MediaWiki:Common.js

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

/* Put Main Page MWE box and filler links on shorter side */ if (mw.config.get('wgTitle') === 'Main Page') { function mainPageMaintain { var leftHeight = $('#featured').outerHeight(true) + $('#poll').outerHeight(true) + $('#shroom').outerHeight(true); var rightHeight = $('#news').outerHeight(true) + $('#dyk').outerHeight(true); if ( leftHeight < rightHeight ) { $('#mwe-left').show; $('#mwe-right').hide; leftHeight = leftHeight + $('#mwe-left').outerHeight(true); } else { $('#mwe-right').show; $('#mwe-left').hide; rightHeight = rightHeight + $('#mwe-right').outerHeight(true); }		var i, len, heightDif; var divIds = ['maintain', 'rc', 'random', 'faq']; for (i = 0, len = divIds.length; i < len; ++i) { heightDif = Math.abs(leftHeight - rightHeight); if (heightDif > 25) { if ( leftHeight < rightHeight ) { $('#' + divIds[i] + '-left').show; $('#' + divIds[i] + '-right').hide; leftHeight = leftHeight + $('#' + divIds[i] + '-left').outerHeight(true); } else { $('#' + divIds[i] + '-right').show; $('#' + divIds[i] + '-left').hide; rightHeight = rightHeight + $('#' + divIds[i] + '-right').outerHeight(true); }			} else { $('#' + divIds[i] + '-left').hide; $('#' + divIds[i] + '-right').hide; }		}	}	$(mainPageMaintain); $(window).resize(function {		$(mainPageMaintain);	}); }

/* Automatically add Aboutfile template to file upload description. Source: nl.wikipedia.org/wiki/MediaWiki:Common.js */ if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !document.getElementById('wpForReUpload') && !document.getElementsByClassName('mw-destfile-warning')[0] && !document.getElementsByClassName('error')[0]) { function loadAutoAboutfileTemplate { uploadDescription = document.getElementById('wpUploadDescription'); var doubleBracket = '{' + '{'; uploadDescription.value = doubleBracket + 'aboutfile\n|1=Subject of the image\n|2=Where you found the image\n|3=Artist\n|4=Describe edits, if any\n|5=Other versions (use file link)\n}}\n' + doubleBracket + 'uncategorized}}'; }	$(loadAutoAboutfileTemplate); }

/* Add a drop-down menu for CheckUser reasons */ if (mw.config.get('wgCanonicalSpecialPageName') === 'CheckUser') { function checkUserReasonMenu { var field = document.getElementById('checkreason'); var menu = 'Please select a reason... Routine new user check Suspected sockpuppet account Matching a vandal account Other '; field.outerHTML = menu; }	$(checkUserReasonMenu);

function checkUserOther(name) { if (name == 'Other') { var menu = document.getElementById('checkreason'); var field = ''; menu.outerHTML = field; }	} }

/* Fix Recent Changes top-right links when new user message */ if (mw.config.get('wgCanonicalSpecialPageName') === 'Recentchanges' && document.getElementsByClassName('usermessage')[0]) { function fixRcLinks { var rcTopLinks = $('#rc-floatlinks'); rcTopLinks.css('top', '-33px'); }	$(fixRcLinks); }