User:DatRoot/Skins/Skin1.js

/* * Set up the elements for the skin */ addOnloadHook(function {    /*  addLinkElem        Adds a link element */    function addLinkElem(refElem, elem, text, href)    {        // If 'refElem' is a string, try to get the element with that id        if(typeof(refElem) == "string") refElem = document.getElementById(refElem);        // If 'elem' is a string, try to get the element with that id        if(typeof(elem) == "string")         {            var id = elem;            elem = document.getElementById(id);            if(!elem && href != null) {                elem = document.createElement("li");                elem.id = id;                elem.appendChild(document.createElement("a"));            }        }        // If we still dont have a refElem or an elem then return        if(!refElem || !elem) return;        // Add text and href to elem if provided        var anchorElem = elem.getElementsByTagName("a")[0];        if(text) anchorElem.innerHTML = text; if(href && href.length > 0) anchorElem.href = href; refElem.getElementsByTagName("ul")[0].appendChild(elem); }   /*  addLinkElems Adds a number of link elements */ function addLinkElems(refElem) {       // If 'refElem' is a string, try to get the element with that id        if(typeof(refElem) == "string") refElem = document.getElementById(refElem); if(!refElem) return; for(var i = 1; i < arguments.length; i++) addLinkElem(refElem, arguments[i]); }

/* addNewElem Adds a new element */ function addNewElem(parent, tagName, id, className, innerHTML) {       if(typeof(parent) == "string") parent = document.getElementById(parent); var newElem = document.createElement(tagName); newElem.id = id; newElem.className = className || ""; newElem.innerHTML = innerHTML || ""; parent.appendChild(newElem); return newElem; }

/* renameLinkElem Renames a link element */ function renameLinkElem(elem, text) {       if(typeof(elem) == "string") elem = document.getElementById(elem); if(!elem) return; elem.getElementsByTagName("a")[0].innerHTML = text; }   var contentElem = document.getElementById("content");

// Add div to firstHeading var firstHeading = document.getElementById("bodyContent"); while(firstHeading.tagName != "H1") firstHeading = firstHeading.previousSibling; firstHeading.innerHTML = ' ' + wgTitle + ' '; // Move logo contentElem.appendChild(document.getElementById("p-logo"));

// Create new element for article, talk page links var viewsElem = addNewElem("column-one", "div", "p-views", "portlet",       '  '); // Add article and edit links to new element addLinkElems(viewsElem, "ca-nstab-main", "ca-nstab-project", "ca-nstab-user",       "ca-nstab-special", "ca-nstab-template", "ca-nstab-image", "ca-nstab-help", "ca-talk"); // Add all page-related links to 'p-cations' var pageLinksElem = document.getElementById("p-cactions"); // 1st column addLinkElem(pageLinksElem, "ca-edit", "edit", ""); addLinkElem(pageLinksElem, "ca-viewsource"); addLinkElem(pageLinksElem, "ca-addsection", "new section", ""); addLinkElem(pageLinksElem, "ca-move", "move", ""); if(document.getElementById("ca-unwatch")) addLinkElem(pageLinksElem, "ca-unwatch", "unwatch"); else addLinkElem(pageLinksElem, "ca-watch", "watch", ""); // 2nd column addLinkElem(pageLinksElem, "ca-history", "history", ""); if(wgNamespaceNumber == 0) addLinkElem(pageLinksElem, "t-log", "logs", "/w/index.php?title=Special:Log&page=" + wgPageName); else addLinkElem(pageLinksElem, "t-log", "logs", ""); addLinkElem(pageLinksElem, "t-contributions", "user contribs", ""); addLinkElem(pageLinksElem, "t-recentchangeslinked", "related changes", ""); // 3rd column addLinkElem(pageLinksElem, "t-whatlinkshere", "what links here", ""); addLinkElem(pageLinksElem, "t-emailuser", "email user", ""); addLinkElem(pageLinksElem, "t-permalink", "permanent link", ""); addLinkElem(pageLinksElem, "t-print", "print version", ""); // 4th column addLinkElem(pageLinksElem, "t-cite", "cite this page", ""); // Add some links to toolbox var toolboxElem = document.getElementById("p-tb"); addLinkElem(toolboxElem, "n-recentchanges"); addLinkElem(toolboxElem, "n-randompage");

// Re-order portlets var columnOneElem = document.getElementById("column-one"); columnOneElem.insertBefore(document.getElementById("p-navigation"), columnOneElem.firstChild); columnOneElem.insertBefore(document.getElementById("p-search"), columnOneElem.firstChild); columnOneElem.insertBefore(toolboxElem, columnOneElem.firstChild); });