Utente:Daimona Eaytoy/Massblock.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Ci siamo quasi
m Qualche ritocco
Riga 1:
/* jshint maxerr: 10000, esversion:6 */
/* global mediaWiki, jQuery, OO */
/**
* Tool for mass-blocking a list of IPs/users.
Riga 6 ⟶ 7:
* Overwrite values in localMsg below to localize.
*
* @todo docs!!, better i18n
* @author (i.e. blame him) https://it.wikipedia.org/wiki/User:Daimona_Eaytoy
*/
( function( mw, $ ) {
'use strict';
 
// OOUI element
var submitBtn,
Riga 15 ⟶ 19:
 
// To add local messages change the values of this variables.
var localMsg = {
'document-title': 'Il mass-blocker attira-trote',
'page-title': 'L\'attira-trote',
Riga 90 ⟶ 94:
wpMassBlockProtectUser = $( "#wpMassBlockProtectUser input" ).prop( 'checked' );
 
/**
* Process an error in any part of the process
*
* @param {string} e The error code
* @param {string} user The user we're processing
* @param {string} action The action we're doing. This is of the form
* {$actionname}-{$page}, where $action name is the name of the API module
* being used (e.g. 'block' or 'edit') and $page is either 'talk' or 'user',
* representing the target of the action. The only special case is 'block',
* which has no hyphen and no page.
*/
var errorHandler = function( e, user, action ) {
var obj = {};
Riga 109 ⟶ 124:
 
 
/**
* Perform a single block via API
*
* @param {string} user The user to block
* @return {Promise}
*/
var doBlock = function( user ) {
return new mw.Api().postWithToken( "csrf", {
Riga 124 ⟶ 145:
};
 
/**
* The post-block handler. Performs edits and protections.
*
* @param {Object} response The response of the block API call
* @return {Promise} A promise which is resolved after all actions are done
* for all pages. This will never be rejected.
*/
var successHandler = function( response ) {
let user = response.block.user,
Riga 240 ⟶ 268:
};
 
// Array of Promises, one for each user. Each one is resolved after the user
// is processed, even in case of failure.
var deferreds = [];
 
for ( let i = 0; i < users.length; i++ ) {
let user = users[ i ];
 
Riga 272 ⟶ 302:
/**
* Executed after all users have been processed.
*
* @param {Object} errors The errors collected on the way. The structure of
* this object is { username: [ { action: errorcode }, ... ], ... }
*/
function doPostBlockActions( errors ) {
Riga 298 ⟶ 331:
 
/**
* Edit the given page.
*
* @param {string} title The title of the page
* @param {string} text The text to add
* @param {string} summary The summary to use
* @param {bool} append Whether to append the text or replace the whole page content
* @return {Promise}
*/
function doEditPage( title, text, summary, append ) {
Riga 318 ⟶ 357:
/**
* Protect the given page
*
* @param {string} title The page to protect
* @param {string} protections As accepted by the Protect API module
* @return {Promise}
*/
function doProtectPage( title, protections ) {
Riga 364 ⟶ 407:
/**
* Get a localised messages, or the default one as fallback.
*
* @param {string} msg The key of the message to get
* @return {string}
*/
function msg( msg ) {
Riga 654 ⟶ 700:
/**
* Utility function to tell if an expiry is infinite
*
* @param {string} expiry
* @return {bool}
*/
function isInfinity( expiry ) {