User:King of Hearts/closecfd.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.
// closecfd.js - written by [[User:King of Hearts]], modified from
// [[w:User:King of Hearts/closecfd.js]] by [[User:King of Hearts]], from
// [[w:Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]] by [[User:Johnleemk]]
// and [[w:User:Lifebaka/closedrv.js]] by [[User:Lifebaka]]
mw.log.warn( 'This script is deprecated, use the UdelReqHandler gadget instead.' );

function autocfd_result() {
	var close = prompt("Result of debate?"),
		reason = prompt("Closing rationale?"),
		f = document.editform,
		t = f.wpTextbox1;
	t.value = '{{cfd' + 'h}}' + '\n' + t.value;
	t.value += '----' + '\n' + '\'\'\'' + close + '\'\'\'' + ': ' + reason + ' ~~' + '~~' + '\n' + '{{cfd' + 'f}}';
	f.wpSummary.value += "Closing debate; result was " + close;
}

function autocfd_add_cfd_tabs() {
	// Only add for pages with the right string somewhere in the title
	if (document.title.indexOf("Editing Commons:Categories for discussion/") !== -1) {
		$(mw.util.addPortletLink('p-cactions', '', "close")).click(autocfd_result);
	}
}

$.when(mw.loader.using('mediawiki.util'), $.ready).then(autocfd_add_cfd_tabs);

// [[Category:User scripts]]