home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / phoenx05.zip / phoenix / res / rdf / dom-test-2.xul < prev    next >
Extensible Markup Language  |  2002-12-10  |  3KB  |  113 lines

  1. <?xml version="1.0"?>  <!-- -*- Mode: SGML -*- -->
  2. <!--
  3.  
  4.   The contents of this file are subject to the Netscape Public
  5.   License Version 1.1 (the "License"); you may not use this file
  6.   except in compliance with the License. You may obtain a copy of
  7.   the License at http://www.mozilla.org/NPL/
  8.  
  9.   Software distributed under the License is distributed on an "AS
  10.   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11.   implied. See the License for the specific language governing
  12.   rights and limitations under the License.
  13.  
  14.   The Original Code is mozilla.org code.
  15.  
  16.   The Initial Developer of the Original Code is Netscape
  17.   Communications Corporation.  Portions created by Netscape are
  18.   Copyright (C) 1998 Netscape Communications Corporation. All
  19.   Rights Reserved.
  20.  
  21.   Contributor(s): 
  22.  
  23. -->
  24.  
  25. <!--
  26.  
  27. This test exercises some of the DOMAttr stuff.
  28.  
  29. -->
  30. <?xml-stylesheet href="resource:/res/samples/xul.css" type="text/css"?>
  31.  
  32. <window
  33.   xmlns:html="http://www.w3.org/1999/xhtml"
  34.   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  35.   xmlns:nc="http://home.netscape.com/NC-rdf#"
  36.   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  37.  
  38. <html:script>
  39. function DumpAttributes()
  40. {
  41.   // get the personal toolbar folder, which'll be constructed
  42.   // automagically by RDF
  43.   var folder = document.getElementById("NC:PersonalToolbarFolder");
  44.   dump("folder = " + folder + "\n");
  45.   if (folder == null)
  46.     return;
  47.  
  48.   // get the attributes of the folder
  49.   var attrs = folder.attributes;
  50.   dump("attrs = " + attrs + "\n");
  51.   if (attrs == null)
  52.     return;
  53.  
  54.   // iterate n' print
  55.   for (var i = 0; i < attrs.length; ++i) {
  56.     var attr = attrs[i];
  57.     dump("attrs[" + i + "] = " + attr + "\n");
  58.     if (attr != null) {
  59.       dump("attr.name  = " + attr.name +  "\n");
  60.       dump("attr.value = " + attr.value + "\n");
  61.     }
  62.   }
  63. }
  64.  
  65.  
  66. function SetItemText()
  67. {
  68.   var folder = document.getElementById("NC:PersonalToolbarFolder");
  69.   dump("folder = " + folder + "\n");
  70.   if (folder == null)
  71.     return;
  72.  
  73.   var attrs = folder.attributes;
  74.   dump("attrs = " + attrs + "\n");
  75.   if (attrs == null)
  76.     return;
  77.  
  78.   var attr = attrs.getNamedItem('nc:Name');
  79.   dump("attrs.getNamedItem('nc:Name') = " + attr + "\n");
  80.   if (attr == null)
  81.     return;
  82.  
  83.   var newValue = document.getElementById("NewText").value;
  84.   dump("newValue = " + newValue + "\n");
  85.   
  86.   attr.value = newValue;
  87. }
  88.   
  89. </html:script>
  90.  
  91. <html:button onclick="DumpAttributes();">DumpAttributes</html:button>
  92. <html:input id="NewText" type="text"/>
  93. <html:button onclick="SetItemText();">Set Item Text</html:button>
  94.  
  95. <tree id="tree" datasources="rdf:bookmarks" onclick="return OpenURL(event,event.target.parentNode);">
  96.   <treecolgroup>
  97.     <treecol resource="http://home.netscape.com/NC-rdf#Name" flex="1"/>
  98.     <treecol resource="http://home.netscape.com/NC-rdf#URL" flex="1"/>
  99.   </treecolgroup>
  100.   <treehead>
  101.     <treeitem>
  102.       <treecell>Name</treecell>
  103.       <treecell>URL</treecell>
  104.     </treeitem>
  105.   </treehead>
  106.  
  107.   <treebody id="NC:BookmarksRoot">
  108.   </treebody>
  109.   <treechildren flex="1"/>
  110. </tree>
  111.  
  112. </window>
  113.