User:Baumanns/monobook.js

// // shows the references tags contents when a reference link is clicked // and hides it when a backlink is clicked // function referencesOnDemand { /** finds the references tag which sadly has no id */ function findReferences { var ols = document.getElementsByTagName("ol"); for (var i=0; i<ols.length; i++) { var ol = ols[i]; if (ol.className = "references")   return ol; }       return null; }   /** show the references tag */ function showReferences { references.style.display   = null; return true; }   /** hide the references tag */ function hideReferences { references.style.display   = "none"; return true; }   var references  = findReferences; if (!references)   return;

// patch reference links to show the references tag var sups = document.getElementsByTagName("sup"); for (var i=0; i<sups.length; i++) { var sup = sups[i]; if (sup.className != "reference")  continue; var a  = sup.firstChild; a.onclick = showReferences; }   // patch reference backlinks to hide the references tag var lis = references.getElementsByTagName("li"); for (var i=0; i<lis.length; i++) { var li = lis[i]; var a  = li.firstChild.firstChild; a.onclick  = hideReferences; }

// initially hide references tag hideReferences; } aOnloadFunctions[aOnloadFunctions.length] = referencesOnDemand;