html5/markup/js dfn.js,1.6,1.7 jump-indexes.js,1.8,1.9

Update of /sources/public/html5/markup/js
In directory hutz:/tmp/cvs-serv30623/js

Modified Files:
	dfn.js jump-indexes.js 
Log Message:
build tweaks to make dfn pop-ups more useful


Index: jump-indexes.js
===================================================================
RCS file: /sources/public/html5/markup/js/jump-indexes.js,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- jump-indexes.js	6 Aug 2010 12:47:52 -0000	1.8
+++ jump-indexes.js	6 Aug 2010 23:33:27 -0000	1.9
@@ -63,39 +63,9 @@
             itemName = "Overview.html";
             if (window.location.hash) {
               var fragID = window.location.hash.substring(1,window.location.hash.length);
-              var elementName = "";
-              if (fragID.indexOf('-') != -1) {
-                elementName = fragID.substring(0,fragID.indexOf('-'));
-              } else if (fragID.indexOf('.attrs.') != -1) {
-                elementName = fragID.substring(0,fragID.indexOf('.attrs.'));
-              }
-              if (fragID == 'index') {
-                itemName = "index.html";
-              }
-              for (var i = 0; i < document.getElementById('appendices').childNodes.length; i++) {
-                if (document.getElementById('appendices').childNodes[i].nodeName == 'DIV') {
-                  if (document.getElementById('appendices').childNodes[i].id == fragID) {
-                    itemName = window.location.hash.substring(1,window.location.hash.length) + ".html";
-                  }
-                }
-              }
-              for (var i = 0; i < document.getElementById('this_sections').childNodes.length; i++) {
-                if (document.getElementById('this_sections').childNodes[i].nodeName == 'DIV') {
-                  if (document.getElementById('this_sections').childNodes[i].id == fragID) {
-                    itemName = window.location.hash.substring(1,window.location.hash.length) + ".html";
-                  }
-                }
-              }
-              for (var i = 0; i < document.getElementById('elements').childNodes.length; i++) {
-                if (document.getElementById('elements').childNodes[i].nodeName == 'DIV') {
-                  if (document.getElementById('elements').childNodes[i].id == fragID) {
-                    itemName = window.location.hash.substring(1,window.location.hash.length) + ".html";
-                  }
-                  if (elementName != "" && document.getElementById('elements').childNodes[i].id == elementName) {
-                    itemName = elementName + ".html" + window.location.hash;
-                  }
-                }
-              }
+              var elementName = document.evaluate("//*[@id = '" + fragID +"']/ancestor-or-self::div[contains(@class,'section')][count(ancestor::div[contains(@class,'section')])=0 and not(@id='elements')]|//*[@id = '" + fragID + "']/ancestor-or-self::div[contains(@class,'section')][child::h2[@class='element-head']]",
+                  document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.id;
+              itemName = elementName + ".html" + window.location.hash;
             }
             a.setAttribute("href", itemName);
             itemName = "multi";

Index: dfn.js
===================================================================
RCS file: /sources/public/html5/markup/js/dfn.js,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dfn.js	6 Aug 2010 12:47:52 -0000	1.6
+++ dfn.js	6 Aug 2010 23:33:27 -0000	1.7
@@ -51,10 +51,17 @@
     if (node) {
       var panel = document.createElement('div');
       panel.className = 'dfnPanel';
+      if (node.id) {
+        var permalinkP = document.createElement('p');
+        var permalinkA = document.createElement('a');
+        permalinkA.href = '#' + node.id;
+        permalinkA.textContent = '#' + node.id;
+        permalinkP.appendChild(permalinkA);
+        panel.appendChild(permalinkP);
+      }
       var p = document.createElement('p');
       panel.appendChild(p);
       if (node.id in dfnMap || node.parentNode.id in dfnMap) {
-        p.textContent = 'Referenced in:';
         var ul = document.createElement('ul');
         var lastHeader;
         var lastLi;

Received on Friday, 6 August 2010 23:33:32 UTC