1,935
editsAd placeholder
User:Nattern/vector.js: Difference between revisions
Jump to navigation
Jump to search
Changed some variable names. added mwPanel, leftNavigation and rightNavigation variables. Added acessKey support for createListItem(). Added link to templates,
(newSidebarNavigation is now a function. Removed "Template" from "Custom" Sidebar navigation. Appended "Image Search" to right navigation. Inserted "JS" and "CSS" links to p-personal after "Preferences") |
(Changed some variable names. added mwPanel, leftNavigation and rightNavigation variables. Added acessKey support for createListItem(). Added link to templates,) |
||
Line 1: | Line 1: | ||
function | 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"); | var nav = document.createElement("nav"); | ||
nav.id = "p-" + id; | nav.id = "p-" + id; | ||
Line 25: | Line 31: | ||
div.appendChild(ul); | div.appendChild(ul); | ||
nav.appendChild(div); | nav.appendChild(div); | ||
mwPanel.appendChild(nav); | |||
} | } | ||
newMwPanelPortlet("Custom"); | |||
Line 63: | 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 | var pNamespaces = contentLists[1]; | ||
var pVariants = contentLists[2]; | var pVariants = contentLists[2]; | ||
var | var pViews = contentLists[3]; | ||
var pCactions = contentLists[4]; | var pCactions = contentLists[4]; | ||
var pNavigation = contentLists[5]; | var pNavigation = contentLists[5]; | ||
Line 75: | Line 51: | ||
function createListItem(end, contentList, listItemName, onClick, title) { | function createListItem(end, contentList, listItemName, onClick, title, acessKey) { | ||
var li = document.createElement('li'); | var li = document.createElement('li'); | ||
var a = document.createElement('a'); | var a = document.createElement('a'); | ||
var span = document.createElement('span'); | var span = document.createElement('span'); | ||
if (end == " | if (end == "p" || end == "pre") {contentList.prepend(li);} | ||
else if (Number.isInteger(end)) {contentList.insertBefore(li, contentList.children[end-1]);} | else if (Number.isInteger(end)) {contentList.insertBefore(li, contentList.children[end-1]);} | ||
else {contentList.append(li);} | else {contentList.append(li);} | ||
Line 89: | Line 65: | ||
a.setAttribute('onclick', onClick); | a.setAttribute('onclick', onClick); | ||
if (title) {a.title = title;} | if (title) {a.title = title;} | ||
if (acessKey) {a.acessKey;} | |||
a.appendChild(span); | a.appendChild(span); | ||
span.innerText = listItemName; | span.innerText = listItemName; | ||
li.classList.add("mw-list-item"); | li.classList.add("mw-list-item"); | ||
} | } | ||
function openPage(pageType) { | function openPage(pageType) { | ||
Line 107: | Line 86: | ||
} | } | ||
createListItem(" | 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(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(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 [alt-shift-t]", "w"); |