MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ function createCollapseButtons {   var tableIndex = 0; var NavigationBoxes = new Object; var Tables = getElementsByClassName(document, "table", "collapsible"); for ( var i = 0; i < Tables.length; i++ ) { /* only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; if (!HeaderRow) continue; var Header = HeaderRow.getElementsByTagName( "th" )[0]; if (!Header) continue; NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); var Button    = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( collapseCaption ); Button.className = "collapseButton"; //Styles are declared in Common.css ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button, Header.childNodes[0] ); tableIndex++; }   var Tables = getElementsByClassName(document, "table", "collapsed"); for ( var i = 0; i < Tables.length; i++ ) { collapseTable( i ); }   var Tables = getElementsByClassName(document, "table", "autocollapse"); for ( var i = 0; i < Tables.length; i++ ) { if ( i >= autoCollapse ) { collapseTable( i ); }    }	}