twingle/twingle/content/navigation navigation.js,1.2,1.3 navigationoverlay.xul,1.1.1.1,1.2
[email protected] Sat, 8 Mar 2003 08:24:38 -0700 (MST)
| Newsgroups | gmane.comp.cms.oscom.twingle.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/root/twingle/twingle/content/navigation
In directory alpha.oscom.org:/tmp/cvs-serv6868/content/navigation
Modified Files:
navigation.js navigationoverlay.xul
Log Message:
Changed to rely on jslib, now have two sites by default
Index: navigation.js
===================================================================
RCS file: /cvs/root/twingle/twingle/content/navigation/navigation.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** navigation.js 6 Mar 2003 20:37:42 -0000 1.2
--- navigation.js 8 Mar 2003 15:24:36 -0000 1.3
***************
*** 1,3 ****
!
--- 1,3 ----
! /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
***************
*** 33,37 ****
-
function SitesDataSource () {
--- 33,36 ----
***************
*** 51,63 ****
this.styleidprop = this.oscomrdfns + "styleid";
this.subitemsprop = this.ncns + "subitems";
! this.profileurl = getProfileDirURL();
! this.elementid = null;
!
! this.ds = new RDFDataSource(this.profileurl + "/twinglesites.rdf",null);
! this.commontypesds = new RDFDataSource();
! // this.commontypesds.parseFromString(commontypes_data,"http://www.zope.org/rdf");
! this.elementid = 'navigation-tree';
this.sitedatasources = new Array();
--- 50,61 ----
this.styleidprop = this.oscomrdfns + "styleid";
this.subitemsprop = this.ncns + "subitems";
+ this.elementid = 'navigation-tree';
! var twingleurl = getProfileDirURL() + 'twingle';
! // Create some default datasources
! this.sitesds = new RDFDataSource(twingleurl + "/sites.rdf",null);
! this.oscomtypesds = new RDFDataSource(twingleurl + "/oscomtypes.rdf",null);
! this.localsiteds = new RDFDataSource(twingleurl + "/localsite.rdf",null);
this.sitedatasources = new Array();
***************
*** 65,119 ****
/* Attach these (potentially empty) datasources */
var tree=document.getElementById(this.elementid);
! tree.database.AddDataSource(this.ds.getRawDataSource());
! // tree.database.AddDataSource(this.commontypesds.getRawDataSource());
! tree.builder.rebuild();
! }
!
! /* Detect if this is an initial install. If so, initialize. */
! SitesDataSource.prototype.initializeProfileDatabases=
! function ()
{
! /* Are there databases in profile dir? If so, log a message and return */
! var allres = this.ds.getAllResources();
! if (allres.hasMoreElements()) {
! dump("\nFound existing twingle sites database");
! return;
! }
!
!
! /* If we make it here, it means we need to create twingle databases */
! var rootnode = this.ds.getNode("urn:twingle:sites");
! var subitems = this.ds.getNode("urn:twingle:sites:subitems");
! subitems.makeSeq();
! rootnode.addTarget(this.subitemsprop,subitems);
!
! /* Just to be fun, let's add two sites by default, local and OSCOM */
!
!
!
! this.ds.save();
! return;
! }
! function initNavigator ()
! {
! sitesds = new SitesDataSource();
! sitesds.initializeProfileDatabases();
! return;
}
! function openSelectedResource ()
{
dump("\nin openSelectedResource");
var tp = document.createElement("defaulttype");
tp.id = "123";
! tp.setAttribute("resourcetitle","My Document");
tp.setAttribute("sourceurl","http://www.oscom.org");
tp.setAttribute("previewurl","http://www.oscom.org");
--- 63,104 ----
/* Attach these (potentially empty) datasources */
var tree=document.getElementById(this.elementid);
! tree.database.AddDataSource(this.sitesds.getRawDataSource());
! tree.database.AddDataSource(this.oscomtypesds.getRawDataSource());
! tree.database.AddDataSource(this.localsiteds.getRawDataSource());
! tree.builder.rebuild();
+ dump("\nfinished add datasources and rebuilding tree");
+ }
! SitesDataSource.prototype.getSelectedResource = function ()
{
+ /* For all trees, this returns a selected resource as an RDFNode */
+ var tree = document.getElementById(this.elementid);
+ var index = tree.view.selection.currentIndex;
! /* We need to work with the composite DS */
! var treedb = tree.database;
! var compositeds = new RDFDataSource();
! compositeds.Init(treedb);
+ if (index == -1) return false;
+ var rdf = tree.view.getItemAtIndex(index).resource;
! return compositeds.getNode(rdf.Value);
}
! SitesDataSource.prototype.openSelectedResource = function ()
{
+ /* Grab the selected resource and open a new tab */
dump("\nin openSelectedResource");
+ var rdf = this.getSelectedResource();
+ var resourcetitle = rdf.getTarget(this.titleprop).getValue();
+
var tp = document.createElement("defaulttype");
tp.id = "123";
! tp.setAttribute("resourcetitle",resourcetitle);
tp.setAttribute("sourceurl","http://www.oscom.org");
tp.setAttribute("previewurl","http://www.oscom.org");
***************
*** 122,127 ****
--- 107,121 ----
outter.appendChild(tp);
+
dump("\nout of openSelectedResource");
return;
+
+ }
+
+
+ function initNavigator ()
+ {
+ sitesds = new SitesDataSource();
+ return;
}
Index: navigationoverlay.xul
===================================================================
RCS file: /cvs/root/twingle/twingle/content/navigation/navigationoverlay.xul,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** navigationoverlay.xul 5 Mar 2003 19:30:31 -0000 1.1.1.1
--- navigationoverlay.xul 8 Mar 2003 15:24:36 -0000 1.2
***************
*** 9,18 ****
<tree flex="1" id="navigation-tree" ref="urn:twingle:sites"
! datasources="chrome://twingle/content/sampledata/sites.rdf
! chrome://twingle/content/sampledata/oscomtypes.rdf
! chrome://twingle/content/sampledata/localsite.rdf
! chrome://twingle/content/sampledata/oscomorg.rdf"
containment="http://home.netscape.com/NC-rdf#subitems"
! ondblclick="openSelectedResource();">
<treecols>
--- 9,15 ----
<tree flex="1" id="navigation-tree" ref="urn:twingle:sites"
! datasources="chrome://twingle/content/sampledata/oscomorg.rdf"
containment="http://home.netscape.com/NC-rdf#subitems"
! ondblclick="sitesds.openSelectedResource();">
<treecols>