[Zope-CVS] CVS: Packages/Moztop/moztop/content/Inspector - Sites.js:1.6 SitesOverlay.xul:1.4
Stephan Richter
srichter@cbu.edu
Tue, 14 Jan 2003 11:00:31 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/Inspector
In directory cvs.zope.org:/tmp/cvs-serv26137/moztop/content/Inspector
Modified Files:
Sites.js SitesOverlay.xul
Log Message:
- Made new Site.js code a little nicer.
- Got deleting of Sites working.
rdfds rules!
=== Packages/Moztop/moztop/content/Inspector/Sites.js 1.5 => 1.6 ===
--- Packages/Moztop/moztop/content/Inspector/Sites.js:1.5 Tue Jan 14 10:18:37 2003
+++ Packages/Moztop/moztop/content/Inspector/Sites.js Tue Jan 14 11:00:29 2003
@@ -1,87 +1,51 @@
-var RDF =
- Components
+var RDF = Components
.classes["@mozilla.org/rdf/rdf-service;1"]
.getService(Components.interfaces.nsIRDFService);
-var ds=null;
+var sites_source = new RDFDataSource();
-var sites_source =
- Components
- .classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"]
- .createInstance(Components.interfaces.nsIRDFDataSource);
-
-function initSites()
-{
-
- /*
- * This sample RDF is used by some of the examples. It is serialized into
- * a new datasource.
- */
- var sample='<?xml version="1.0"?>' +
- '<RDF:RDF xmlns:z="http://www.zope.org/rdf/site#"' +
- ' xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
+function initSites() {
+ /* Sample RDF string that sets the format of the RDF source. */
+ var sample = '<?xml version="1.0"?>' +
+ '<RDF:RDF ' +
+ ' xmlns:site="http://www.zope.org/rdf/site#"' +
+ ' xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
+
' <RDF:Seq about="urn:sites:data">' +
' <RDF:li resource="urn:sites:data:mysite"/>' +
' </RDF:Seq>' +
+
' <RDF:Description about="urn:sites:data:mysite" ' +
- ' z:servername="My Site" ' +
- ' z:serverport="9000" ' +
- ' z:username="Paul"/>' +
+ ' site:servername="My Site" ' +
+ ' site:serverport="9000" ' +
+ ' site:username="Paul" ' +
+ ' site:password="foo"/>' +
'</RDF:RDF>';
- ds=new RDFDataSource();
- ds.parseFromString(sample,"http://192.168.1.3:9080/");
- var tree = document.getElementById("sites-tree");
- tree.database.AddDataSource(ds.getRawDataSource());
- tree.builder.rebuild();
-
+ /* Create new datasource */
+ sites_source.parseFromString(sample, "http://localhost:8080/");
+ /* Add datasource to tree */
+ var tree = document.getElementById("sites-tree");
+ tree.database.AddDataSource(sites_source.getRawDataSource());
+ tree.builder.rebuild();
}
-function addSite (servername, serverport, username) {
-
- var sites=ds.getNode("urn:sites:data");
- var newsite=ds.getNode("urn:sites:data:" + servername);
- sites.addChild(newsite);
-
- newsite.addTarget("http://www.zope.org/rdf/site#servername",servername);
- newsite.addTarget("http://www.zope.org/rdf/site#serverport",serverport);
- newsite.addTarget("http://www.zope.org/rdf/site#username",username);
- alert(ds.serializeToString());
-}
-
-function oldaddSite(servername, serverport, username, password) {
- var root = "urn:sites:" + servername+"_"+serverport
- sites_source.Assert(RDF.GetResource(root),
- RDF.GetResource("http://www.zope.org/rdf/site#servername"),
- RDF.GetLiteral(servername),
- true);
-
- sites_source.Assert(RDF.GetResource(root),
- RDF.GetResource("http://www.zope.org/rdf/site#serverport"),
- RDF.GetLiteral(serverport),
- true);
-
- sites_source.Assert(RDF.GetResource(root),
- RDF.GetResource("http://www.zope.org/rdf/site#username"),
- RDF.GetLiteral(username),
- true);
-
- sites_source.Assert(RDF.GetResource(root),
- RDF.GetResource("http://www.zope.org/rdf/site#password"),
- RDF.GetLiteral(password),
- true);
-
- sites_source.Assert(RDF.GetResource("urn:sites:data"),
- RDF.GetResource("http://www.zope.org/rdf/site#child"),
- RDF.GetLiteral(root),
- true);
+function addSite(servername, serverport, username, password) {
+ var sites = sites_source.getNode("urn:sites:data");
+ var newsite = sites_source.getNode("urn:sites:data:" + servername);
+ sites.addChild(newsite);
+
+ newsite.addTarget("http://www.zope.org/rdf/site#servername", servername);
+ newsite.addTarget("http://www.zope.org/rdf/site#serverport", serverport);
+ newsite.addTarget("http://www.zope.org/rdf/site#username", username);
+ newsite.addTarget("http://www.zope.org/rdf/site#password", password);
+ // alert(sites_source.serializeToString());
}
-
function deleteSelectedSite() {
var tree = document.getElementById("sites-tree");
- alert(tree.builder);
+ // source = tree.database.GetDataSources
var start = new Object();
var end = new Object();
var numRanges = tree.view.selection.getRangeCount();
@@ -90,11 +54,9 @@
tree.view.selection.getRangeAt(t,start,end);
for (var v = start.value; v <= end.value; v++){
var builder = tree.builder.QueryInterface(
- Components.interfaces.nsIXULTreeBuilder)
- rdf = builder.getResourceAtIndex(v)
- sites_source.Unassert(RDF.GetResource("urn:sites:data"),
- RDF.GetResource("http://www.zope.org/rdf/site#child"),
- RDF.GetResource(rdf.Value));
+ Components.interfaces.nsIXULTreeBuilder);
+ rdf = builder.getResourceAtIndex(v);
+ sites_source.deleteRecursive(rdf.Value)
}
}
}
=== Packages/Moztop/moztop/content/Inspector/SitesOverlay.xul 1.3 => 1.4 ===
--- Packages/Moztop/moztop/content/Inspector/SitesOverlay.xul:1.3 Tue Jan 14 10:18:37 2003
+++ Packages/Moztop/moztop/content/Inspector/SitesOverlay.xul Tue Jan 14 11:00:29 2003
@@ -10,7 +10,7 @@
<tabpanel id="sites-panel">
-<button onclick="addSite('test5.com', '8081', 'stephan');"
+<button onclick="addSite('test5.com', '8081', 'stephan', 'bar');"
label="Add Site" />
<button onclick="deleteSelectedSite();" label="Delete Site" />