Misplaced Pages

User:CesarB/monobook.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:CesarB Browse history interactively← Previous editContent deleted Content added
Revision as of 16:49, 2 September 2006 view sourceCesarB (talk | contribs)Administrators14,429 edits bug fix← Previous edit Latest revision as of 16:51, 2 September 2006 view source CesarB (talk | contribs)Administrators14,429 edits experiment finished 
Line 1: Line 1:
/*<pre><nowiki>*/

// Undo addLoadEvent(createNavigationBarToggleButton);

window.removeEventListener("load", createNavigationBarToggleButton, false);

// Replace function
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
var countDefaultNavigationBar = 0;
var NavFrame;
// iterate over all < div >-elements
for(
var i=0;
NavFrame = document.getElementsByTagName("div");
i++
) {
// if found a navigation bar
if (NavFrame.className == "NavFrame" || NavFrame.className == "NavFrameDefaultShow" || NavFrame.className == "NavFrameDefaultHide") {
indexNavigationBar++;
if (NavFrame.className == "NavFrame")
countDefaultNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for(
var j=0;
j < NavFrame.childNodes.length;
j++
) {
if (NavFrame.childNodes.className == "NavHead") {
NavFrame.childNodes.appendChild(NavToggle);
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
if (NavFrame.className == "NavFrameDefaultHide")
toggleNavigationBar(indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < countDefaultNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
if (document.getElementById("NavFrame" + i).className == "NavFrame")
toggleNavigationBar(i);
}
}
// change all class names to NavFrame
for(
var i=1;
i<=indexNavigationBar;
i++
) {
document.getElementById("NavFrame" + i).className = "NavFrame"
}
}

// Redo addLoadEvent(createNavigationBarToggleButton);
addLoadEvent(createNavigationBarToggleButton);

/*</nowiki></pre>*/

Latest revision as of 16:51, 2 September 2006