User:Gondor/monobook.js

/* * Collapsable tables ********************************************************* * * Description: Allows tables to be collapsed, show only the header. See *              wikipedia:Wikipedia:NavFrame. * Maintainers: wikipedia:User:R. Koot * Edited: User:Gondor - modified so that you can switch between different windows...same concept... *  code will be cleaned up later... */

var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show";

function hasClass( element, className ) { var Classes = element.className.split( " " ); for ( var i = 0; i < Classes.length; i++ ) { if ( Classes[i] == className ) { return ( true ); } }  return ( false ); }

function collapseTable1( tableIndex ) {   var Button1 = document.getElementById( "collapseButton1" + tableIndex ); var Button2 = document.getElementById( "collapseButton2" + tableIndex ); var Button3 = document.getElementById( "collapseButton3" + tableIndex ); var Button4 = document.getElementById( "collapseButton4" + tableIndex ); var Button5 = document.getElementById( "collapseButton5" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex );

//if it isn't a table or button do nothing if ( !Table || !Button1 ) { return false; }

//otherwise set button1 visible and the rest invisible var Rows = Table.getElementsByTagName( "tr" ); Rows[1].style.display = Rows[0].style.display; Rows[4].style.display = "none"; Rows[6].style.display = "none"; Rows[9].style.display = "none"; Rows[11].style.display = "none";

//now we need to set the text Button1.firstChild.data = "\"Tyria\""; Button2.firstChild.data = "Cantha"; Button3.firstChild.data = "Elona"; Button4.firstChild.data = "GWEN Missions"; Button5.firstChild.data = "GWEN Dungeons";

}

