This commit is contained in:
slamm%netscape.com 1999-07-12 23:24:22 +00:00
Родитель 48c53c1488
Коммит ee1fcf5b42
5 изменённых файлов: 0 добавлений и 555 удалений

Просмотреть файл

@ -1,158 +0,0 @@
// Note that there is a bug with resource: URLs right now.
//var FileURL = "file:///C:/matt/rdf/sidebar-browser.rdf";
var FileURL = "resource:/res/rdf/sidebar-browser.rdf";
// var the "NC" namespace. Used to construct resources
var NC = "http://home.netscape.com/NC-rdf#";
function writeRDF(title,content,customize,append)
{
// Get the RDF service
var RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
dump("RDF = " + RDF + "\n");
// Open the RDF file synchronously. This is tricky, because
// GetDataSource() will do it asynchronously. So, what we do is
// this. First try to manually construct the RDF/XML datasource
// and read it in. This might throw an exception if the datasource
// has already been read in once. In which case, we'll just get
// the existing datasource from the RDF service.
var datasource;
try {
datasource = Components.classes["component://netscape/rdf/datasource?name=xml-datasource"].createInstance();
datasource = datasource.QueryInterface(Components.interfaces.nsIRDFXMLDataSource);
datasource.Init(FileURL);
datasource.Open(true);
dump("datasource = " + datasource + ", opened for the first time.\n");
}
catch (ex) {
datasource = RDF.GetDataSource(FileURL);
dump("File:" + FileURL + " datasource = " + datasource + ", using registered datasource.\n");
}
// Create a "container" wrapper around the "NC:BrowserSidebarRoot"
// object. This makes it easier to manipulate the RDF:Seq correctly.
var container = Components.classes["component://netscape/rdf/container"].createInstance();
container = container.QueryInterface(Components.interfaces.nsIRDFContainer);
container.Init(datasource, RDF.GetResource("NC:BrowserSidebarRoot"));
dump("initialized container " + container + " on NC:BrowserSidebarRoot\n");
// Now append a new resource to it. The resource will have the URI
// "file:///D:/tmp/container.rdf#3".
var count = container.GetCount();
dump("container has " + count + " elements\n");
var element = RDF.GetResource(FileURL + "#" + count);
dump(FileURL + "#" + count + "\n");
if (append == 0 ) {
container.AppendElement(element);
//container.RemoveElement(element,true);
dump("appended " + element + " to the container\n");
// Now make some sidebar-ish assertions about it...
datasource.Assert(element,
RDF.GetResource(NC + "title"),
RDF.GetLiteral(title),
true);
datasource.Assert(element,
RDF.GetResource(NC + "content"),
RDF.GetLiteral(content),
true);
datasource.Assert(element,
RDF.GetResource(NC + "customize"),
RDF.GetLiteral(customize),
true);
dump("added assertions about " + element + "\n");
} else {
var element = 'file://C:/matt/rdf/sidebar-browser.rdf#bookmarks';
dump(element);
container.RemoveElement(element,true);
}
// Now serialize it back to disk
//datasource.Flush();
dump("wrote " + FileURL + " back to disk.\n");
}
function selected(event, node)
{
dump('node:\n' + node);
selectedNode_Title = node.getAttribute('title');
selectedNode_Content = node.getAttribute('content');
selectedNode_Customize = node.getAttribute('customize');
}
function Addit()
{
if (window.frames[0].selectedNode_Title != null) {
dump(window.frames[0].selectedNode_Title + '\n');
createOption();
} else {
dump('Nothing selected');
}
}
function createOption() {
var selectedNode_Title = window.frames[0].selectedNode_Title;
var selectedNode_Content = window.frames[0].selectedNode_Content;
var selectedNode_Customize = window.frames[0].selectedNode_Customize;
var list = parent.frames[0].document.getElementById('selectList');
dump('Here' + selectedNode_Title);
writeRDF(selectedNode_Title,selectedNode_Content,selectedNode_Customize,0)
//dump(option_title + "\n");
parent.frames[0].location.reload();
}
/*
function createOption() {
var selectedNode_Title = window.frames[0].selectedNode_Title;
var selectedNode_Content = window.frames[0].selectedNode_Content;
var selectedNode_Customize = window.frames[0].selectedNode_Customize;
var list = parent.frames[0].document.getElementById('selectList');
//dump(option_title + "\n");
var optionSelect = parent.frames[0].createOptionTitle(selectedNode_Title);
var option = parent.frames[0].document.createElement('html:option');
dump(option + "\n");
option.setAttribute('title', selectedNode_Title);
option.setAttribute('customize', selectedNode_Content);
option.setAttribute('content', selectedNode_Customize);
option.appendChild(optionSelect);
return option;
}
function createOptionTitle(titletext)
{
dump('create optionText');
var title = parent.frames[0].document.createElement('html:option');
var textOption = parent.frames[0].document.createTextNode(titletext);
//should be able to use title.add actaully
dump("TextOption:\n" + textOption + "\n");
title.appendChild(textOption);
return textOption;
}
*/

