[Zope-CVS] CVS: Packages/Moztop/moztop/content/Menu - ToolBar.js:1.2 ToolBarOverlay.xul:1.4
Stephan Richter
srichter@cbu.edu
Tue, 14 Jan 2003 20:26:42 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/Menu
In directory cvs.zope.org:/tmp/cvs-serv6091/moztop/content/Menu
Modified Files:
ToolBar.js ToolBarOverlay.xul
Log Message:
I think this is a good checkpoint to make a checkin:
- Now we can add Folders in any arbitrary Sub-Folder.
- I needed to fix the nsXmlRpcClient.js file, so I provide the fixed
version here.
- Updated CHANGES.txt.
- Updated INSTALL.txt to reflect the fix for nzXmlRpcClient.js and made
a note that a nightly build is required, since the XML-RPC lib does not
work in 1.2.1.
=== Packages/Moztop/moztop/content/Menu/ToolBar.js 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/Menu/ToolBar.js:1.1 Tue Jan 14 12:09:02 2003
+++ Packages/Moztop/moztop/content/Menu/ToolBar.js Tue Jan 14 20:26:38 2003
@@ -1,5 +1,63 @@
+var ZOPE3_URL='http://localhost:8081/'
+function getClient() {
+ return Components.classes['@mozilla.org/xml-rpc/client;1']
+ .createInstance(Components.interfaces.nsIXmlRpcClient);
+}
-function addFolder () {
- alert('ouch!');
-}
\ No newline at end of file
+var xmlRpcClient;
+function getXmlRpc() {
+ if (!xmlRpcClient) xmlRpcClient = getClient();
+ return xmlRpcClient;
+}
+
+var Listener = {
+ onResult: function(client, ctxt, result) {
+ /* result = result.QueryInterface(
+ Components.interfaces.nsISupportsString);
+ alert(result.data); */
+ alert('Object successfully added');
+ },
+
+ onFault: function(client, ctxt, fault) {
+ alert('Fault! ' + fault + '\n');
+ },
+
+ onError: function(client, ctxt, status, errorMsg) {
+ alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
+ }
+};
+
+
+function sendAddRequest(parent, obj_type, obj_name) {
+ var xmlRpc = getXmlRpc();
+ xmlRpc.init(ZOPE3_URL + parent);
+ var type = xmlRpc.createType(xmlRpc.STRING, {});
+ type.data = obj_type;
+ var name = xmlRpc.createType(xmlRpc.STRING, {});
+ name.data = obj_name;
+ xmlRpc.asyncCall(Listener, null, 'createAndAdd', [type, name], 2);
+}
+
+
+/* Add a Folder */
+function addFolder() {
+ var tree = document.getElementById("navigationtree");
+ var start = new Object();
+ var end = new Object();
+ var source = new Object();
+ var numRanges = tree.view.selection.getRangeCount();
+
+ for (var t=0; t<numRanges; t++){
+ tree.view.selection.getRangeAt(t,start,end);
+ for (var v = start.value; v <= end.value; v++){
+ rdf = tree.view.getItemAtIndex(v).resource;
+ var parent = rdf.Value.replace('urn:explorer:data', '') + '/';
+ while (parent.indexOf(":") > -1)
+ parent = parent.replace(":", "/");
+ alert(parent);
+ sendAddRequest(parent, 'Folder', 'FooBar');
+ }
+ }
+
+}
=== Packages/Moztop/moztop/content/Menu/ToolBarOverlay.xul 1.3 => 1.4 ===
--- Packages/Moztop/moztop/content/Menu/ToolBarOverlay.xul:1.3 Tue Jan 14 12:09:02 2003
+++ Packages/Moztop/moztop/content/Menu/ToolBarOverlay.xul Tue Jan 14 20:26:38 2003
@@ -17,6 +17,7 @@
label="Add Task" />
<button onclick="deleteSelectedTask();" label="Delete Task" />
<button onclick="addFolder(); return false;" label="Add folder" />
+ <button onclick="reloadContentData();" label="Reload Content" />
<spring flex="100%" />
</toolbar>