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.
//<nowiki>// By Sideswipe9th// Last edit date: 4 March 2023// Known bugs:// - On pages with a ToC, scrolling the main content area will cause the stick panel to jump to whatever// the "focused" header is, if you've scrolled down to access the toolsbar it will jump back up// - If the Main Menu is hidden, the CSS for this breaks. I think I just need to add another check to make sure// The parent containers exist when the menu is hidden, and if not create empty ones// Change log:// - 4 March 2023// * Fix the tools menu not being appended on TOC-less pages after the previously always present nav I was relying on was removed// - 18 February 2023// * Initial release$(function(){// does the document contain a vector-toc-pinned-container? This should be null if the page has no ToC//var container = document.getElementById("vector-toc-pinned-container");// does the document contain an element with the classes "vector-main-menu-container vector-sidebar-container-no-toc"varnoToCContainer=document.getElementsByClassName("vector-main-menu-container vector-sidebar-container-no-toc");if(noToCContainer!=null&&noToCContainer.length>0){// it does, so we're on a ToCless // get the element with the id vector-main-menu, cause we're going to check its parentvarvectorMainMenu=document.getElementById("vector-main-menu");// do a null check, in theory this should always exist but you never knowif(vectorMainMenu!=null){// is the parent of vectorMainMenu the pinned container?// disabled for now, can't figure out how to detect when the menu is closed and force it open again/*if (vectorMainMenu.parentNode.id != "vector-main-menu-pinned-container") { // it is not, so lets reparent it var mainMenuPinned = document.getElementById("vector-main-menu-pinned-container"); mainMenuPinned.appendChild(vectorMainMenu); }*/// now that the main menu is forced on, we can start to create our new heirarchy varnav=document.getElementById("mw-panel-toc");// grab the parent navbar that's used to always be present// check if mw-panel-toc is presentif(nav==null){// it's not, ugh. Ok, get the elements with the class name mw-page-container-innervarpageContainer=document.getElementsByClassName("mw-page-container-inner");if(pageContainer.length>0){// create the nav that should be present but isn'tnav=document.createElement("NAV");// assign it the right ID, classes, and arialabelnav.id="mw-panel-toc";nav.className="mw-table-of-contents-container vector-toc-landmark";nav.arialabel="Contents";// append this nav as a child to the right page containerpageContainer[0].appendChild(nav);}}varnewContainer=document.createElement("div");// create a new divnewContainer.id="vector-toc-pinned-container";// give it the right idnewContainer.className="vector-pinned-container";// give it some classnav.appendChild(newContainer);// and append it to the navbarvartoolsBar=document.getElementById("vector-page-tools");// then grab the tools bar by IDtoolsBar.disabled=true;// because enabling the tools bar will break this, we want to force it to disablednewContainer.appendChild(toolsBar);// and finally append the tools bar to the floating ToC}}else{// it does not, so we're on a page that has a ToC. This code is simpler, as we just want to append the tools bar// to the end of vector-tocvartoolsBar=document.getElementById("vector-page-tools");// first grab the tools bar by IDvarfloatingToC=document.getElementById("vector-toc");// then grab the floating TOC by IDfloatingToC.appendChild(toolsBar);// and finally append the tools bar to the floating ToC}});//</nowiki>