Jump to content

User:King of Hearts/closecfd.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.
// closecfd.js - 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 autocfd_result()
{
	var close = prompt("Result of debate?")
	var f = document.editform, t = f.wpTextbox1;
	t.value = t.value.split(' ====').join(' ====' + '\n' + '{{subst:' + 'cfd top' + '|1=' + '\'' + '\'' + '\'' + close + '\'' + '\'' + '\'' + '.}}' + ' ~~' + '~~');
	t.value += "{{subst:" + "cfd bottom" + "}}";
	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 Wikipedia:Categories for discussion/Log/") != -1) && (document.title.indexOf("(section)") != -1))
	{
		mw.util.addPortletLink('p-cactions', 'javascript:autocfd_result()', "close");
	}
}
 
addOnloadHook(autocfd_add_cfd_tabs);