[Zope-CVS] CVS: Packages/Moztop/moztop/content/Explorer - Explorer.js:1.2 ExplorerOverlay.xul:1.2

Paul Everitt paul@zope.com
Tue, 28 Jan 2003 16:24:38 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/Explorer
In directory cvs.zope.org:/tmp/cvs-serv12338/Explorer

Modified Files:
	Explorer.js ExplorerOverlay.xul 
Log Message:
Adding and deleting sites works with the Connect button

=== Packages/Moztop/moztop/content/Explorer/Explorer.js 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/Explorer/Explorer.js:1.1	Sat Jan 25 12:44:02 2003
+++ Packages/Moztop/moztop/content/Explorer/Explorer.js	Tue Jan 28 16:24:35 2003
@@ -17,10 +17,6 @@
 
 ******************************************************************************/
 
-// Using jslib "include", import some io utilities
-include('chrome://moztop/content/jslib/io/io.js');
-include('chrome://moztop/content/jslib/io/filesystem.js');
-
 
 /* XML-RPC client setup. */
 function getClient() {
@@ -148,9 +144,59 @@
 }
 
 function getObjectName() {
-    var path = getPath()
+  var path = getPath();
     var parts = path.split('/');
     var obj_name = parts[parts.length-1];
     
     return obj_name
+}
+
+function addSite(site_name, site_url, site_username, site_password) {
+
+  // First some constants for RDF property names
+  var dctitle = "http://www.purl.org/dc/1.1#title";
+  var sitert = "http://www.zope.org/rdf/site#resourcetype";
+  var siteurl = "http://www.zope.org/rdf/site#url";
+  var siteusername = "http://www.zope.org/rdf/site#username";
+  var sitepassword = "http://www.zope.org/rdf/site#password";
+
+  // Grab the datasources
+  var prefsdir = getProfileURL();
+  var sitesds = new RDFDataSource(prefsdir + "/moztop_sites.rdf");
+  var typesds = new RDFDataSource(prefsdir + "/moztop_types.rdf");
+
+  // Create a new node for the new site, attached to the sites list
+  var sc=sitesds.getNode("urn:moztop:sites")
+	.getTarget("http://home.netscape.com/NC-rdf#subitems");
+  var newsite=sitesds.getNode("urn:moztop:sites:" + site_name);
+  var siteres = typesds.getNode("urn:moztop:resourcetypes:site");
+  sc.addChild(newsite);
+
+  // Now fill in the data for the new site
+  newsite.addTarget(dctitle,site_name);
+  newsite.addTarget(siteurl,site_url);
+  newsite.addTarget(siteusername,site_username);
+  newsite.addTarget(sitepassword,site_password);
+  newsite.addTarget(sitert,siteres);
+
+  sitesds.save();  
+
+  //  alert(typesds.serializeToString());
+}
+
+
+/* Delete a site from the datasource. */
+function deleteSelectedSite() {
+
+  // First find out which site should be deleted
+  var tree = document.getElementById("explorertree");
+  var index = tree.view.selection.currentIndex;
+  var rdf = tree.view.getItemAtIndex(index).resource;
+
+  // Grab the datasources
+  var prefsdir = getProfileURL();
+  var sitesds = new RDFDataSource(prefsdir + "/moztop_sites.rdf");
+  sitesds.deleteRecursive(rdf.Value);
+  sitesds.save()
+  return;
 }


=== Packages/Moztop/moztop/content/Explorer/ExplorerOverlay.xul 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/Explorer/ExplorerOverlay.xul:1.1	Sat Jan 25 12:44:02 2003
+++ Packages/Moztop/moztop/content/Explorer/ExplorerOverlay.xul	Tue Jan 28 16:24:35 2003
@@ -8,7 +8,7 @@
 
 <vbox id="explorer">
 <tree flex="1" 
-    id="navigationtree" ref="urn:moztop:sites" 
+    id="explorertree" ref="urn:moztop:sites" 
     datasources="rdf:null" 
     containment="http://home.netscape.com/NC-rdf#subitems">
   <treecols>
@@ -43,7 +43,7 @@
         </bindings>
 
         <action>
-            <treechildren onclick="treechildSelect();" flex="1">
+            <treechildren flex="1">
                 <treeitem uri="?subitem">
                     <treerow>
                         <treecell properties="zope-?styleid" label="?name"/>
@@ -55,6 +55,7 @@
       </rule>
     </template>
 </tree>
+<button label="Delete Site" oncommand="deleteSelectedSite();" />
 
 
 <box orient="vertical">