Jump to content

User:Pxma/afchelper.js

From Wikipedia, the free encyclopedia
(Redirected from User:PxMa/afchelper.js)
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.
importScript("User:PxMa/simpleajax.js");
importScript("User:Azatoth/morebits.js");

function afchelperload(){
 if(wgTitle.indexOf("Articles for creation") == -1){
  return;
 }
 mw.util.addPortletLink("p-cactions", "javascript:afchelper('approved')", "approved", "ca-approved", "approved", "");
 mw.util.addPortletLink("p-cactions", "javascript:afchelper('denied')", "denied", "ca-denied", "denied", "");
 mw.util.addPortletLink("p-cactions", "javascript:afchelper('archive')", "archive", "ca-archive", "archive", ""); 
}
$(afchelperload);

function afchelper(type){
 if(type == "approved"){
  var params = window.prompt("add articlename, or don't ");
  if(params == null){
   params = "";
  }else{
   params = "|" + params;
  }
  var tag = "{" + "{" + "subst:afc accept"+params+"}}";
  simpleAJAXAppend(wgPageName, ":"+tag+" ~~"+"~~"+"\n", "Approving article", false, true, "<h3>Editing...</h3>", "<h3>Saved!</h3>", true);
 }
 if(type == "denied"){
  var params = window.prompt("v/bio/nn/web/corp/music/dict/context/blank/neo/joke/lang/blp/npov/not");
  if(params == null){
   params = "";
  }else{
   params = " " + params;
  }
  var tag = "{" + "{" + "subst:afc"+params+"}}";
  simpleAJAXAppend(wgPageName, ":"+tag+" ~~"+"~~"+"\n", "Article denied", false, true, "<h3>Editing...</h3>", "<h3>Saved!</h3>", false);
 }
 if(type == "archive"){
  var result = window.prompt("If accepted add accept", "Approved");
  simpleAJAXAppendPrepend(wgPageName, "{"+"{"+"subst:afc top|"+result+"}}", "{"+"{"+"subst:afc b}}", "Archiving", false, false, "<h3>Archiving...</h3>", "<h3>Archived, reloading...</h3>", true);
 }
}