User:Ale jrb/Scripts/myinterface.js

if (enableRemoveInterface == null) { var enableRemoveInterface = false; } function myInterface { // Define settings and variables var root = 'http://en.wikipedia.org'; if (typeof linkArray == 'undefined') var linkArray = new Array(		/* id, text, href */		['n-csdlink', root+'/w/index.php?title=Category:Candidates_for_speedy_deletion&action=purge#Pages_in_category', 'CSD'],		['n-aivlink', root+'/wiki/WP:AIV', 'AIV'],		['n-noticeboard', root+'/wiki/WP:AN', 'Admin\'s noticeboard'],		['n-csdguide', root+'/wiki/WP:CSD', 'CSD Guidlines']		/*[, , ],		[, , ],		[, , ],		[, , ],		[, , ''],*/

);	// Handle removal of unwanted links from interface.	if (typeof removeFromInterface == 'undefined') { 		var removeFromInterface = new Array('n-contents', 'n-featuredcontent', 'n-currentevents', 'n-aboutsite', 'p-interaction');	}	if (enableRemoveInterface == true) {		for (var i = 0; i < removeFromInterface.length; i ++) {			document.getElementById(removeFromInterface[i]).parentNode.removeChild(document.getElementById(removeFromInterface[i]));		}	}	// Handle addition of new links to interface.	var par = document.getElementById('n-randompage').parentNode;	var linkHold = document.createElement('li');	linkHold.id = 'n-recentchanges';	var link = document.createElement('a');	link.setAttribute('href', root + '/wiki/Special:Recentchanges');	link.appendChild(document.createTextNode('Recent changes'));	linkHold.appendChild(link);	par.appendChild(linkHold);	// Create new portlet, and add links to it. var portlet = document.createElement('div'); portlet.setAttribute('id', 'p-mylinks-test'); portlet.className = 'generated-sidebar portlet'; //setAttribute('class', 'generated-sidebar portlet'); var portletHeader = document.createElement('h5'); var portletHeaderContent = document.createTextNode('my links'); portletHeader .appendChild(portletHeaderContent ); portlet.appendChild(portletHeader);

var portletContent = document.createElement('div'); portletContent.className = 'pBody'; //setAttribute('class', 'pBody'); portlet.appendChild(portletContent);

var portletListT = document.createElement('ul'); portletContent.appendChild(portletListT);

for (var i = 0; i < linkArray.length; i ++) { var portletListItemT = document.createElement('li'); portletListItemT.setAttribute('id', linkArray[i][0]); portletListT.appendChild(portletListItemT);

var portletLink = document.createElement('a'); portletLink.setAttribute('href', linkArray[i][1]); portletListItemT.appendChild(portletLink);

var portletLinkText = document.createTextNode(linkArray[i][2]); portletLink.appendChild(portletLinkText); }	document.getElementById('p-search').parentNode.insertBefore(portlet, document.getElementById('p-search')); } hookEvent('load', myInterface);