User:Voizzzz/vector.js

var panelStatus; var mwPanel = document.getElementById("mw-panel"); var mwBody = document.getElementsByClassName("mw-body")[0]; var mwHead = document.getElementById("mw-head"); var mwHeadBase = document.getElementById("mw-head-base"); var leftNavigation = document.getElementById("left-navigation"); var readMoreContainer = document.getElementsByClassName("read-more-container")[0];

createToggleButton; initPanelStatus;

function createToggleButton { var button = document.createElement("button"); document. getElementsByTagName("body")[0].appendChild(button); button.innerHTML = "-"; button.id = "toggleSidebarButton"; button.addEventListener ("click", togglePanels); }

function initPanelStatus { if (localStorage.panelStatus === undefined || localStorage.panelStatus === null) { console.log("undefined"); localStorage.panelStatus = "hidden"; }

localStorage.panelStatus == "shown" ? showPanels : hidePanels; }

function togglePanels { localStorage.panelStatus == "shown" ? hidePanels : showPanels; }

function hidePanels { // Top panel mwHead.style.display = "none"; mwHeadBase.style.height = "1em"; mwBody.style.borderTop = "none"; // Sidebar mwPanel.style.display = "none"; mwBody.style.width = "66%"; mwBody.style.marginLeft = "0"; mwBody.style.margin = "0 auto"; readMoreContainer.style.margin = "0 0 0 20em"; readMoreContainer.style.width = "66%";

localStorage.panelStatus = "hidden"; } function showPanels { // Top panel mwHead.style.display = "inherit"; mwHead.style.width = "100%"; mwHead.style.margin = "0 0 0 0"; mwHead.style.right = "5em"; leftNavigation.style.marginLeft = "20em"; mwHeadBase.style.height = "5em"; mwBody.style.borderTop = "1px solid #ccc"; // Sidebar mwPanel.style.display = "inherit"; mwBody.style.width = "82%"; mwBody.style.marginLeft = "15em"; mwBody.style.margin = "-1px 0 0 15em"; readMoreContainer.style.margin = "0 0 0 15em"; readMoreContainer.style.width = "82%"; localStorage.panelStatus = "shown"; }