User:Bawolff/onebox-select.js

//This scrit makes it so you can only have one dynamic nav box open at a time //To use: /* //Insert user:Bawolff/onebox.js - only allow one box open at a time var url = "http://en.wikinews.org/w/index.php?title=user:Bawolff/onebox-select.js&action=raw&ctype=text/javascript&dontcountme=s"; var scriptElem = document.createElement( 'script' ); scriptElem.setAttribute( 'src', url ); scriptElem.setAttribute( 'type', 'text/javascript' ); document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
 * Add only the part directly below to your special:mypage/monobook.js (or whatever skin you use):

-
 * Do not add the part under this line:

// ============================================================ // BEGIN Dynamic Navigation Bars (experimental)

// set up the words in your language var LOCAL_NavigationBarHide = '[ you suck! ]'; var LOCAL_NavigationBarShow = '[ Give Me More! ]';

// set up max count of Navigation Bars on page, // if there are more, all will be hidden // NavigationBarShowDefault = 0; // all bars will be hidden // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden var LOCAL_NavigationBarShowDefault = 1;

// shows and hides content and picture (if available) of navigation bars // Parameters: //    indexNavigationBar: the index of navigation bar to be toggled function LOCAL_toggleNavigationBar(LOCAL_indexNavigationBar) {  var LOCAL_NavToggle = document.getElementById("NavToggleOnce" + LOCAL_indexNavigationBar); var LOCAL_NavFrame = document.getElementById("NavFrameOnce" + LOCAL_indexNavigationBar);

if (!LOCAL_NavFrame || !LOCAL_NavToggle) { return false; }

// if shown now if (LOCAL_NavToggle.firstChild.data == LOCAL_NavigationBarHide) { for (              var LOCAL_NavChild = LOCAL_NavFrame.firstChild;               LOCAL_NavChild != null;               LOCAL_NavChild = LOCAL_NavChild.nextSibling           ) { if (LOCAL_NavChild.className == 'NavPic') { LOCAL_NavChild.style.display = 'none'; }          if (LOCAL_NavChild.className == 'NavContent') { LOCAL_NavChild.style.display = 'none'; }      }   LOCAL_NavToggle.firstChild.data = LOCAL_NavigationBarShow;

// if hidden now } else if (LOCAL_NavToggle.firstChild.data == LOCAL_NavigationBarShow) { //Start hiding all open boxes. things with f is loops to close everything for (              f = 1;               f < 50; //prevent indef loop               f++            )  { var LOCAL_f_NavToggle = document.getElementById("NavToggleOnce" + f); var LOCAL_f_NavFrame = document.getElementById("NavFrameOnce" + f);

if (!LOCAL_f_NavFrame || !LOCAL_f_NavToggle) { break; }                 for (                     var LOCAL_f_NavChild = LOCAL_f_NavFrame.firstChild;                     LOCAL_f_NavChild != null;                     LOCAL_f_NavChild = LOCAL_f_NavChild.nextSibling                      ) { if (LOCAL_f_NavChild.className == 'NavPic') { LOCAL_f_NavChild.style.display = 'none'; }                          if (LOCAL_f_NavChild.className == 'NavContent') { LOCAL_f_NavChild.style.display = 'none'; }                       }                 LOCAL_f_NavToggle.firstChild.data = LOCAL_NavigationBarShow; }

//open selected one

for (              var LOCAL_NavChild = LOCAL_NavFrame.firstChild;               LOCAL_NavChild != null;               LOCAL_NavChild = LOCAL_NavChild.nextSibling           ) { if (LOCAL_NavChild.className == 'NavPic') { LOCAL_NavChild.style.display = 'block'; }          if (LOCAL_NavChild.className == 'NavContent') { LOCAL_NavChild.style.display = 'block'; }      }   LOCAL_NavToggle.firstChild.data = LOCAL_NavigationBarHide; } }

// adds show/hide-button to navigation bars function LOCAL_createNavigationBarToggleButton {  var LOCAL_indexNavigationBar = 0; // iterate over all -elements for(          var i=0;            LOCAL_NavFrame = document.getElementsByTagName("div")[i];            i++       ) { // if found a navigation bar if (LOCAL_NavFrame.className == "NavFrame NavOnce") {

LOCAL_indexNavigationBar++; var LOCAL_NavToggle = document.createElement("a"); LOCAL_NavToggle.className = 'NavToggle'; LOCAL_NavToggle.setAttribute('id', 'NavToggleOnce' + LOCAL_indexNavigationBar); LOCAL_NavToggle.setAttribute('href', 'javascript:LOCAL_toggleNavigationBar(' + LOCAL_indexNavigationBar + ');'); var LOCAL_NavToggleText = document.createTextNode(LOCAL_NavigationBarHide); LOCAL_NavToggle.appendChild(LOCAL_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 < LOCAL_NavFrame.childNodes.length;              j++           ) { if (LOCAL_NavFrame.childNodes[j].className == "NavHead") { LOCAL_NavFrame.childNodes[j].appendChild(LOCAL_NavToggle); }          }           LOCAL_NavFrame.setAttribute('id', 'NavFrameOnce' + LOCAL_indexNavigationBar); }  }   // if more Navigation Bars found than Default: hide all if (LOCAL_NavigationBarShowDefault < LOCAL_indexNavigationBar) { for(              var i=1;                i<=LOCAL_indexNavigationBar;                i++       ) { LOCAL_toggleNavigationBar(i); }  }

}

addLoadEvent(LOCAL_createNavigationBarToggleButton);

// comment stuff : http://en.wikinews.org/w/index.php?title=User:Bawolff/monobook.js&oldid=403650 //