User:King of Hearts/closeudel.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.
// closeudel.js - written by [[User:King of Hearts]], modified from
// [[User:King of Hearts/closecfd.js]] by [[User:King of Hearts]], 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]]
 
function autoudel_result()
{
	var close = "invalid"
	while (close == "invalid") {
		var input = prompt("Done or not done?")
		if (input.charAt(0) == 'd' || input.charAt(0) == 'D' || input.charAt(0) == 'y' || input.charAt(0) == 'Y') close = "done"
		if (input.charAt(0) == 'n' || input.charAt(0) == 'N') close = "not done"
	}
	var reason = prompt("Closing rationale?")
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.search('{{udel' + 'h}}') != -1)
		t.value = t.value.split('{{udel' + 'h}}').join('----' + '\n' + '{{' + close + '}}' + ': ' + reason + ' ~~' + '~~' + '\n' + '{{udel' + 'f}}' + '\n' + '\n' + '{{udel' + 'h}}');
	else
		t.value += '----' + '\n' + '{{' + close + '}}' + ': ' + reason + ' ~~' + '~~' + '\n' + '{{udel' + 'f}}';
	t.value = '{{udel' + 'h}}' + '\n' + t.value;
	f.wpSummary.value += "Closing request as " + close;
}
 
function autoudel_add_udel_tabs()
{
	// Only add for pages with the right string somewhere in the title
	if (document.title.indexOf("Editing Commons:Undeletion requests/Current requests (section)") != -1)
	{
		mw.util.addPortletLink('p-cactions', 'javascript:autoudel_result()', "close");
	}
}
 
$(autoudel_add_udel_tabs);

// [[Category:User scripts]]