2009/dap/ReSpec.js/js respec.js,1.139,1.140

Update of /sources/public/2009/dap/ReSpec.js/js
In directory hutz:/tmp/cvs-serv15308

Modified Files:
	respec.js 
Log Message:
add section reference handling


Index: respec.js
===================================================================
RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- respec.js	18 Oct 2010 22:06:49 -0000	1.139
+++ respec.js	31 Dec 2010 01:45:27 -0000	1.140
@@ -203,7 +203,9 @@
 
             // if (this.doMicroData) this.makeMicroData();
             if (this.doRDFa) this.makeRDFa();
-            if( this.practiceNum) this.doBestPractices(); // do not slow down those who do not need it , fjh
+            if( this.practiceNum) this.doBestPractices(); // do not
+            // slow down those who do not need it , fjh
+            this.makeSectionRefs(); // allow references to sections using name for text, fjh
            this.unHTML5();
             this.removeRespec();
 
@@ -1289,7 +1291,46 @@
             this.practiceNum++;
         }
     },
+    
+    //  <link href="section id" class="sectionRef" />
+
+//     returnObjById: function( id ) 
+//     { 
+//     if (document.getElementById) 
+//         var returnVar = document.getElementById(id); 
+//     else if (document.all) 
+//         var returnVar = document.all[id]; 
+//     else if (document.layers) 
+//         var returnVar = document.layers[id]; 
+//     return returnVar; 
+//     }, 
+
+    makeSectionRefs: function () {
+        var secrefs = document.querySelectorAll("a.sectionRef");
+        for (var i = 0; i < secrefs.length; i++) {
+            var secref = secrefs[i];
 
+            // get the link href and section title
+            var h = secref.getAttribute('href');
+            var id = h.substring(1);
+
+            var sec = document.getElementById(id);
+            var secno = "Not found"+ id;
+            
+            if(sec) {
+                var span = sec.firstElementChild;
+
+                if(span) {
+                    secno = span.textContent;
+                }
+            }
+
+            title = "section " + secno;
+
+            // create new a reference to section using section title
+            secref.innerHTML = title;
+        }
+    },
     
     // --- WEB IDL --------------------------------------------------------------------------------------------
     webIDL:    function () {

Received on Friday, 31 December 2010 01:45:31 UTC