Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:37

0001 document.addEventListener("DOMContentLoaded", function() {
0002     // Code
0003     // select local TOC
0004     var menu = q(".sectionTOCS")[0];
0005     var menuopened = "^^^";
0006     var m = createEl("a","menu","");
0007     var toolbar = createEl("div","toolbar");
0008     var sidebar = createEl("div","sidebar","");
0009     var crosslinks = q(".crosslinks")[0];
0010     var setText = function(node,a){
0011       var text = document.createTextNode(a);
0012       node.removeChild(node.childNodes[0]);
0013       node.appendChild(text);
0014     }
0015     // pass reference to new container and crosslinks
0016     var transfromCrosslinks = function(newcrosslinks,el){
0017       // find all crosslinks 
0018       var links = el.querySelectorAll("a");
0019       var newcrs = {}
0020      // make table with link text as name
0021      for(i=0;i!=links.length;i++){
0022           var text = links[i].firstChild.nodeValue;
0023           newcrs[text] = links[i];
0024       }
0025       // select next, prev and up nodes and replace text with unicode arrows
0026       // is a node doesn't exist, create span with blanklink class
0027       var next = newcrs["next"] || createEl("span","blanklink",">")
0028       setText(next,"⇨");
0029       var prev = newcrs["prev"]|| createEl("span","blanklink",">")
0030       setText(prev,"⇦");
0031       setText(newcrs["up"],"⇧");
0032       // add crosslinks to a toolbar
0033       newcrosslinks.appendChild(prev);
0034       newcrosslinks.appendChild(newcrs["up"]);
0035       newcrosslinks.appendChild(next);
0036       crosslinks.remove();
0037       return newcrosslinks;
0038     }
0039     // add elements to the sidebar depending on existence of a local TOC and 
0040     // crosslinks
0041     if(crosslinks){
0042       transfromCrosslinks(toolbar,crosslinks);
0043       // add sidebat only if it doesn't exist already
0044       if(!menu) sidebar.appendChild(toolbar);
0045       //m.appendChild(newcrosslinks);
0046     }
0047     if(menu) { 
0048       toolbar.appendChild(m);
0049       sidebar.appendChild(toolbar);
0050       sidebar.appendChild(menu);
0051     }
0052     q("body")[0].appendChild(sidebar);
0053     
0054  }, false);