User:JediRogue/monaco.js

//WIKISWAP //from User:AT

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("guildwars.wikia.com"); 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('page_tabs', url, name, id, title, key); }

//from User:AT

// WikiSwap function wikiSwap { var url = new String; var urlSwitch = new String; var urlGW2 = new String; var uri = new Object; var label = new String; var title = new String; getURL(uri); if (uri.thisSite == "GWW") { url = "http://gw.gamewikis.org/" ; label = "Switch to GuildWiki"; title = "GWiki"; }   if (uri.thisSite == "GWIKI") { url = "http://wiki.guildwars.com/" label = "Switch to GWW"; title = "GWW"; }   urlSwitch = url + uri.pagename; if(uri.pagename.indexOf("Guild:") == -1) { addTab(urlSwitch, title, "ca-swap", label, ""); }   urlGW2 = "http://wiki.guildwars2.com/" + uri.pagename;

addTab(urlGW2, "GW2W", "ca-swap2", "Switch to GW2W", ""); }

function test{ var node = document.getElementByID("ca-edit"); node.text = "EDIT!"; }

addOnloadHook(wikiSwap); addOnloadHook(test);