User:David Condrey/common.js

This is an old revision of this page, as edited by David Condrey (talk | contribs) at 02:39, 19 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 ptLinksToAdd = [
        {
                label: "New pages",
                title: "Feed of recently created pages",
                url: "/wiki/Special:NewPagesFeed",
                index: 5
        },
		{
        		label: "AFI",
        		url: "/wiki/Wikipedia:Today%27s_articles_for_improvement",
        		index: 6
        },
        {
                label: "AFC",
                url: "/wiki/Wikipedia:Articles_for_creation",
                index: 7
        },
        {
        		label: "CompSci",
        		url: "/wiki/Wikipedia:WikiProject_Computer_science",
        		index: 8
        }
 ];
 
var ptList = document.getElementById("p-personal").getElementsByTagName("ul")[0];
 
for (var i = 0; i < ptLinksToAdd.length; i++) {
	var newListItem = document.createElement("li");
	var newLink = document.createElement("a");
	newLink.setAttribute("href", ptLinksToAdd[i].url);
	if (ptLinksToAdd[i].hasOwnProperty("title")) {
		newLink.setAttribute("title", ptLinksToAdd[i].title);
	}
	newLink.appendChild(document.createTextNode(ptLinksToAdd[i].label));
	newListItem.appendChild(newLink);
 
	if (ptLinksToAdd[i].hasOwnProperty("index")) {
		ptList.insertBefore(newListItem, ptList.childNodes[ptLinksToAdd[i].index]);
	} else {
		ptList.appendChild(newListItem);
	}
}