home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / res / rdf / dom-test-1.xul < prev    next >
Extensible Markup Language  |  2001-02-14  |  4KB  |  135 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 simple DOM manipulation on a tree control
  28.  
  29. -->
  30.  
  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="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  36.   align="vertical">
  37.  
  38.   <html:script>
  39.   function RemovePersonalToolbar()
  40.   {
  41.     var personalToolbarFolder = document.getElementById("NC:PersonalToolbarFolder");
  42.     dump("personalToolbarFolder = " + personalToolbarFolder + "\n");
  43.     if (personalToolbarFolder == null)
  44.       return;
  45.   
  46.     var bookmarksRoot = document.getElementById("NC:BookmarksRoot");
  47.     dump("bookmarksRoot = " + bookmarksRoot + "\n");
  48.     if (bookmarksRoot == null)
  49.       return;
  50.   
  51.     bookmarksRoot.removeChild(personalToolbarFolder);
  52.   }
  53.   
  54.   function AddPersonalToolbar()
  55.   {
  56.     var bookmarksRoot = document.getElementById("NC:BookmarksRoot");
  57.     dump("bookmarksRoot = " + bookmarksRoot + "\n");
  58.     if (bookmarksRoot == null)
  59.       return;
  60.   
  61.     var personalToolbarFolder = document.getElementById("NC:PersonalToolbarFolder");
  62.     dump("personalToolbarFolder = " + personalToolbarFolder + "\n");
  63.     if (personalToolbarFolder != null) // already there
  64.       return;
  65.   
  66.     personalToolbarFolder = document.createElement("xul:treeitem");
  67.     personalToolbarFolder.setAttribute("id", "NC:PersonalToolbarFolder");
  68.     bookmarksRoot.appendChild(personalToolbarFolder);
  69.   }
  70.   
  71.   function MutateBody()
  72.   {
  73.     // This test changes the "id" attribute on the treebody
  74.     var tree = document.getElementById("tree");
  75.     dump("tree = " + tree + "\n");
  76.  
  77.     var currentRef = tree.getAttribute("ref");
  78.     dump("currentRef = " + currentRef + "\n");
  79.  
  80.     if (currentRef == "NC:BookmarksRoot") {
  81.       tree.setAttribute("ref", "NC:PersonalToolbarFolder");
  82.     }
  83.     else {
  84.       tree.setAttribute("ref", "NC:BookmarksRoot");
  85.     }
  86.   }
  87.   </html:script>
  88.  
  89.   <box align="horizontal">  
  90.     <html:button onclick="RemovePersonalToolbar();">Remove Personal Toolbar</html:button>
  91.     <html:button onclick="AddPersonalToolbar();">Add Personal Toolbar</html:button>
  92.     <html:button onclick="MutateBody();">Swap Body (Bookmarks Root/Personal Toolbar Folder)</html:button>
  93.   </box>
  94.  
  95.   <tree id="tree" datasources="rdf:bookmarks" onclick="return OpenURL(event,event.target.parentNode);" ref="NC:BookmarksRoot">
  96.     <template>
  97.       <rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
  98.         <treechildren>
  99.           <treeitem uri="...">
  100.             <treerow>
  101.               <treecell>
  102.                 <html:hr width="75%" align="center" size="1" />
  103.               </treecell>
  104.             </treerow>
  105.           </treeitem>          
  106.         </treechildren>
  107.       </rule>
  108.  
  109.       <rule>
  110.         <treechildren>
  111.           <treeitem uri="...">
  112.             <treerow>
  113.               <treecell>
  114.                 <treeindentation />
  115.                 <titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name" align="right" />
  116.               </treecell>
  117.               <treecell>
  118.                 <titledbutton value="rdf:http://home.netscape.com/NC-rdf#URL" align="right" style="list-style-image: none;" />
  119.               </treecell>
  120.             </treerow>
  121.           </treeitem>
  122.         </treechildren>
  123.       </rule>
  124.     </template>
  125.  
  126.     <treehead>
  127.       <treerow>
  128.         <treecell>Name</treecell>
  129.         <treecell>URL</treecell>
  130.       </treerow>
  131.     </treehead>
  132.   </tree>
  133.  
  134. </window>
  135.