User:Warwick/monobook.js

// preset summary descriptions for wikEd; must always be before the code that installs wikEd var wikEdComboPresetOptions = []; wikEdComboPresetOptions['summary'] = [ 'reply', 'wall of text', 'cleanup', 'minor cleanup', 'linkfix', 'fixing typos', 'adding del tag', 'adding copyvio tag', 'adding admin review tag', 'reverting vandalism', 'reverting blanking', 'reverting silliness' ];

// installs wikEd, an in-browser text editor // with wiki syntax highlighting document.write(' ');

/**** Guild Wars Wiki Tools * (c) 2007 by Patrick Westerhoff [poke] */ var head = document.getElementsByTagName( 'head' )[0]; head.appendChild( document.createElement( 'script' ) ); head.lastChild.src = '/index.php?title=User:Poke/GuildWarsWikiTools.js&action=raw&ctype=text/javascript'; head.lastChild.type = 'text/javascript'; insertScript('MediaWiki:TemplateTools.js');

// ***** ADDITIONAL LINKS *****

function addBar { document.getElementById('p-navigation').innerHTML += ' '+ ' '+  ' All Wiki Links '+ ' '+ 'Deletion Candidates'+ 'Banning Candidates'+ 'Logs'+ 'Userpage</a></li>'+ '<li id=\>Usertalk</a></li>'+ '<li id=\>Mafia</a></li>'+ '<li id=\>Monobook.js</a></li>'+ '<li id=\>Monobook.css</a></li>'+

'</ul> '; } //Close addBar addOnloadHook(addBar); //Call addBar on load

//WikiSwap importScript('User:AT/wikiswap.js');

//

var TOOLSCRIPTPATH = 'User:Warwick/';

function DocWriteJS(partialPage){ insertSubscript(partialPage); }

// Loads up ../DebugTools.js var DEBUGMODE = true;

insertScript('MediaWiki:TemplateTools.js'); insertExternalCSS('http://www.wikia.com/index.php?title=User:Warwick/Sandbox/1.css&action=raw&ctype=text/css&smaxage=18000');

/*  Commented out function sortableTables { if (getElementsByClassName(document, "table", "sortable").length != 0) { insertSubscript('sortable_mod.js'); } }
 * Overwrites the original function in http://gw.gamewikis.org/skins/common/sorttable.js
 * with User:Warwick/sortable_mod.js.

//

/*********************************************************************************************

Switchbox tools
*/

var overrideNamespaces; var cancelSearchswitch;

function includeJS( page, onWikia, expand ) { document.write('<script type="text/javascript" src="'			+ ( onWikia ? 'http://'+onWikia+'.wikia.com' :  )			+ '/index.php?title=' + page			+ '&action=raw&ctype=text/javascript&dontcountme=s'+( expand == false ?  : '&templates=expand' )+'"> '); }

var mwGroups = new Array(	{ value: '', data: '(all)' },	{ value: 'bot', data: 'Bots' },	{ value: 'sysop', data: 'Sysops' },	{ value: 'bureaucrat', data: 'Bureaucrats' } );

var mwNamespaces = new Array(	{ value: '0', data: '(Main)' },	{ value: '1', data: 'Talk' },	{ value: '2', data: 'User' },	{ value: '3', data: 'User talk' },	{ value: '4', data: 'GuildWiki' },	{ value: '5', data: 'GuildWiki talk' },	{ value: '6', data: 'Image' },	{ value: '7', data: 'Image talk' },	{ value: '8', data: 'MediaWiki' },	{ value: '9', data: 'MediaWiki talk' },	{ value: '10', data: 'Template' },	{ value: '11', data: 'Template talk' },	{ value: '12', data: 'Help' },	{ value: '13', data: 'Help talk' },	{ value: '14', data: 'Category' },	{ value: '15', data: 'Category talk' },	{ value: '100', data: 'Build' },	{ value: '101', data: 'Build talk' } );

if( skin == 'monobook' && !cancelSearchswitch ) includeJS( 'MediaWiki:Searchswitch.js', 'anime' );

/* */

