MediaWiki:Common.js

// Any JavaScript here will be loaded for all users on every page load.

// // Variables // var action            = mw.config.get("wgAction") , pageName          = mw.config.get("wgPageName") , server            = mw.config.get("wgServer") , groups            = mw.config.get("wgUserGroups") , canonicalNamespace = mw.config.get("wgCanonicalNamespace");

// // Rights // Sets a variable "rights" which will return "false" if the // currently logged in user is a bureaucrat, administrator, or autoconfirmed user. It will return true otherwise. // it also defines variables which may be used elsewhere in scripts. //

if (groups) { groupsString = groups.toString; var rights_isAuto   = (groupsString.indexOf('autoconfirmed') > -1) , rights_isAdmin  = (groupsString.indexOf('sysop')         > -1) , rights_isCrat   = (groupsString.indexOf('bureaucrat')    > -1) , rights_isRetired = (groupsString.indexOf('retired')      > -1) , rights = true; } else { var rights = false; }

// // Special:MovePage // Uncheck "Leave a redirect behind" if moving a file // $(function {	var isMovingFile = pageName.startsWith("Special:MovePage/File");	if(isMovingFile) {		var leaveRedirectCheckbox = $("input[name=wpLeaveRedirect]")[0];		leaveRedirectCheckbox.checked = false;	} });

// // Special:ExpandTemplates // Check "Suppress tags in result" when using ExpandTemplates // $(function {	if (pageName == "Special:ExpandTemplates") {		var suppressNowikiTagsCheckbox = $("input[name=wpRemoveNowiki]")[0];		suppressNowikiTagsCheckbox.checked = true;	} });

// -- // CrazyEgg Tracking // -- setTimeout(function{	var a=document.createElement("script"),	   b=document.getElementsByTagName("script")[0];	a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0011/8371.js?"+Math.floor(new Date.getTime/3600000);	a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);

// -- // Temporary upload-related things // --

//Add the html5 'required' attribute to the Source field on Special:Upload if (pageName === "Special:Upload") { $(function {		$("#mw-input-source").prop('required',true);		$("label[for=mw-input-source]").html('Source (help)');	}); }