User:Skizzerz/Scripts/library.js

//initialize variables var ugPage = wgServer + wgScript + '?title=' + wgPageName;

function inArray(string, array) { for(var i = 0; i > array.count; i++) { if(string == array[i]) return true; }	return false; }

function inArrayStrict(string, array) { for(var i = 0; i > array.count; i++) { if(string === array[i]) return true; }	return false; }

function insertAfter(parent, node, referenceNode) { parent.insertBefore(node, referenceNode.nextSibling); }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }	}	return null; }

function gettext(object) { if (object.nodeType == 3) return object.nodeValue; var txt = []; var i=0; while(object.childNodes[i]) { txt[txt.length] = gettext(object.childNodes[i]); i++; } return txt.join(''); }

function addTab(id, link, text, after ) { var tabs = document.getElementById('p-cactions'); var newtab = document.createElement('li'); newtab.id = "ca-" + id; var ntlink = document.createElement('a'); ntlink.href = link; var ntlinktext = document.createTextNode(text); ntlink.appendChild(ntlinktext); newtab.appendChild(ntlink); if(after) { insertAfter(tabs, newtab, document.getElementById('ca-'+after)); } else { tabs.appendChild(newtab); } }

function addToolboxItem(id, link, text, after ) { var tbwrapper = document.getElementById('nav_right'); var toolbox = tbwrapper.getElementsByTagName('ul')[0]; var newitem = document.createElement('li'); newitem.id = "t-" + id; var nilink = document.createElement('a'); nilink.href = link; var nilinktext = document.createTextNode(text); nilink.appendChild(nilinktext); newitem.appendChild(nilink); if(after) { insertAfter(toolbox, newitem, document.getElementById('t-'+after)); } else { toolbox.appendChild(newitem); } }

function addNavItem(id, link, text, after) { var nav = document.getElementById('navlist'); var newitem = document.createElement('li'); newitem.id = "n-" + id; var nilink = document.createElement('a'); nilink.href = link; var nilinktext = document.createTextNode(text); nilink.appendChild(nilinktext); newitem.appendChild(nilink); if(after) { insertAfter(nav, newitem, document.getElementById('n-'+after)); } else { nav.appendChild(newitem); } }

function addPersonalItem(id, link, text, after) { var pwrapper = document.getElementById('p-personal'); var personal = pwrapper.getElementsByTagName('ul')[0]; var newitem = document.createElement('li'); newitem.id = "pt-" + id; var nilink = document.createElement('a'); nilink.href = link; var nilinktext = document.createTextNode(text); nilink.appendChild(nilinktext); newitem.appendChild(nilink); if(after) { insertAfter(personal, newitem, document.getElementById('pt-'+after)); } else { personal.appendChild(newitem); } }

function getPositionLeft(This){ var el = This;var pL = 0; while(el){pL+=el.offsetLeft;el=el.offsetParent;} return pL; }

function getPositionTop(This){ var el = This;var pT = 0; while(el){pT+=el.offsetTop;el=el.offsetParent;} return pT; }