User:Nattern/vector.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(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.)
(New Condition Pages button in Custom)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
/////////////////////////////////////////////////////
var mwPanel = document.getElementById('mw-panel');
var id = "Custom";
var leftNavigation = document.getElementById('left-navigation');
var nav = document.createElement("nav");
var rightNavigation = document.getElementById('right-navigation');
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);
/////////////////////////////////////////////////////
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 






function newMwPanelPortlet(id) {
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);
mwPanel.appendChild(nav);
}
newMwPanelPortlet("Custom");




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




function createListItem(contentList, listItemName) {
 
function createListItem(end, contentList, listItemName, onClick, title, accessKey) {
var li = document.createElement('li');
var li = document.createElement('li');
var a = document.createElement('a');
var a = document.createElement('a');
contentList.prepend(li);
var span = document.createElement('span');
if (end == "p" || end == "pre") {contentList.prepend(li);}
else if (Number.isInteger(end)) {contentList.insertBefore(li, contentList.children[end-1]);}
else {contentList.append(li);}
// li.id = "pt/t/ca-" + listItemName;
// li.id = "pt/t/ca-" + listItemName;
li.appendChild(a);
li.appendChild(a);
a.setAttribute('onclick', 'openPage()');
if (onClick.includes('/')){
a.innerText = listItemName;
a.href = onClick;
li.classList += "mw-list-item";
}
a.setAttribute('onclick', onClick);
if (title) {a.title = title;}
if (accessKey) {a.accessKey = accessKey;}
a.appendChild(span);
span.innerText = listItemName;
li.classList.add("mw-list-item");
}
}


function openPage(pageType) {
function openPage(pageType) {
Line 96: Line 82:
     var pageName = prompt("Type" + pageType + "here:");
     var pageName = prompt("Type" + pageType + "here:");
     if (pageName) {
     if (pageName) {
         window.open("https://bg3.wiki/wiki/Template:" + pageName, '_blank');
         window.open('https://bg3.wiki/wiki/'+ pageType + ':' + pageName, '_blank');
     }
     }
};
}
 
createListItem("a", pViews, "Image Search", "/w/index.php?title=Special:Search&profile=images&search=&fulltext=1", "Open wiki search page on Multimedia");
 
createListItem(4, pPersonal, "JS", "https://bg3.wiki/wiki/User:Nattern/vector.js", "User:Nattern/vector.js");
createListItem(5, pPersonal, "CSS", "https://bg3.wiki/wiki/User:Nattern/vector.css", "User:Nattern/vector.css");


createListItem(pCustom, 'Template');
createListItem("a", pCustom, "Templates", "/wiki/Category:Templates", "List of templates");
createListItem("a", pCustom, "Categories", "/wiki/Special:Categories", "List of categories");
createListItem("a", pCustom, "Wiki Maintenance", "/wiki/Category:Wiki_Maintenance", "Wiki maintenance pages");
createListItem("a", pCustom, "All Pages", "/wiki/Special:AllPages", "A list of all pages on the wiki");
createListItem("a", pCustom, "Export", "/wiki/Special:Export", "Export pages as xml");
createListItem("a", pCustom, "New Condition Pages", "/wiki/Special:RecentChangesLinked?hidepageedits=1&hidelog=1&target=Template%3ACondition+page&showlinkedto=1&limit=500&days=30&enhanced=1&urlversion=2", "New pages using the Condition page template");

Latest revision as of 09:04, 9 February 2024

var mwPanel = document.getElementById('mw-panel');
var leftNavigation = document.getElementById('left-navigation');
var rightNavigation = document.getElementById('right-navigation');



function newMwPanelPortlet(id) {
	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);
	mwPanel.appendChild(nav);
}
newMwPanelPortlet("Custom");



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

var pCustom = contentLists[8];



function createListItem(end, contentList, listItemName, onClick, title, accessKey) {
	var li = document.createElement('li');
	var a = document.createElement('a');
	var span = document.createElement('span');
	if (end == "p" || end == "pre") {contentList.prepend(li);}
	else if (Number.isInteger(end)) {contentList.insertBefore(li, contentList.children[end-1]);}
	else {contentList.append(li);}
	// li.id = "pt/t/ca-" + listItemName;
	li.appendChild(a);
	if (onClick.includes('/')){
		a.href = onClick;
	}
	a.setAttribute('onclick', onClick);
	if (title) {a.title = title;}
	if (accessKey) {a.accessKey = accessKey;}
	a.appendChild(span);
	span.innerText = listItemName;
	li.classList.add("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/'+ pageType + ':' + pageName, '_blank');
    }
}

createListItem("a", pViews, "Image Search", "/w/index.php?title=Special:Search&profile=images&search=&fulltext=1", "Open wiki search page on Multimedia");

createListItem(4, pPersonal, "JS", "https://bg3.wiki/wiki/User:Nattern/vector.js", "User:Nattern/vector.js");
createListItem(5, pPersonal, "CSS", "https://bg3.wiki/wiki/User:Nattern/vector.css", "User:Nattern/vector.css");

createListItem("a", pCustom, "Templates", "/wiki/Category:Templates", "List of templates");
createListItem("a", pCustom, "Categories", "/wiki/Special:Categories", "List of categories");
createListItem("a", pCustom, "Wiki Maintenance", "/wiki/Category:Wiki_Maintenance", "Wiki maintenance pages");
createListItem("a", pCustom, "All Pages", "/wiki/Special:AllPages", "A list of all pages on the wiki");
createListItem("a", pCustom, "Export", "/wiki/Special:Export", "Export pages as xml");
createListItem("a", pCustom, "New Condition Pages", "/wiki/Special:RecentChangesLinked?hidepageedits=1&hidelog=1&target=Template%3ACondition+page&showlinkedto=1&limit=500&days=30&enhanced=1&urlversion=2", "New pages using the Condition page template");