MediaWiki:AjaxBatchUndelete.js

/* if ($('#t-bd').length) return; var ug = mw.config.get("wgUserGroups").join(' '); if (ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') + ug.indexOf('helper') > -4) { var FormHTML = '\  \ \     Reason for recovery: \  \ \     \      Put the name of each page you want to undelete on a separate line. \        \ Any errors encountered will appear below: \  \ \ ',  token = mw.user.tokens.get('editToken'), delay = window.batchDeleteDelay || 1000; //Support for Monobook if (mw.config.get('skin') === 'monobook') { mw.util.addPortletLink('p-tb', '#', 'Batch unDelete', 't-bd'); }  else { $('#my-tools-menu').prepend(' Batch unDelete'); } $('#t-bd').click(function  {    $.showCustomModal('Ajax Batch unDelete', FormHTML, { id: 'form-mass-undelete', width: 500, buttons: [{ message: 'Cancel', handler: function { $('#form-mass-undelete').closeModal; }     }, {          id: 'startButton', message: 'Initiate', defaultButton: true, handler: function { init; }     }]    });  });    function init { var txt = document.getElementById('text-mass-undelete'), undeleteReason = document.getElementById('undelete-reason').value, pages = txt.value.split('\n'), currentPage = pages[0]; if (!undeleteReason) { alert('Please state a reason!'); return; }     document.getElementById('startButton').setAttribute('disabled','disabled'); if (!currentPage) { document.getElementById('startButton').removeAttribute("disabled"); $.showCustomModal('Finished!', 'Nothing left to do, or next line is blank.', {          id: 'mass-undelete-complete',           width: 200,           buttons: [{              message: 'Close',              defaultButton: true,              handler: function {                 $('#mass-undelete-complete').closeModal;              }           }]        }); }      else { process(currentPage,undeleteReason); }     pages = pages.slice(1,pages.length); txt.value = pages.join('\n'); }   function process(page,reason) { new mw.Api.post({     format: 'json',      action: 'undelete',      watchlist: 'nochange',      timestamps: '',      title: page,      reason: reason,      token: token      }) .done(function(d) {        if (!d.error) {          console.log('Recovery of '+page+' successful!');        } 	else {          console.log('Failed to recover '+page+': '+ d.error.code);          $('#text-error-output').append('Failed to undelete '+page+': '+d.error.code+' ');        }      }) .fail(function {       console.log('Failed to recover '+page+': unknownerror');        $('#text-error-output').append('Failed to recover '+page+': unknownerror ');      }); setTimeout(init,delay); } } }) (this.jQuery, this.mediaWiki);
 * Ajax Batch Delete V2
 * @description Delete listed multiple pages
 * Based on and faster than the original
 * http://dev.wikia.com/wiki/AjaxBatchDelete
 * Does not need to go to Special:BlankPage to use
 * Includes the option to protect after deleting
 * Includes the option to grab a whole category's contents
 * @author Ozuzanna
 * modified by Noreplyz & Nerfmaster8
 * (function($, mw) {