MediaWiki:MassBlock/code.js

// \       ' + i18n.accountCreation + ' \ ' + i18n.talkPage + ' \ ' + i18n.instructions + ' \  \ ' + i18n.outputInitial + ' \ \ ',  delay = window.massBlockDelay || 1000;

//Support for Monobook if (mw.config.get('skin') === 'monobook') { mw.util.addPortletLink('p-tb', '#', 'Mass Block', 't-bb'); }  else { $('#my-tools-menu').prepend(' ' + i18n.title + ''); }

$('#t-bb').click(function {    $.showCustomModal(i18n.title, FormHTML, { id: 'form-mass-block', width: 500, buttons: [{ message: i18n.cancel, handler: function { $('#form-mass-block').closeModal; }     },  {          id: 'startButton', message: i18n.initiate, defaultButton: true, handler: function { init; }     }]    });  });

function init { var txt = document.getElementById('text-mass-block'), pages = txt.value.split('\n'), currentUser = pages[0];

$('#startButton').attr('disabled','disabled');

if (!currentUser) { $('#startButton').removeAttr("disabled"); $.showCustomModal(i18n.finished, i18n.nothingLeftToDo, {          id: 'mass-block-complete',           width: 200,           buttons: [{              message: i18n.close,              defaultButton: true,              handler: function {                 $('#mass-block-complete').closeModal;              }           }]        }); }      else { process(currentUser); }     pages = pages.slice(1,pages.length); txt.value = pages.join('\n'); }

function process(name) { var block = { action: 'block', user: name, reason: $('#block-reason').val || $('#block-reason').attr('placeholder'), expiry: $('#block-expiry').val || $('#block-expiry').attr('placeholder'), nocreate: '', allowusertalk: '', autoblock: 0, token: mw.user.tokens.values.editToken };     if (!$('#block-nocreate').attr('Checked')) delete block.nocreate;

if ($('#block-restrtp').attr('Checked')) delete block.allowusertalk;

new mw.Api.post(block) .done(function(d) {        if (!d.error) {          console.log(i18n.blockDone.replace('$1',name));        } 	else {          console.log(i18n.blockFail.replace('$1',name)+': '+ d.error.code);          $('#text-error-output').append(i18n.blockFail.replace('$1',name)+': '+d.error.code+' ');        }      }) .fail(function {       console.log(i18n.blockFail.replace('$1',name));        $('#text-error-output').append(i18n.blockFail.replace('$1',name)+' ');      }); setTimeout(init,delay); } } }) (this.jQuery, this.mediaWiki); //