Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/** Dynamic Navigation Bars (experimental) ************************************* * * Description: See [[Wikipedia:xNavFrame]]. * Maintainers: UNMAINTAINED */// set up the words in your languagevarxNavigationBarHide='['+collapseCaption+']';varxNavigationBarShow='['+expandCaption+']';// shows and hides content and picture (if available) of navigation bars// Parameters:// indexNavigationBar: the index of navigation bar to be toggledfunctionxtoggleNavigationBar(indexNavigationBar){varxNavToggle=document.getElementById("xNavToggle"+indexNavigationBar);varxNavFrame=document.getElementById("xNavFrame"+indexNavigationBar);if(!xNavFrame||!xNavToggle){returnfalse;}// if shown nowif(xNavToggle.firstChild.data==xNavigationBarHide){for(varxNavChild=xNavFrame.firstChild;xNavChild!=null;xNavChild=xNavChild.nextSibling){if(hasClass(xNavChild,'xNavPic')){xNavChild.style.display='none';}if(hasClass(xNavChild,'xNavContent')){xNavChild.style.display='none';}}xNavToggle.firstChild.data=xNavigationBarShow;// if hidden now}elseif(xNavToggle.firstChild.data==xNavigationBarShow){for(varxNavChild=xNavFrame.firstChild;xNavChild!=null;xNavChild=xNavChild.nextSibling){if(hasClass(xNavChild,'xNavPic')){xNavChild.style.display='block';}if(hasClass(xNavChild,'xNavContent')){xNavChild.style.display='block';}}xNavToggle.firstChild.data=xNavigationBarHide;}}// adds show/hide-button to navigation barsfunctionxcreateNavigationBarToggleButton(){varindexNavigationBar=0;// iterate over all < div >-elements vardivs=document.getElementsByTagName("div");for(vari=0;xNavFrame=divs[i];i++){// if found a navigation barif(hasClass(xNavFrame,"xNavFrame")){indexNavigationBar++;varxNavToggle=document.createElement("a");xNavToggle.className='xNavToggle';xNavToggle.setAttribute('id','xNavToggle'+indexNavigationBar);xNavToggle.setAttribute('href','javascript:xtoggleNavigationBar('+indexNavigationBar+');');varisCollapsed=hasClass(xNavFrame,"collapsed");/* * Check if any children are already hidden. This loop is here for backwards compatibility: * the old way of making xNavFrames start out collapsed was to manually add style="display:none" * to all the xNavPic/xNavContent elements. Since this was bad for accessibility (no way to make * the content visible without JavaScript support), the new recommended way is to add the class * "collapsed" to the xNavFrame itself, just like with collapsible tables. */for(varxNavChild=xNavFrame.firstChild;xNavChild!=null;xNavChild=xNavChild.nextSibling){if(hasClass(xNavChild,'xNavPic')||hasClass(xNavChild,'xNavContent')){if(xNavChild.style.display=='none'){isCollapsed=true;break;}}}if(isCollapsed){for(varxNavChild=xNavFrame.firstChild;xNavChild!=null;xNavChild=xNavChild.nextSibling){if(hasClass(xNavChild,'xNavPic')||hasClass(xNavChild,'xNavContent')){xNavChild.style.display='none';}}}varxNavToggleText=document.createTextNode(isCollapsed?xNavigationBarShow:xNavigationBarHide);xNavToggle.appendChild(xNavToggleText);// Find the xNavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)for(varj=0;j<xNavFrame.childNodes.length;j++){if(hasClass(xNavFrame.childNodes[j],"xNavHead")){xNavFrame.childNodes[j].appendChild(xNavToggle);}}xNavFrame.setAttribute('id','xNavFrame'+indexNavigationBar);}}}addOnloadHook(xcreateNavigationBarToggleButton);