User:Kyrasantae/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 isGWW = uri.array[2].indexOf("wiki.guildwars.com"); var isGWIKI = uri.array[2].indexOf("www.guildwiki.org"); if (isGWW != -1 ) { uri.thisSite = "GWW" }; if (isGWIKI != -1 ) {uri.thisSite = "GWIKI" }; 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); }