User:David Condrey/common.js

This is an old revision of this page, as edited by David Condrey (talk | contribs) at 11:04, 27 July 2014. 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.
var new_NavTop = [
		{
        		label: "AFI",
        		url: "/wiki/Wikipedia:Today%27s_articles_for_improvement",
        		index: 6
        },
        {
                label: "AFC",
                url: "/wiki/Special:RandomInCategory/Pending_AfC_submissions",
                index: 7
        },
        {
                label: "New pages",
                title: "Feed of recently created pages",
                url: "/wiki/Special:NewPagesFeed",
                index: 5
        },
        {
        		label: "Categories",
        		url: "/wiki/Wikipedia:Reference_desk",
        		index: 8
        }
 ];

var new_NavSide = [
        {
        		label: "Policy",
        		url: "/wiki/Wikipedia:List_of_policies",
        },
        {
        		label: "Guidelines",
        		url: "/wiki/Wikipedia:List_of_guidelines",
        }
];
 
var NavTop = document.getElementById("p-personal").getElementsByTagName("ul")[0];

for (var i = 0; i < new_NavTop.length; i++) {
	var newListItem = document.createElement("li");
	var newLink = document.createElement("a");
	newLink.setAttribute("href", new_NavTop[i].url);
	if (new_NavTop[i].hasOwnProperty("title")) {
		newLink.setAttribute("title", new_NavTop[i].title);
	}
	newLink.appendChild(document.createTextNode(new_NavTop[i].label));
	newListItem.appendChild(newLink);
 
	if (new_NavTop[i].hasOwnProperty("index")) {
		NavTop.insertBefore(newListItem, NavTop.childNodes[new_NavTop[i].index]);
	} else {
		NavTop.appendChild(newListItem);
	}
}

var leftNav = document.getElementById("p-interaction").getElementsByTagName("ul")[0];

for (var i = 0; i < new_NavSide.length; i++) {
	var newListItem = document.createElement("li");
	var newLink = document.createElement("a");
	newLink.setAttribute("href", new_NavSide[i].url);
	if (new_NavSide[i].hasOwnProperty("title")) {
		newLink.setAttribute("title", new_NavSide[i].title);
	}
	newLink.appendChild(document.createTextNode(new_NavSide[i].label));
	newListItem.appendChild(newLink);
 
	if (new_NavSide[i].hasOwnProperty("index")) {
		NavSide.insertBefore(newListItem, NavSide.childNodes[new_NavSide[i].index]);
	} else {
		NavSide.appendChild(newListItem);
	}
}