// closetfd.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 autotfd_result()
{
var close = prompt("Result of debate?")
var f = document.editform, t = f.wpTextbox1;
t.value = t.value.split(']] ====').join(']] ====' + '\n' + '{{subst:' + 'tfd top' + '|1=' + '\'' + '\'' + '\'' + close + '\'' + '\'' + '\'' + '.|2=y}}');
t.value += "{{subst:" + "tfd bottom" + "}}";
f.wpSummary.value += "Closing debate; result was " + close;
}
function autotfd_add_tfd_tabs()
{
// Only add for pages with the right string somewhere in the title
if ((document.title.indexOf("Editing Wikipedia:Templates for discussion/Log/") != -1) && (document.title.indexOf("(section)") != -1))
{
mw.util.addPortletLink('p-cactions', 'javascript:autotfd_result()', "close");
}
}
$(autotfd_add_tfd_tabs);