function collapseTable2( tableIndex ) {   var Button1 = document.getElementById( "collapseButton1" + tableIndex ); var Button2 = document.getElementById( "collapseButton2" + tableIndex ); var Button3 = document.getElementById( "collapseButton3" + tableIndex ); var Button4 = document.getElementById( "collapseButton4" + tableIndex ); var Button5 = document.getElementById( "collapseButton5" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex );

//if it isn't a table or button do nothing if ( !Table || !Button1 ) { return false; }

//otherwise set button1 visible and the rest invisible var Rows = Table.getElementsByTagName( "tr" ); Rows[1].style.display = "none"; Rows[4].style.display = Rows[0].style.display; Rows[6].style.display = "none"; Rows[9].style.display = "none"; Rows[11].style.display = "none";

//now we need to set the text Button1.firstChild.data = "Tyria"; Button2.firstChild.data = "\"Cantha\""; Button3.firstChild.data = "Elona"; Button4.firstChild.data = "GWEN Missions"; Button5.firstChild.data = "GWEN Dungeons"; }

function collapseTable3( tableIndex ) {   var Button1 = document.getElementById( "collapseButton1" + tableIndex ); var Button2 = document.getElementById( "collapseButton2" + tableIndex ); var Button3 = document.getElementById( "collapseButton3" + tableIndex ); var Button4 = document.getElementById( "collapseButton4" + tableIndex ); var Button5 = document.getElementById( "collapseButton5" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex );

//if it isn't a table or button do nothing if ( !Table || !Button1 ) { return false; }

//otherwise set button1 visible and the rest invisible var Rows = Table.getElementsByTagName( "tr" ); Rows[1].style.display = "none"; Rows[4].style.display = "none"; Rows[6].style.display = Rows[0].style.display; Rows[9].style.display = "none"; Rows[11].style.display = "none";

//now we need to set the text Button1.firstChild.data = "Tyria"; Button2.firstChild.data = "Cantha"; Button3.firstChild.data = "\"Elona\""; Button4.firstChild.data = "GWEN Missions"; Button5.firstChild.data = "GWEN Dungeons"; }

function collapseTable4( tableIndex ) {   var Button1 = document.getElementById( "collapseButton1" + tableIndex ); var Button2 = document.getElementById( "collapseButton2" + tableIndex ); var Button3 = document.getElementById( "collapseButton3" + tableIndex ); var Button4 = document.getElementById( "collapseButton4" + tableIndex ); var Button5 = document.getElementById( "collapseButton5" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex );

//if it isn't a table or button do nothing if ( !Table || !Button1 ) { return false; }

//otherwise set button1 visible and the rest invisible var Rows = Table.getElementsByTagName( "tr" ); Rows[1].style.display = "none" Rows[4].style.display = "none"; Rows[6].style.display = "none"; Rows[9].style.display = Rows[0].style.display; Rows[11].style.display = "none";

//now we need to set the text Button1.firstChild.data = "Tyria"; Button2.firstChild.data = "Cantha"; Button3.firstChild.data = "Elona"; Button4.firstChild.data = "\"GWEN Missions\""; Button5.firstChild.data = "GWEN Dungeons"; }

function collapseAll( tableIndex ) {   var Button1 = document.getElementById( "collapseButton1" + tableIndex ); var Button2 = document.getElementById( "collapseButton2" + tableIndex ); var Button3 = document.getElementById( "collapseButton3" + tableIndex ); var Button4 = document.getElementById( "collapseButton4" + tableIndex ); var Button5 = document.getElementById( "collapseButton5" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex );

//if it isn't a table or button do nothing if ( !Table || !Button1 ) { return false; }

//otherwise set button1 visible and the rest invisible var Rows = Table.getElementsByTagName( "tr" ); Rows[1].style.display = "none" Rows[4].style.display = "none"; Rows[6].style.display = "none"; Rows[9].style.display = "none"; Rows[11].style.display = "none"; }

function collapseTable5( tableIndex ) {   var Button1 = document.getElementById( "collapseButton1" + tableIndex ); var Button2 = document.getElementById( "collapseButton2" + tableIndex ); var Button3 = document.getElementById( "collapseButton3" + tableIndex ); var Button4 = document.getElementById( "collapseButton4" + tableIndex ); var Button5 = document.getElementById( "collapseButton5" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex );

//if it isn't a table or button do nothing if ( !Table || !Button1 ) { return false; }

//otherwise set button1 visible and the rest invisible var Rows = Table.getElementsByTagName( "tr" ); Rows[1].style.display = "none" Rows[4].style.display = "none"; Rows[6].style.display = "none"; Rows[9].style.display = "none"; Rows[11].style.display = Rows[0].style.display;

//now we need to set the text Button1.firstChild.data = "Tyria"; Button2.firstChild.data = "Cantha"; Button3.firstChild.data = "Elona"; Button4.firstChild.data = "GWEN Missions"; Button5.firstChild.data = "\"GWEN Dungeons\""; }

/*This is a test part...we are trying to create a header with 5 buttons*/ function createCollapseButtons2 {   var tableIndex = 0; var NavigationBoxes = new Object; var Tables = document.getElementsByTagName("table");

for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "missionlist" ) ) { NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex);

var Button    = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( "Tyria" );

Button.style.styleFloat = "left"; Button.style.cssFloat = "left"; Button.style.fontWeight = "normal"; Button.style.textAlign = "left"; Button.style.width = "3.5em";

ButtonLink.setAttribute( "id", "collapseButton1" + tableIndex ); ButtonLink.setAttribute( "href", "javascript:collapseTable1(" + tableIndex + ");" ); ButtonLink.appendChild( ButtonText );

Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) );

var Button2    = document.createElement( "span" ); var ButtonLink2 = document.createElement( "a" ); var ButtonText2 = document.createTextNode( "Cantha" );

Button2.style.styleFloat = "left"; Button2.style.cssFloat = "left"; Button2.style.fontWeight = "normal"; Button2.style.textAlign = "left"; Button2.style.width = "6em";

ButtonLink2.setAttribute( "id", "collapseButton2" + tableIndex ); ButtonLink2.setAttribute( "href", "javascript:collapseTable2(" + tableIndex + ");" ); ButtonLink2.appendChild( ButtonText2 );

Button2.appendChild( document.createTextNode( "[" ) ); Button2.appendChild( ButtonLink2 ); Button2.appendChild( document.createTextNode( "]" ) );

var Button3    = document.createElement( "span" ); var ButtonLink3 = document.createElement( "a" ); var ButtonText3 = document.createTextNode( "Elona" );

Button3.style.styleFloat = "left"; Button3.style.cssFloat = "left"; Button3.style.fontWeight = "normal"; Button3.style.textAlign = "left"; Button3.style.width = "6em";

ButtonLink3.setAttribute( "id", "collapseButton3" + tableIndex ); ButtonLink3.setAttribute( "href", "javascript:collapseTable3(" + tableIndex + ");" ); ButtonLink3.appendChild( ButtonText3 );

Button3.appendChild( document.createTextNode( "[" ) ); Button3.appendChild( ButtonLink3 ); Button3.appendChild( document.createTextNode( "]" ) );

var Button4    = document.createElement( "span" ); var ButtonLink4 = document.createElement( "a" ); var ButtonText4 = document.createTextNode( "GWEN Missions" );

Button4.style.styleFloat = "left"; Button4.style.cssFloat = "left"; Button4.style.fontWeight = "normal"; Button4.style.textAlign = "left"; Button4.style.width = "10em";

ButtonLink4.setAttribute( "id", "collapseButton4" + tableIndex ); ButtonLink4.setAttribute( "href", "javascript:collapseTable4(" + tableIndex + ");" ); ButtonLink4.appendChild( ButtonText4 );

Button4.appendChild( document.createTextNode( "[" ) ); Button4.appendChild( ButtonLink4 ); Button4.appendChild( document.createTextNode( "]" ) );

var Button5    = document.createElement( "span" ); var ButtonLink5 = document.createElement( "a" ); var ButtonText5 = document.createTextNode( "GWEN Dungeons" );

Button5.style.styleFloat = "left"; Button5.style.cssFloat = "left"; Button5.style.fontWeight = "normal"; Button5.style.textAlign = "left"; Button5.style.width = "10em";

ButtonLink5.setAttribute( "id", "collapseButton5" + tableIndex ); ButtonLink5.setAttribute( "href", "javascript:collapseTable5(" + tableIndex + ");" ); ButtonLink5.appendChild( ButtonText5 );

Button5.appendChild( document.createTextNode( "[" ) ); Button5.appendChild( ButtonLink5 ); Button5.appendChild( document.createTextNode( "]" ) );

var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0]; Header.insertBefore( Button5, Header.childNodes[0] ); Header.insertBefore( Button4, Header.childNodes[0] ); Header.insertBefore( Button3, Header.childNodes[0] ); Header.insertBefore( Button2, Header.childNodes[0] ); Header.insertBefore( Button, Header.childNodes[0] ); collapseAll(tableIndex); tableIndex++; }   } }

addOnloadHook( createCollapseButtons2 );

/**** 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'; var gwwtWatchlist = true;

timerTimezone = -5;