Jump to content

User:InvalidOS/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by InvalidOS (talk | contribs) at 14:50, 16 October 2019 (temporary?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// Replace sandbox item with dropdown, add a link to [[Special:RecentChanges]] to top menu

/*
Dropdown HTML:

<li class="pt-sand-drop"><div class="sandbox-dropdown">
  <button onclick="sandDropdown()" class="sandbox-dropdown-l">Sandboxes</button>
  <div id="mySandboxes" class="sandbox-dropdown-content">
    <a href="/wiki/User:InvalidOS/sandbox1" title="Sandbox 1">Sandbox 1</a>
	<a href="/wiki/User:InvalidOS/sandbox2" title="Sandbox 2">Sandbox 2</a>
	<a href="/wiki/User:InvalidOS/sandbox3" title="Sandbox 3">Sandbox 3</a>
  </div>
</div></li>

<li id="pt-recent", title="Special:RecentChanges">
	<a href="/wiki/Special:RecentChanges?damaging=likelybad%3Bverylikelybad&hidebots=1&hideWikibase=1&limit=50&days=7&urlversion=2">
		Recent Changes
	</a>
</li>

*/

if (document.getElementById('pt-sandbox'))
{
	var inner = '<li class="pt-sand-drop"><div class="sandbox-dropdown"><button onclick="sandDropdown()" class="sandbox-dropdown-l"><a href="#">Sandboxes</a></button><div id="mySandboxes" class="sandbox-dropdown-content"><a href="/wiki/User:InvalidOS/sandbox1" title="Sandbox 1">Sandbox 1</a><a href="/wiki/User:InvalidOS/sandbox2" title="Sandbox 2">Sandbox 2</a><a href="/wiki/User:InvalidOS/sandbox3" title="Sandbox 3">Sandbox 3</a></div></div></li>';
	var append = '<li id="pt-recent", title="Special:RecentChanges"><a href="/wiki/Special:RecentChanges?damaging=likelybad%3Bverylikelybad&hidebots=1&hideWikibase=1&limit=50&days=7&urlversion=2">Recent Changes</a></li>';
	var el = document.getElementById('pt-sandbox');
	el.innerHTML = inner;
	el.insertAdjacentHTML("afterend",append);
}

// Opens dropdown
function sandDropdown() {
  document.getElementById("mySandboxes").classList.toggle("show");
}

// Closes dropdown
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {
    var dropdowns = document.getElementsByClassName("sandbox-dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('sand-show')) {
        openDropdown.classList.remove('sand-show');
      }
    }
  }
};