Просмотреть файл

@ -1,37 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script src="dialog.js" />
<tree id="tree"
datasources="resource:/res/rdf/sidebar-registry.rdf"
onclick="selected(event,event.target.parentNode)" >
<!-- The template we'll use to build rows in the content model. -->
<template containment="treeitem" rootcontainment="treebody" subcontainment="treechildren">
<treeitem uri="...">
<treecell>
<treeindentation />
<titledbutton />
<text rdf:resource="http://home.netscape.com/NC-rdf#title" />
</treecell>
</treeitem>
</template>
<!-- The tree header: display some column info. -->
<treehead>
<treeitem>
<treecell>Title</treecell>
</treeitem>
</treehead>
<!-- The tree body: it's rooted at sitemap1.rdf's root -->
<treebody ref="NC:BrowserSidebarRoot" />
</tree>
</window>

Просмотреть файл

@ -1,299 +0,0 @@
// -*- Mode: Java -*-
// the rdf service
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
// the current profile directory
// XXX obviously, this shouldn't be hard-coded
var profiledir = 'resource:/res/rdf/';
// the location of the flash registry.
var sidebardb = profiledir + 'sidebar-browser.rdf';
//var sidebardb = 'file:///C:/matt/rdf/sidebar-browser.rdf';
var sidebar_resource = 'NC:BrowserSidebarRoot';
function dumpTree(node, depth) {
var inde
nt = "| | | | | | | | | | | | | | | | | | | | | | | | | | | | | + ";
var kids = node.childNodes;
dump(indent.substr(indent.length - depth*2));
// Print your favorite attributes here
dump(node.nodeName)
dump(" "+node.getAttribute('id'));
dump("\n");
for (var ii=0; ii < kids.length; ii++) {
dumpTree(kids[ii], depth + 1);
}
}
function Init(sidebardb, sidebar_resource)
{
dump("here we go \n");
// Initialize the Sidebar
// Install all the datasources named in the Flash Registry into
// the tree control. Datasources are listed as members of the
// NC:FlashDataSources sequence, and are loaded in the order that
// they appear in that sequence.
var registry = RDF.GetDataSource(sidebardb);
// Create a 'container' wrapper around the sidebar_resources
// resource so we can use some utility routines that make access a
// bit easier.
var sb_datasource = Components.classes['component://netscape/rdf/container'].createInstance();
sb_datasource = sb_datasource.QueryInterface(Components.interfaces.nsIRDFContainer);
sb_datasource.Init(registry, RDF.GetResource(sidebar_resource));
var sideoption = document.getElementById('selectList');
// Now enumerate all of the flash datasources.
dump(sb_datasource.GetElements() + '\n');
var enumerator = sb_datasource.GetElements();
var count = 0;
var countTotal = sb_datasource.GetCount();
dump("Start Get:" + countTotal + "\n");
while (enumerator.HasMoreElements()) {
count = ++count;
dump(count + "\n");
var service = enumerator.GetNext();
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
var new_option = createOption(registry, service);
if (new_option) {
sideoption.appendChild(new_option);
}
}
}
function createOption(registry, service) {
var option_title = getAttr(registry, service, 'title');
var option_customize = getAttr(registry, service, 'customize');
var option_content = getAttr(registry, service, 'content');
dump(option_title + "\n");
var optionSelect = createOptionTitle(option_title);
var option = document.createElement('html:option');
dump(option);
option.setAttribute('title', option_title);
option.setAttribute('customize', option_customize);
option.setAttribute('content', option_content);
option.appendChild(optionSelect);
return option;
}
function createOptionTitle(titletext)
{
dump('create optionText');
var title = document.createElement('html:option');
var textOption = document.createTextNode(titletext);
//should be able to use title.add actaully
title.appendChild(textOption);
return textOption;
}
function getAttr(registry,service,attr_name) {
var attr = registry.GetTarget(service,
RDF.GetResource('http://home.netscape.com/NC-rdf#' + attr_name),
true);
if (attr)
attr = attr.QueryInterface(
Components.interfaces.nsIRDFLiteral);
if (attr)
attr = attr.Value;
return attr;
}
function Reload(url, pollInterval)
{
// Reload the specified datasource and reschedule.
dump('Reload(' + url + ', ' + pollInterval + ')\n');
var datasource = RDF.GetDataSource(url);
datasource = datasource.QueryInterface(Components.interfaces.nsIRDFXMLDataSource);
// Reload, asynchronously.
datasource.Open(false);
// Reschedule
Schedule(url, pollInterval);
}
function Schedule(url, pollInterval)
{
setTimeout('Reload("' + url + '", ' + pollInterval + ')', pollInterval * 1000);
}
function OpenURL(node)
{
dump("open-url(" + node + ")\n");
}
function moveUp() {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
if (list.selectedIndex != -1) {
var listOption = list.childNodes.item(listSelect).cloneNode(true);
var listOptionBefore = list.childNodes.item(listSelect-1);
list.remove(listSelect);
list.insertBefore(listOption, listOptionBefore);
dump("\n" + listOption + "\n");
}
}
function moveDown() {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
dump("list\n" + listSelect);
if (list.selectedIndex != -1) {
var listOption = list.childNodes.item(listSelect);
var listOptionBefore = list.childNodes.item(listSelect+1).cloneNode(true);
list.remove(listSelect+1);
list.insertBefore(listOptionBefore, listOption);
dump("\n" + listOption + "\n");
}
}
function deleteOption()
{
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
if (list.selectedIndex != -1) {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
list.remove(listSelect);
}
}
function DumpIt() {
var list = document.getElementById('selectList');
var listLen = list.childNodes.length;
for (var i=0;i<listLen; ++i) {
dump('length:' + listLen + '\n');
dump(list.childNodes.item(i).getAttribute('title') + '\n');
writeRDF(list.childNodes.item(i).getAttribute('title'),list.childNodes.item(i).getAttribute('content'),list.childNodes.item(i).getAttribute('customize'),0);
}
}
function save() {
self.close();
}
// Note that there is a bug with resource: URLs right now.
var FileURL = "file:///C:/matt/rdf/sidebar-browser.rdf";
// var the "NC" namespace. Used to construct resources
var NC = "http://home.netscape.com/NC-rdf#";
function writeRDF(title,content,customize,append)
{
// Get the RDF service
var RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
dump("RDF = " + RDF + "\n");
// Open the RDF file synchronously. This is tricky, because
// GetDataSource() will do it asynchronously. So, what we do is
// this. First try to manually construct the RDF/XML datasource
// and read it in. This might throw an exception if the datasource
// has already been read in once. In which case, we'll just get
// the existing datasource from the RDF service.
var datasource;
try {
datasource = Components.classes["component://netscape/rdf/datasource?name=xml-datasource"].createInstance();
datasource = datasource.QueryInterface(Components.interfaces.nsIRDFXMLDataSource);
datasource.Init(FileURL);
datasource.Open(true);
dump("datasource = " + datasource + ", opened for the first time.\n");
}
catch (ex) {
datasource = RDF.GetDataSource(FileURL);
dump("datasource = " + datasource + ", using registered datasource.\n");
}
// Create a "container" wrapper around the "NC:BrowserSidebarRoot"
// object. This makes it easier to manipulate the RDF:Seq correctly.
var container = Components.classes["component://netscape/rdf/container"].createInstance();
container = container.QueryInterface(Components.interfaces.nsIRDFContainer);
container.Init(datasource, RDF.GetResource("NC:BrowserSidebarRoot"));
dump("initialized container " + container + " on NC:BrowserSidebarRoot\n");
// Now append a new resource to it. The resource will have the URI
// "file:///D:/tmp/container.rdf#3".
var count = container.GetCount();
dump("container has " + count + " elements\n");
var element = RDF.GetResource(FileURL + "#" + count);
dump(FileURL + "#" + count + "\n");
if (append == 0 ) {
container.AppendElement(element);
//container.RemoveElement(element,true);
dump("appended " + element + " to the container\n");
// Now make some sidebar-ish assertions about it...
datasource.Assert(element,
RDF.GetResource(NC + "title"),
RDF.GetLiteral(title + ' ' + count),
true);
datasource.Assert(element,
RDF.GetResource(NC + "content"),
RDF.GetLiteral(content),
true);
datasource.Assert(element,
RDF.GetResource(NC + "customize"),
RDF.GetLiteral(customize),
true);
dump("added assertions about " + element + "\n");
} else {
var element = 'file://C:/matt/rdf/sidebar-browser.rdf#bookmarks';
dump(element);
container.RemoveElement(element,true);
}
// Now serialize it back to disk
datasource.Flush();
dump("wrote " + FileURL + " back to disk.\n");
}
// To get around "window.onload" not working in viewer.
function Boot()
{
var root = document.documentElement;
dump("booting \n");
if (root == null) {
setTimeout(Boot, 0);
}
else {
Init(sidebardb, sidebar_resource);
}
}
setTimeout('Boot()', 0);
dump("finished\n");

