gecko-dev/rdf/resources/dom-test-3.xul

70 строки
2.1 KiB
Plaintext
Исходник Обычный вид История

1999-04-16 12:39:29 +04:00
<?xml version="1.0"?>
<!--
This test exercises creation of DOM elements from the XUL document. It
creates a bookmark element and tries to insert it.
-->
<?xml-stylesheet href="resource:/res/samples/xul.css" type="text/css"?>
1999-04-16 12:39:29 +04:00
<window
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
1999-04-16 12:39:29 +04:00
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script>
function AddBookmark()
{
// get the personal toolbar folder, which'll be constructed
// automagically by RDF
var folder = document.getElementById("NC:PersonalToolbarFolder");
dump("folder = " + folder + "\n");
if (folder == null)
return;
var treechildren = null;
for (var i = folder.childNodes.length - 1; i >= 0; --i) {
dump('folder.childNodes[' + i + '].nodeName = ' + folder.childNodes[i].nodeName + '\n');
if (folder.childNodes[i].nodeName == 'treechildren') {
treechildren = folder.childNodes[i];
break;
}
}
dump("treechildren = " + treechildren + "\n");
if (treechildren == null) {
treechildren = document.createElement('treechildren');
folder.appendChild(treechildren);
}
var newItem = document.createElement('treeitem');
newItem.setAttribute('id', 'http://home.netscape.com/people/waterson');
newItem.setAttribute('type', 'http://home.netscape.com/NC-rdf#Bookmark');
newItem.setAttribute('nc:Name', 'My Home Page');
newItem.setAttribute('rdf:property', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_5');
1999-04-16 12:39:29 +04:00
treechildren.appendChild(newItem);
}
</html:script>
<html:button onclick="AddBookmark();">Add Bookmark</html:button>
<tree id="tree" datasources="rdf:bookmarks" onclick="return OpenURL(event,event.target.parentNode);">
<treecolgroup>
<treecol resource="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<treecol resource="http://home.netscape.com/NC-rdf#URL" flex="1"/>
</treecolgroup>
1999-04-16 12:39:29 +04:00
<treehead>
<treeitem>
<treecell>Name</treecell>
<treecell>URL</treecell>
</treeitem>
</treehead>
<treebody id="NC:BookmarksRoot">
</treebody>
</tree>
</window>