Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:Nattern/vector.js

< User:Nattern
Revision as of 15:50, 15 November 2023 by Nattern (talk | contribs) (Added variables for the different navigation menus. Added new section called "Custom" to the panel on the left side of the screen. Added a shortcut to open a template page called "Template" to the new "Custom" section.)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/////////////////////////////////////////////////////
var id = "Custom";
var nav = document.createElement("nav");
nav.id = "p-" + id;
nav.className = "vector-menu mw-portlet mw-portlet-" + id + " vector-menu-portal portal";
nav.setAttribute("aria-labelledby", "p-" + id + "-label");
nav.setAttribute("role", "navigation");

var h3 = document.createElement("h3");
h3.id = "p-" + id + "-label";
h3.className = "vector-menu-heading";

var span = document.createElement("span");
span.className = "vector-menu-heading-label";
span.textContent = id;

h3.appendChild(span);
nav.appendChild(h3);

var div = document.createElement("div");
div.className = "vector-menu-content";

var ul = document.createElement("ul");
ul.className = "vector-menu-content-list";

div.appendChild(ul);
nav.appendChild(div);
document.getElementById("mw-panel").appendChild(nav);
/////////////////////////////////////////////////////


































var contentLists = document.querySelectorAll('.vector-menu-content-list');
var pPersonal = contentLists[0];
var leftNavigation = contentLists[1];
var pVariants = contentLists[2];
var rightNavigation = contentLists[3];
var pCactions = contentLists[4];
var pNavigation = contentLists[5];
var pSpecial = contentLists[6];
var pTb = contentLists[7];
/////
var pCustom = contentLists[8];
/////


function createListItem(contentList, listItemName) {
	var li = document.createElement('li');
	var a = document.createElement('a');
	contentList.prepend(li);
	// li.id = "pt/t/ca-" + listItemName;
	li.appendChild(a);
	a.setAttribute('onclick', 'openPage()');
	a.innerText = listItemName;
	li.classList += "mw-list-item";
}

function openPage(pageType) {
	if (pageType == undefined) {
		pageType = " ";
	} else {
		pageType = " " + pageType + " ";
	}
		
    var pageName = prompt("Type" + pageType + "here:");
    if (pageName) {
        window.open("https://bg3.wiki/wiki/Template:" + pageName, '_blank');
    }
};

createListItem(pCustom, 'Template');