Jump to content

User:DeirdreAnne/closemfd.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// closemfd.js - updated by [[User:Doug]] with help from [[User:thedj]] from code 
// written by [[User:King of Hearts]], modified from
// [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]] by [[User:Johnleemk]]
// and [[User:Lifebaka/closedrv.js]] by [[User:Lifebaka]]
 
function automfd_result()
{
	var close = prompt("Result of debate?");
	var f = document.editform, t = f.wpTextbox1;
 
	t.value = "{{subst:" + "mfd top" + "|1='''" + close + "'''.|2=y}}" + "\n" + "\n" + t.value;
	if (t.value.length > 0)
	{
		t.value += '\n';
	}
	t.value += "{{subst:" + "mfd bottom" + "}}";
	f.wpSummary.value += "Closing debate; result was " + close + " (using [[User:Doug/closemfd.js]])";
}
 
function automfd_add_mfd_tabs()
{
	// Only add for pages with the right string somewhere in the title
	if ((document.title.indexOf("Editing Wikipedia:Miscellany for deletion/") != -1) && (document.title.indexOf("(section)") != -1))
	{
		mw.loader.using( ['mediawiki.util'] ).done( function() {
			var link = mw.util.addPortletLink('p-cactions', '', "close");
			$(link).click( function(e) {
				e.preventDefault();
				automfd_result();
			} );
		});
	}
}
 
$(automfd_add_mfd_tabs);