MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ // /*Recent changes addition*/ /* Add Recent Changes menu item link to On the Wiki menu */ $(function {	$('ul.nav > li.nav-item:first-child > ul.subnav-2 li.subnav-2-item:first-child').before('Recent Changes'); }); $('ul.nav > li.nav-item:first-child > ul.subnav-2 li.subnav-2-item:first-child').before('Fan Fiction'); }); /* displayTimer */ importScript('MediaWiki:Common.js/displayTimer.js');

/** Collapsible tables ********************************************************* * *  Description: Allows tables to be collapsed, showing only the header. See *              NavFrame. * Maintainer on Wikipedia: User:R. Koot */ 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 collapseTable( tableIndex ) {    var Button = document.getElementById( "collapseButton" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex ); if ( !Table || !Button ) { return false; }    var Rows = Table.getElementsByTagName( "tr" ); if ( Button.firstChild.data == collapseCaption ) { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = "none"; }        Button.firstChild.data = expandCaption; } else { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; }        Button.firstChild.data = collapseCaption; } } function createCollapseButtons {    var tableIndex = 0; var NavigationBoxes = new Object; var Tables = document.getElementsByTagName( "table" ); for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "collapsible" ) ) { 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.style.styleFloat = "right"; Button.style.cssFloat = "right"; Button.style.fontWeight = "normal"; Button.style.textAlign = "right"; Button.style.width = "6em"; 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( "]" ) ); var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0]; /* only add button and increment count if there is a header row to work with */ if (Header) { Header.insertBefore( Button, Header.childNodes[0] ); tableIndex++; }        }     }     for ( var i = 0;  i < tableIndex; i++ ) { if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { collapseTable( i ); }    } } addOnloadHook( createCollapseButtons );

{	saveButton.value = 'Save page (use preview first)'; saveButton.style.fontWeight = 'normal'; }

/* kill read more headings on pages with elements that have id="noreadmore" */ function NoReadMore { if($('#noreadmore')) { $('.RelatedPagesModule').css({"display": 'none'}); } }

addOnloadHook(NoReadMore);

/*Special tool for the USERNAME template.*/ /* Replaces with the name of the user browsing the page. Requires copying Template:USERNAME. */ var username_elements = document.getElementsByClassName("insertusername") || []; for ( var i = 0; i < username_elements.length; i++ ) { username_elements[i].textContent = mw.user.name; } /* End of the replacement */ /***************************************/ /*Massive extension for user tags     */ /***************************************/ window.UserTagsJS = { modules: {}, tags: { bureaucrat: { u:'Guild Headmaster', link:'Project:Bureaucrats', order:1 }, sysop: { u:'Guildmaster', link:'Project:Administrators', order:101 }, inactive: { u: 'Has not edited recently' order:102 }, bot: { u:'Felyne Comrade', order:103 }, test1: { u:'Tester', order:104 }, } }; UserTagsJS.modules.custom = { 'Master Ceadeus 27': ['test1'] // NOTE: order of list here does NOT matter }; UserTagsJS.modules.mwGroups = ['bureaucrat', 'sysop']; importArticle({type:'script', article:'w:c:dev:UserTags/code.js'}); /* END */