Просмотреть файл

@ -1,61 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="resource:/res/samples/xul.css" type="text/css"?>
<!DOCTYPE window>
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script src="dialogSidebar.js" />
Current My Sidebar
<html:div>
<box align="horizontal">
<html:form name="one">
<html:select name="two" id="selectList" size="10" multiple="true">
</html:select>
</html:form>
<box align="vertical">
<spring flex="100%"/>
<html:button style="width:144px; height:15px;" onclick="moveUp()">
<html:div>Move Up</html:div>
</html:button>
<spring style="width:15px"/>
<html:button style="width:108px; height:15px;" onclick="moveDown()">
<html:div>Move Down</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="dump('here');deleteOption()">
<html:div>Remove</html:div>
</html:button>
<spring style="width:15px"/>
<html:button style="width:108px; height:15px;" onclick="parent.frames[1].location.href = 'about:blank'">
<html:div>Customize</html:div>
</html:button>
<!-- <html:button style="width:108px; height:15px;" onclick="writeRDF('New Panel','http://foo.com/content.html','http://foo.com/customize.html',0)">
<html:div>Add</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="writeRDF('New Panel','http://foo.com/content.html','http://foo.com/customize.html',1)">
<html:div>Remove</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="DumpIt()">
<html:div>RemoveIt</html:div>
</html:button> -->
</box>
</box>
</html:div>
</window>

Просмотреть файл