MediaWiki:RemoveIncomplete.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// <nowiki>
/*
  Quick helper script for removing {{Incomplete upload}}.

  Original author of Catcheck.js: [[User:Lupo]], September 2008
  Derived from [[MediaWiki:Botcheck.js]]
  License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
  
  Choose whichever license of these you like best :-)
*/

/*global $:false, wgNamespaceNumber:false, wgAction:false*/
/*jshint curly:false*/
if (mw.config.get('wgNamespaceNumber') === 6 && mw.config.get('wgAction') === 'edit') {
	$(document).ready(function () {
		'use strict';

		var text = document.getElementById ('wpTextbox1');
		if (!text) return;
		// Remove tag
		text.value = text.value.replace (/\{\{Incomplete[ _]upload\}\}/g, "");

		// Remove cat
		text.value = text.value.replace (/\[\[Category:Incomplete[ _]JPG[ _]files[ _]\(5[ _]MB[ _]interruption\)\]\]/g, "");
		
		// Remove any whitespace from beginning and end
		text.value = $.trim( text.value || "" );

		// Set edit summary
		var add = "Removing [[Template:Incomplete upload|{{Incomplete upload}}]] and [[Category:Incomplete JPG files (5 MB interruption)]]";
		var summary = document.getElementById ('wpSummary');
		if (!summary) return;
		var val = $.trim( summary.value || "" );
		if (val.indexOf(add) !== -1) return;
		summary.value = (val.length === 0) ? add : val + " " + add;
		document.editform.wpMinoredit.checked = true;
		document.editform.wpDiff.click();
	});
}
// </nowiki>