User:Vildricianus/universal.js

//

// functions

// addTab function function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); }

// add LI link function function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) {       if(key && title) {           ta[id] = [key, title]; }       else if(key) {           ta[id] = [key, '']; }       else if(title) {           ta[id] = ['', title]; }   }    // re-render the title and accesskeys from existing code in wikibits.js    akeytt; return li; }

// addLink function function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". //   //* url is the URL which will be called when the button is clicked. //  javascript: urls can be used to do more complex things. //   //* name is what will appear as the name of the button. //   //* id is the id of the button; it's best to define one. //  Use a prefix to make sure its unique. Optional. //   //* title is the tooltip title that gives a longer description //  of the button; if you define a accesskey, mention it here. Optional. //   //* key is the char you want for the accesskey. Optional. //   //* after is the id of the button you want to follow this one. Optional. //   var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { tabs.appendChild(li); }   if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title];} }   // re-render the title and accesskeys from existing code in wikibits.js    akeytt; return li; }

// signature button inserts ~ instead of --~ (function {    var oldAddButton = addButton;    if (typeof(oldAddButton) != 'function') return;    addButton = function  {        if (arguments.length > 2)            arguments[2] = arguments[2].replace(/^--~$/, '~');        oldAddButton.apply(this, arguments);    }; });

// VIEW SOURCE tab next to edit tab $(function {  if (location.href.indexOf('viewsource=1') != -1) {    sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl);    ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed);    return;  }  editbutton = document.getElementById('ca-edit');  if (editbutton && location.href.indexOf('action=edit')==-1) {    editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';    tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];    na = document.createElement('a');    na.href = editlink; na.appendChild(document.createTextNode('src'));    li = document.createElement('li'); li.id = 'ca-source'; li.appendChild(na);    tabs.insertBefore(li,editbutton);  } });

// add purge tab $( function {   var x = document.getElementById('ca-history');    if(!x) return;    if(x.children) x = x.children[0].href;    else x = x.childNodes[0].href;    addLink("p-cactions", x.replace(/=history/, "=purge"), 'pu', 'ca-purge', 'Purge the internal cache for this page', 0); });

// add raw text tab $( function {   var x = document.getElementById('ca-history');    if(!x) return;    if(x.children) x = x.children[0].href;    else x = x.childNodes[0].href;    addLink("p-cactions", x.replace(/=history/, "=raw"), 'raw', 'ca-raw', 'Raw text for this page', 0); });

// add last diff tab $(function {    z=document.getElementById("content").childNodes;    for (var n=0;n<z.length;n++) {       if (z[n].className=="firstHeading") {        var pname=z[n].textContent;      }    }    var l=addTab("/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'last', '');    l.lastChild.title="Show most recent diff"; });

// EDIT SECTION 0 function addEditSection0 { if (!document.getElementById) return; x = document.getElementById('ca-edit'); if(!x) return; y = document.createElement('LI'); y.id = 'ca-edit-0'; if (x.className=='selected') { if (/&action=edit&section=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected'; } else { x.className = 'selected istalk'; } } else if (x.className=='selected istalk') { if (/&action=edit&section=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; } } else { y.className = x.className; x.className = 'istalk'; } z = document.createElement('A'); if (x.children) { z.href = x.children[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling); } else { z.href = x.childNodes[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling); } }

if (document.title.indexOf("Editing ")==-1) { addOnloadHook(addEditSection0); }

// PERSONAL TOOLBAR EXPANSION - from Mike function addTools { var myprefs = document.getElementById('pt-preferences'); var newpt; var newa;

newpt = document.createElement('li'); newa = document.createElement('a'); newa.href='/wiki/User:Vildricianus/monobook.css' ; newa.appendChild(document.createTextNode('css')); newpt.appendChild(newa); myprefs.parentNode.insertBefore(newpt, myprefs);

newpt = document.createElement('li'); newa = document.createElement('a'); newa.href='/wiki/User:Vildricianus/monobook.js' ; newa.appendChild(document.createTextNode('js')); newpt.appendChild(newa); myprefs.parentNode.insertBefore(newpt, myprefs);

newpt = document.createElement('li'); newa = document.createElement('a'); newa.href='/wiki/Special:Log' ; newa.appendChild(document.createTextNode('log')); newpt.appendChild(newa); myprefs.parentNode.insertBefore(newpt, myprefs);

newpt = document.createElement('li'); newa = document.createElement('a'); newa.href='/w/index.php?title=Special:Recentchanges&limit=250'; newa.appendChild(document.createTextNode('rc')); newpt.appendChild(newa); myprefs.parentNode.insertBefore(newpt, myprefs);

newpt = document.createElement('li'); newa = document.createElement('a'); newa.href='/wiki/Special:Randompage' ; newa.appendChild(document.createTextNode('rand')); newpt.appendChild(newa); myprefs.parentNode.insertBefore(newpt, myprefs);

}

function reformatMyPage { addTools; }

window.myAddOnload=function(f) { if (window.addEventListener) window.addEventListener("load", f, false); else if (window.attachEvent) window.attachEvent("onload",f); }

myAddOnload(reformatMyPage);

// User:Vildricianus/clock.js

document.write('');

//