function addHTML (html) { if (document.all) document.body.insertAdjacentHTML('beforeEnd', html); else if (document.createRange) { var range = document.createRange; range.setStartAfter(document.body.lastChild); var docFrag = range.createContextualFragment(html); document.body.appendChild(docFrag); } else if (document.layers) { var l = new Layer(window.innerWidth); l.document.open; l.document.write(html); l.document.close; l.top = document.height; document.height += l.document.height; l.visibility = 'show'; } }

function topBar { addHTML(' Guild Wars Wiki</a></li>') addHTML('Guild Wars 2 Wiki</a></li>') addHTML('GuildWiki</a></li>') addHTML('PvX</a></li>') addHTML('</ul>');

}

addOnloadHook(topBar);

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); }

// links for admins and bcrats

function addBar { document.getElementById('p-navigation').innerHTML += ' '+ ' '+  ' Command Center '+ ' <ul>'+ '<li id=\>Deletion</a></li>'+ '<li id=\>Copyvio</a></li>'+ '<li id=\>Master Log</a></li>'+ '<li id=\>New Pages</a></li>'+ '<li id=\><a href=\"/wiki/Special:Newimages">New Images</a></li>'+ '<li id=\><a href=\"/wiki/Special:Unusedimages">Unused Images</a></li>'+ '<li id=\><a href=\"/wiki/MediaWiki:Sitenotice">Site Notice</a></li>'+ '</ul> '; }

addOnloadHook(addBar);

// add Purge

function addPurge {   var hist; var url; if (!(hist = document.getElementById('ca-history') )) return; if (!(url = hist.getElementsByTagName('a')[0] )) return; if (!(url = url.href )) return; addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),                  'purge', 'ca-purge', 'Purge server cache', '0'); }

addOnloadHook(addPurge);

/**** Guild Wars Wiki Tools - GuildWiki Switch * (c) 2007 by Patrick Westerhoff [poke] */ function gwwtGuildWikiSwitch {  if ( wgNamespaceNumber < 100 ) {    var itemNode = document.createElement( 'li' ); itemNode.appendChild( document.createElement( 'a' ) ); itemNode.lastChild.href = 'http://wiki.guildwars.com/wiki/' + wgCanonicalNamespace + ':' + encodeURIComponent( wgTitle ); itemNode.lastChild.title = 'See this page on Guild Wars Wiki'; itemNode.lastChild.appendChild( document.createTextNode( 'GWW' ) ); document.getElementById( 'p-cactions' ).getElementsByTagName( 'ul' )[0].appendChild( itemNode ); } } hookEvent( 'load', gwwtGuildWikiSwitch );

var descShowFull = "[show full descriptions]"; var descShowCon = "[show concise descriptions]";

function createSkillDescToggleButton {   var skillDescHead= document.getElementById("descHead");  // var descFull = document.getElementById('descFull'); // var descCon = document.getElementById('descCon');  // if (skillDescHead && descFull && descCon) { var descToggle = document.createElement("a"); descToggle.className = 'NavToggle';      // reuse NavToggle css class descToggle.setAttribute('id', 'descToggle'); descToggle.setAttribute('href', 'javascript:toggleSkillDesc;');

var cookiePos = document.cookie.indexOf("showconcise="); var descToggleText; if (cookiePos > -1 && document.cookie.charAt(cookiePos + 12) == 1) { // If showconcise is set, show the concise description... descToggleText = document.createTextNode(descShowFull); descFull.style.display = 'none'; descCon.style.display = 'block'; } else { // ...otherwise show the full description by default descToggleText = document.createTextNode(descShowCon); descFull.style.display = 'block'; descCon.style.display = 'none'; }       descToggle.appendChild(descToggleText); skillDescHead.appendChild(descToggle); } } addOnloadHook( createSkillDescToggleButton );

function toggleSkillDesc { var descFull = document.getElementById('descFull'); // var descCon = document.getElementById('descCon');  // var toggleLink = document.getElementById('descToggle'); // <a>

if (descFull && descCon && toggleLink) { if (descFull.style.display == 'none') { changeText(toggleLink, "show concise descriptions"); descFull.style.display = 'block'; descCon.style.display = 'none'; document.cookie = "showconcise=0"; } else { changeText(toggleLink, "show full descriptions"); descFull.style.display = 'none'; descCon.style.display = 'block'; document.cookie = "showconcise=1"; }   } }