MediaWiki:Gadget-Site.js

/* JS for all users on all desktop and mobile skins.

Inteded as a replacement to Common.js and Mobile.js which only target desktop and mobile versions, respectively.

Use sparingly for JavaScript not significant enough to warrant its own Gadget.



// // Special:MovePage // Uncheck "Leave a redirect behind" if moving a file // $(function {	var isMovingFile = mw.config.get("wgPageName").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 (mw.config.get("wgPageName") == "Special:ExpandTemplates") {		var suppressNowikiTagsCheckbox = $("input[name=wpRemoveNowiki]")[0];		suppressNowikiTagsCheckbox.checked = true;	} });

// -- // Use altrow styling on Cargo tables // -- $(function {	$(".cargoTable")		.addClass('wikitable')		.removeClass('cargoTable') //because the class overrides altrow styles });

// -- /* Fix the wrong icons showing in the codeEditor buttons */ // -- $('#wpTextbox1').on('wikiEditor-toolbar-doneInitialSections',function{	$("#wikiEditor-section-main .group-codeeditor-main .wikiEditor-toolbar-spritedButton").removeClass("wikiEditor-toolbar-spritedButton"); }); mw.hook('codeEditor.configure').add(function{	$("#wikiEditor-section-main .group-codeeditor-format .wikiEditor-toolbar-spritedButton").removeClass("wikiEditor-toolbar-spritedButton");	$("#wikiEditor-section-main .group-codeeditor-style .wikiEditor-toolbar-spritedButton").removeClass("wikiEditor-toolbar-spritedButton"); });

// // Link to module dependencies // Author: RheingoldRiver // $(function {	if (mw.config.get('wgCanonicalNamespace') != 'Module') return;	$('.s1, .s2').each(function { var html = $(this).html; var quote = html[0]; var quoteRE = new RegExp('^' + quote + '|' + quote + '$', 'g'); var name = html.replace(quoteRE,""); if (name.startsWith("Module:")) { var target = name.replace(/ /g,'%20'); var url = mw.config.get('wgServer') + '/' + target; var str = quote + '' + name + '' + quote; $(this).html(str); }	}); });

// Highlight linked table rows (function { const highlightClass = "zw-highlight"; const linkedTd = $('td :target').closest('tr').addClass(highlightClass); linkedTd	.siblings	.mouseover(function { linkedTd.removeClass(highlightClass); }); });