User:Lem/wikiswapfuncs.js

function getURL(uri) { var sizeOf = location.href.length; uri.dir = location.href.substring(0, sizeOf); uri.array = uri.dir.split("/"); var arraySize = uri.array.length; uri.pagename = ""; uri.namespace = new String; for(var i = 3; i <= arraySize-1; i++) { if(i==arraySize-1){ uri.pagename = uri.pagename+uri.array[i]; }   else { uri.pagename = uri.pagename+uri.array[i]+"/"; } }  var isSTOW = uri.array[2].indexOf("wiki.guildwars.com"); var isMA = uri.array[2].indexOf("memory-alpha.org"); var isMB = uri.array[2].indexOf("memory-beta.wikia.com"); if (isSTOW != -1 ) { uri.thisSite = "STOWiki" }; if (isMA != -1 ) {uri.thisSite = "MA" }; if (isMB != -1 ) {uri.thisSite = "MB" }; return uri; }

function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { var node = document.getElementById(portlet); if ( !node ) return null; node = node.getElementsByTagName( "ul" )[0]; if ( !node ) return null; var link = document.createElement( "a" ); link.appendChild( document.createTextNode( text ) ); link.href = href; var item = document.createElement( "li" ); item.appendChild( link ); if ( id ) item.id = id; if ( accesskey ) { link.setAttribute( "accesskey", accesskey ); tooltip += " ["+accesskey+"]"; } if ( tooltip ) { link.setAttribute( "title", tooltip ); } if ( accesskey && tooltip ) { updateTooltipAccessKeys( new Array( link ) ); } if ( nextnode && nextnode.parentNode == node ) node.insertBefore( item, nextnode ); else node.appendChild( item ); // IE compatibility (?) return item; }

function addTab(url, name, id, title, key) { return addPortletLink('p-cactions', url, name, id, title, key); }