User:AT/wikiswapfuncs.js

From Guild Wars Wiki
Jump to navigationJump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
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("gw.gamewikis.org");
  var isGW2W = uri.array[2].indexOf("wiki.guildwars2.com");
  if (isGWW != -1 ) { uri.thisSite = "GWW"  };
  if (isGWIKI != -1 ) {uri.thisSite = "GWIKI" };
  if (isGWIKI != -1 ) {uri.thisSite = "GW2W" };
  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); 
}