User:Gamedezyner/API/Plugins/deleteStandardsPages.js

//Delete old Standards Violation plugin for API //Designed for use on w:c:sonicfanon api.functions.deleteStandardsPages = function { api.functions.deleteStandardsPages.timelimit = 1; thisQuery = new api.actions.query; thisQuery.list = "categorymembers"; thisQuery.cmtitle = "Category:Pages that do not meet standards"; thisQuery.cmlimit = api.settings.pagelimit; api.actions.post(thisQuery); categorymembers = thisQuery.response.query.categorymembers; thisQuery = new api.actions.query; thisQuery.prop = "revisions" thisQuery.titles = '' for (var i in categorymembers) { thisQuery.titles += categorymembers[i].title + '|'; } thisQuery.titles = thisQuery.titles.slice(0,thisQuery.titles.length-1); api.actions.post(thisQuery); pages = thisQuery.response.query.pages; badpages = []; for (var i in pages) { var prevTime = new Date(pages[i].revisions[0].timestamp); // Edit date var thisTime = new Date             // now var diff = thisTime.getTime - prevTime.getTime;  // now - Feb 1 if (diff/(1000*60*60*24)>api.functions.deleteStandardsPages.timelimit) { badpages.push(pages[i].title); } }  console.log(badpages); if (badpages.length>0) { i=0; apiInterval = setInterval(function {     if (iPage Deleted: ' + badpages[i] + ''); console.log('Page Deleted: ' + badpages[i]); i++; }     else { console.log("Done!"); api.functions.deleteStandardsPages.running = false; api.functions.deleteStandardsPages.complete = true; $("#ok").attr("disabled",false).html("Exit"); $("#cancel").remove; clearInterval(apiInterval); };   },api.settings.throttle);  } } api.functions.deleteStandardsPages.running = false; api.functions.deleteStandardsPages.complete = false;

api.menu.add("deleteStandardsPages", "Empty Standards"); $("#deleteStandardsPages").click(function {   api.menu.open("Delete Standards Pages", ' This will delete pages in Category:Pages_that_do_not_meet_standards that haven\'t been touched in ' + api.functions.deleteStandardsPages.timelimit + ' days. ' , 510,    function { if (api.functions.deleteStandardsPages.running == false && api.functions.deleteStandardsPages.complete == false) { api.functions.deleteStandardsPages.running = true; $("#ok").attr("disabled",true).html("Running..."); api.functions.deleteStandardsPages; }       if (api.functions.deleteStandardsPages.running == false && api.functions.deleteStandardsPages.complete == true) { api.menu.cancel; }   },     function { if (typeof(apiInterval) != "undefined"){ clearInterval(apiInterval); }     api.functions.deleteStandardsPages.running = false; api.functions.deleteStandardsPages.complete = false; api.menu.cancel; },   "Go!", "Cancel"); });