Jump to content

User:Mr.Z-man/closeAFD.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr.Z-man (talk | contribs) at 00:44, 4 September 2008 (testing). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
var closeAFD_default_close;
/*
function autoafd_result()
{
  var close = prompt("Result of debate?", closeAFD_default_close)
  if (close == null) {return;}
  var reason = prompt("Additional reason:", "reason")
  var page = "[["+wgPageName.replace(/_/g, "%20")+"]]";
  var title = wgTitle.substring(wgTitle.indexOf('/')+1);
  var f = document.editform, t = f.wpTextbox1;
  t.value = t.value.replace(/{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD\|(\w|\?)}}\n/i,"")
  if (reason != "reason") {
    t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + reason + " ~" + "~" + "~" + "~" + '\n' + t.value;
  }
  else {
    t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + t.value;
  }
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "ab" + "}}";
  f.wpSummary.value = "Closing debate; result was " + close;
  document.editform.wpSave.click();
  if (close == "delete") {
    window.open("http://en.wikipedia.org/w/index.php?title="+title+"&action=delete&wpReason="+page+"&autodelete=true");
    window.open("http://en.wikipedia.org/w/index.php?title=Talk:"+title+"&action=delete&wpReason="+page+"&autodelete=true");
  }
}
 
function autoafd_relist()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
  f.wpSummary.value = "Relisting debate";
}
 
function autoafd_keep()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD";
}
 
function autoafd_no_consensus()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD with no consensus";
}
 
function autoafd_redirect()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}
 
function autoafd_merge()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Merge and redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}
 
function autoafd_other()
{
  var date = prompt("Nomination was made when?")
  var result = prompt("Result was?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "AfDed; result was " + result;
*/}
function AFDtest() {
  closeAFD_getPageText(wgPageName);
}
function closeAFD_getPageText(title) {
  var req = sajax_init_object();
  req.open("GET", wgServer + wgScriptPath + "/api.php?action=query&prop=revisions&rvprop=content&format=json&titles="+title, false);
  req.send(null);
  var response = eval('(' + req.responseText + ')');
  alert(response);
  //return pagetext;
}
function closeAFD_getToken(title, type) {
  var req = sajax_init_object();
  req.open("GET", wgServer + wgScriptPath + "/api.php?action=query&prop=info&intoken="+type+"&format=json&titles="+title, false);
  req.send(null);
  var response = eval('(' + req.responseText + ')');
  //return token;
}
function closeAFD_editPage(title, newtext, token, summary) {
  var req = sajax_init_object();
  req.open("POST", wgServer + wgScriptPath + "/api.php?action=edit&token="+token+"&title="+title+"&text="+newtext+"&notminor=1&summary="+summary+"&nocreate=1&, true);
  req.send(null);
  var response = eval('(' + req.responseText + ')');
  //return token;
}