MediaWiki:Gadget-Massblock.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m mediawiki.util gestito da RL
+opzione per bloccare la talk anche qui
 
(24 versioni intermedie di uno stesso utente non sono mostrate)
Riga 5:
* Adapted from [[:en:User:Timotheus Canens/massblock.js]].
* Go to [[Special:Massblock]] to use it.
* If you want to add localized messages, add a localMsg variable after loading
* the script. See localMsg below.
*
* In order to use it, please IMPORT this page, and then add some code calling
* mw.messages.set with a list of localized messages if you wish. For an example,
* see [[:it:MediaWiki:Gadget-Massblock-it.js]]
*
* Memo: only then() can return a new promise object, done() and fail() can't.
*
* @author (i.e. blame him) [[:it:User:Daimona Eaytoy]]
* @todo This should handle the async loop more nicely, and properly use Promise
* rejections.
*/
( function( mw, $ ) {
'use strict';
 
// Default messages
mw.messages.set( {
'massblock-toolbar-text': 'Massblock',
'massblock-document-title': 'Mass-blocking tool - Wikipedia, the free encyclopedia',
'massblock-page-title': 'Mass-blocking tool',
'massblock-abuse-disclaimer': 'If you abuse this tool, it\'s your fault, not mine.',
'massblock-blockusers': 'Users to block (one on each line, please):',
'massblock-talkmsg': 'Replace talk page with, or text to add if the expiry is not infinite (leave blank to leave no message):',
'massblock-upmsg': 'Replace user page text with (leave blank for no change):',
'massblock-block-options-label': 'Block options',
'massblock-further-options-label': 'Further options',
'massblock-common-reasons': 'Common reasons:',
'massblock-other-reason': 'Other reason',
'massblock-extra-reason': 'Other/additional reason:',
'massblock-exptime': 'Expiration time, in english (blank for indefinite):',
'massblock-summary-default': 'Blocked user.',
'massblock-talksummary': 'Edit summary for talk page edit:',
'massblock-talkprotect': 'Protect the talk (sysop level, infinite):',
'massblock-upsummary': 'Edit summary for user page edit:',
'massblock-upprotect': 'Protect the user page (sysop level, infinite):',
'massblock-protect-reason-label': 'Reason for protection:',
'massblock-protect-reason-default': 'Blocked user.',
'massblock-anononly': 'Block anonymous users only (IPs only):',
'massblock-autoblock': 'Enable autoblock (accounts only):',
'massblock-nocreate': 'Block account creation:',
'massblock-noemail': 'Block email:',
'massblock-notalk': 'Remove talk page access:',
'massblock-override': 'Override existing blocks:',
'massblock-submit-text': 'Block',
'massblock-result-alert': 'Blocked $1 users. Edited $2 talk pages and $3 user pages. Protected $4 talk pages and $5 user pages.',
'massblock-failed-actions': 'Failed actions with errors:',
'massblock-failure-help': 'help',
'massblock-init-failure': 'Unable to load the Massblock gadget. Error:'
} );
 
// OOUI element
var submitBtn,
// LikeIdeally this would use $wgBlockAllowsUTEdit, but it's not available in JS.
blockAllowsTalkEdit; = true,
mwapi = new mw.Api();
 
// To add localized messages change the values of this variables. The english messages
// are in defaultMsg below.
var localMsg = {
'toolbar-text': 'Massblock',
'document-title': 'Il mass-blocker attira-trote',
'page-title': 'Il mass-blocker attira-trote',
'abuse-disclaimer': 'Se abusi di questo strumento, è colpa tua e non mia!',
'basic-data': 'Dati di base',
'blockusers': 'Utenti da bloccare (uno per riga):',
'talkmsg': 'Sostituisci la talk con, oppure aggiungi alla talk se il blocco non è infinito (lasciare vuoto per non modificare la talk):',
'upmsg': 'Sostituisci la pagina utente con (lasciare vuoto per non modificare la pagina utente):',
'block-options-label': 'Opzioni del blocco',
'further-options-label': 'Altre opzioni',
'common-reasons': 'Motivazioni comuni:',
'other-reason': 'Altra motivazione',
'extra-reason': 'Motivazione aggiuntiva:',
'exptime': 'Durata del blocco, in inglese (lasciare vuoto per blocco infinito):',
'summary-default': 'Utente bloccato.',
'talksummary': 'Oggetto per la modifica della talk:',
'talkprotect': 'Proteggi la talk:',
'upsummary': 'Oggetto per la modifica della pagina utente:',
'upprotect': 'Proteggi la pagina utente:',
'protect-reason-label': 'Motivazione per la protezione:',
'protect-reason-default': 'Utente bloccato.',
'anononly': 'Blocca solo utenti anonimi:',
'autoblock': 'Attiva autoblocco (solo per utenti registrati):',
'nocreate': 'Blocca la creazione di utenze:',
'noemail': 'Blocca email:',
'notalk': 'Blocca anche la modifica della talk:',
'override': 'Sovrascrivi eventuali blocchi:',
'submit-text': 'Scatena l\'inferno!',
'result-alert': 'Bloccati $1 utenti. Modificate $2 talk e $3 pagine utente. Protette $4 talk e $5 pagine utente.',
'failed-actions': 'Azioni non riuscite e relativi errori:',
'failure-help': 'aiuto'
};
 
// Default english messages. Don't change these!
var defaultMsg = {
'toolbar-text': 'Massblock',
'document-title': 'Mass-blocking tool - Wikipedia, the free encyclopedia',
'page-title': 'Mass-blocking tool',
'abuse-disclaimer': 'If you abuse this tool, it\'s your fault, not mine.',
'basic-data': 'Basic data',
'blockusers': 'Users to block (one on each line, please):',
'talkmsg': 'Replace talk page with, or text to add if the expiry is not infinite (leave blank to leave no message):',
'upmsg': 'Replace user page text with (leave blank for no change):',
'block-options-label': 'Block options',
'further-options-label': 'Further options',
'common-reasons': 'Common reasons:',
'other-reason': 'Other reason',
'extra-reason': 'Other/additional reason:',
'exptime': 'Expiration time, in english (blank for indefinite):',
'summary-default': 'Blocked user.',
'talksummary': 'Edit summary for talk page edit:',
'talkprotect': 'Protect the talk (sysop level, infinite):',
'upsummary': 'Edit summary for user page edit:',
'upprotect': 'Protect the user page (sysop level, infinite):',
'protect-reason-label': 'Reason for protection:',
'protect-reason-default': 'Blocked user.',
'anononly': 'Block anonymous users only (IPs only):',
'autoblock': 'Enable autoblock (accounts only):',
'nocreate': 'Block account creation:',
'noemail': 'Block email:',
'notalk': 'Remove talk page access:',
'override': 'Override existing blocks:',
'submit-text': 'Block',
'result-alert': 'Blocked $1 users. Edited $2 talk pages and $3 user pages. Protected $4 talk pages and $5 user pages.',
'failed-actions': 'Failed actions with errors:',
'failure-help': 'help'
};
 
/**
* Main form processing routine, called on form submit
*/
function doMassBlock() {
var users = $( "#wpMassBlockUsers textarea" ).val().split( "\n" );
 
// First trim everything
users = users.map( function( s ) {
return s.trim();
} );
// Then remove blanks and duplicates
users = users.filter( function( el, index, me ) {
return el !== '' && me.indexOf( el ) === index;
} );
if ( users.length === 0 ) {
// Easy
return;
}
submitBtn.setDisabled( true );
 
var wpMassBlockReasons = $( "#wpMassBlockReasons select :selected" ).val().trim(),
wpMassBlockReason = $( "#wpMassBlockReason input" ).val().trim(),
blocked = 0,
talkpageedited = 0,
userpageedited = 0,
talkpageprotected = 0,
userpageprotected = 0,
errors = {};
var wpMassBlockAnononly = $( "#wpMassBlockAnononly input" ).prop( 'checked' ),
wpMassBlockNocreate = $( "#wpMassBlockNocreate input" ).prop( 'checked' ),
wpMassBlockEmail = $( "#wpMassBlockEmail input" ).prop( 'checked' ),
wpMassBlockAutoblock = $( "#wpMassBlockAutoblock input" ).prop( 'checked' ),
wpMassBlockTalkpage = blockAllowsTalkEdit ? $( "#wpMassBlockTalkpage input" ).prop( 'checked' ) : false,
wpMassBlockReblock = $( "#wpMassBlockReblock input" ).prop( 'checked' );
var wpMassBlockMessage = $( "#wpMassBlockMessage textarea" ).val().trim(),
wpMassBlockTag = $( "#wpMassBlockTag textarea" ).val().trim(),
wpMassBlockExpiry = $( "#wpMassBlockExpiry input" ).val().trim();
var wpMassBlockSummaryTalk = $( "#wpMassBlockSummaryTalk input" ).val().trim(),
wpMassBlockSummaryUser = $( "#wpMassBlockSummaryUser input" ).val().trim(),
wpMassBlockProtectTalk = $( "#wpMassBlockProtectTalk input" ).prop( 'checked' ),
wpMassBlockProtectUser = $( "#wpMassBlockProtectUser input" ).prop( 'checked' );
 
var ErrorHandler = {
errors: {},
/**
* Process an error in any part of the process
Line 144 ⟶ 71:
* which has no hyphen and no page.
*/
var errorHandler =add: function( e, user, action ) {
var obj = { action: e };
objif ( !this.errors[ actionuser ] =) e;{
if ( ! this.errors[ user ] )= {[ obj ];
errors[ user ] = [ obj ];
} else {
this.errors[ user ].push( obj );
}
},
getCodesForUser: function( user ) {
var cb = function( el ) {
var key = Object.keys( el )[ 0 ],
action = key.split( "-" )[ 0 ],
link = '//mediawiki.org/wiki/API:' + action + '#Possible_errors';
return key + ': <code style="color:red">' +
el[ key ] + '</code> (<a href="' + link + '">' +
msg( 'failure-help' ) + '</a>)';
};
return this.errors[ user ].map( cb );
}
};
 
var FormData = {
init: function() {
this.dropdownReason = $( "#wpMassBlockReasons select :selected" ).val().trim();
this.otherReason = $( "#wpMassBlockReason input" ).val().trim();
this.anononly = $( "#wpMassBlockAnononly input" ).prop( 'checked' );
this.nocreate = $( "#wpMassBlockNocreate input" ).prop( 'checked' );
this.noEmail = $( "#wpMassBlockEmail input" ).prop( 'checked' );
this.autoblock = $( "#wpMassBlockAutoblock input" ).prop( 'checked' );
this.talkpageBlocked = blockAllowsTalkEdit ? $( "#wpMassBlockTalkpage input" ).prop( 'checked' ) : true;
this.reblock = $( "#wpMassBlockReblock input" ).prop( 'checked' );
this.talkMessage = $( "#wpMassBlockMessage textarea" ).val().trim();
this.expiry = $( "#wpMassBlockExpiry input" ).val().trim();
this.talkSummary = $( "#wpMassBlockSummaryTalk input" ).val().trim();
this.upSummary = $( "#wpMassBlockSummaryUser input" ).val().trim();
this.protectReason = $( "#wpMassBlockProtectReason input" ).val().trim();
 
this.isInfty = isInfinity( this.expiry );
};
// Several actions can only be executed if the block is infinite
this.protectTalk = $( "#wpMassBlockProtectTalk input" ).prop( 'checked' ) && this.isInfty;
this.protectUser = $( "#wpMassBlockProtectUser input" ).prop( 'checked' ) && this.isInfty;
this.upMessage = this.isInfty ? $( "#wpMassBlockTag textarea" ).val().trim() : '';
}
};
 
var Main = {
var isInfty = isInfinity( wpMassBlockExpiry );
blocked: 0,
// Several actions can only be executed if the block is infinite
talkpageedited: 0,
wpMassBlockProtectTalk = wpMassBlockProtectTalk && isInfty;
userpageedited: 0,
wpMassBlockProtectUser = wpMassBlockProtectUser && isInfty;
talkpageprotected: 0,
wpMassBlockTag = isInfty ? wpMassBlockTag : '';
userpageprotected: 0,
 
_protect: function( page, exists, counter, user ) {
var prType = exists ? 'edit=sysop|move=sysop' : 'create=sysop';
return doProtectPage( page, 'edit=sysop|move=sysop' )
.done( function() {
this[counter]++;
} )
.fail( function( e ) {
ErrorHandler.add( e, user, "protect-talk" );
} )
.always( function() {
return $.when();
} );
},
editTalk: function( user ) {
var talkPage = getTalkTitle( user );
return doEditPage( talkPage, FormData.talkMessage, FormData.talkSummary, !FormData.isInfty )
.then(
function() {
this.talkpageedited++;
if ( FormData.protectTalk ) {
return this._protect( talkPage, true, 'talkpageprotected', user );
}
}.bind( this ),
function( e ) {
ErrorHandler.add( e, user, "edit-talk" );
return $.when();
}
);
},
protectTalk: function( user ) {
var talkPage = getTalkTitle( user );
mwapi.get( {
action: 'query',
titles: talkPage
} )
.then(
function( data ) {
var exists = Object.keys( data.query.pages )[ 0 ] !== -1;
return this._protect( talkPage, exists, 'talkpageprotected', user );
}.bind( this ),
function( e ) {
ErrorHandler.add( e, user, "query-talk" );
return $.when();
}
);
},
editUP: function( user ) {
var userPage = getUPTitle( user );
doEditPage( userPage, FormData.upMessage, FormData.upSummary )
.then(
function() {
this.userpageedited++;
if ( FormData.protectUser ) {
return this._protect( userPage, true, 'userpageprotected', user );
}
}.bind( this ),
function( e ) {
ErrorHandler.add( e, user, "edit-user" );
return $.when();
}
);
},
protectUP: function( user ) {
var userPage = getUPTitle( user );
return mwapi.get( {
action: 'query',
titles: userPage
} )
.then(
function( data ) {
var exists = Object.keys( data.query.pages )[ 0 ] !== -1;
return this._protect( userPage, exists, 'userpageprotected', user );
}.bind( this ),
function( e ) {
ErrorHandler.add( e, user, "query-user" );
return $.when();
}
);
},
getAlertText: function() {
return msg( 'result-alert' )
.replace( '$1', this.blocked )
.replace( '$2', this.talkpageedited )
.replace( '$3', this.userpageedited )
.replace( '$4', this.talkpageprotected )
.replace( '$5', this.userpageprotected );
}
};
 
function getTalkTitle( user ) {
/**
return 'User talk:' + user;
* Perform a single block via API
}
*
* @param {string} user The user to block
function getUPTitle( user ) {
* @return {Promise}
return 'User:' + user;
*/
}
var doBlock = function( user ) {
return new mw.Api().postWithToken( "csrf", {
action: 'block',
allowusertalk: wpMassBlockTalkpage,
autoblock: wpMassBlockAutoblock,
nocreate: wpMassBlockNocreate,
expiry: wpMassBlockExpiry === "" ? "indefinite" : wpMassBlockExpiry,
anononly: wpMassBlockAnononly,
noemail: wpMassBlockEmail,
reblock: wpMassBlockReblock,
reason: wpMassBlockReasons === "other" ? wpMassBlockReason : wpMassBlockReasons + ( wpMassBlockReason ? ": " + wpMassBlockReason : "" ),
user: user
} );
};
 
/**
* The post-block handler. Performs edits and protections.
*
* @param {Objectstring} response The response of the block API calluser
* @return {Promise} A promise which is resolved after all actions are done
* for all pages. This will never be rejected.
*/
var function successHandler = function( responseuser ) {
// @var {Promise} These track the state for all actions (edit and protect)
var user = response.block.user,
// on every page. They are resolved as soon as a page is processed, with or
talkPage = 'User talk:' + user,
// without a failure. This way the final $.when will resolve after all promises
userPage = 'User:' + user,
// have been processed, and not after the first rejection.
// @var {Promise} These track the state for all actions (edit and protect)
var talkDone, userDone;
// on every page. They are resolved as soon as a page is processed, with or
// without a failure. This way the final $.when will resolve after all promises
// have been processed, and not after the first rejection.
talkDone = $.Deferred(),
userDone = $.Deferred();
 
Main.blocked++;
 
if ( wpMassBlockMessageFormData.talkMessage !== "" ) {
talkDone = Main.editTalk( user );
doEditPage( talkPage, wpMassBlockMessage, wpMassBlockSummaryTalk, !isInfty )
} else if ( FormData.protectTalk ) {
.done( function() {
talkDone = Main.protectTalk( user );
talkpageedited++;
} else {
if ( wpMassBlockProtectTalk ) {
talkDone = $.when();
doProtectPage( talkPage, 'edit=sysop|move=sysop' )
}
.done( function() {
talkpageprotected++;
} )
.fail( function( e ) {
errorHandler( e, user, "protect-talk" );
} )
.always( function() {
talkDone.resolve();
} );
} else {
talkDone.resolve();
}
} )
.fail( function( e ) {
errorHandler( e, user, "edit-talk" );
talkDone.resolve();
} );
} else if ( wpMassBlockProtectTalk ) {
new mw.Api().get( {
action: 'query',
titles: talkPage
} )
.then( function( data ) {
var exists = Object.keys( data.query.pages )[ 0 ] !== -1,
prType = exists ? 'edit=sysop|move=sysop' : 'create=sysop';
doProtectPage( talkPage, prType )
.done( function() {
talkpageprotected++;
} )
.fail( function( e ) {
errorHandler( e, user, "protect-talk" );
} )
.always( function() {
talkDone.resolve();
} );
} )
.fail( function( e ) {
errorHandler( e, user, "query-talk" );
talkDone.resolve();
} );
} else {
talkDone.resolve();
}
 
if ( wpMassBlockTagFormData.upMessage !== "" ) {
userDone = Main.editUP( user );
doEditPage( userPage, wpMassBlockTag, wpMassBlockSummaryUser )
} else if ( FormData.protectUser ) {
.done( function() {
userDone = Main.protectUP( user );
userpageedited++;
} else {
if ( wpMassBlockProtectUser ) {
userDone = $.when();
doProtectPage( userPage, 'edit=sysop|move=sysop' )
}
.done( function() {
userpageprotected++;
} )
.fail( function( e ) {
errorHandler( e, user, "protect-user" );
} )
.always( function() {
userDone.resolve();
} );
} else {
userDone.resolve();
}
} )
.fail( function( e ) {
errorHandler( e, user, "edit-user" );
userDone.resolve();
} );
} else if ( wpMassBlockProtectUser ) {
new mw.Api().get( {
action: 'query',
titles: userPage
} )
.then( function( data ) {
var exists = Object.keys( data.query.pages )[ 0 ] !== -1,
prType = exists ? 'edit=sysop|move=sysop' : 'create=sysop';
doProtectPage( userPage, prType )
.done( function() {
userpageprotected++;
} )
.fail( function( e ) {
errorHandler( e, user, "protect-user" );
} )
.always( function() {
userDone.resolve();
} );
} )
.fail( function( e ) {
errorHandler( e, user, "query-user" );
userDone.resolve();
} );
} else {
userDone.resolve();
}
 
return $.when( talkDone, userDone );
};
 
/**
* Main form processing routine, called on form submit
*/
function doMassBlock() {
var users = $( "#wpMassBlockUsers textarea" ).val().split( "\n" );
 
users = users
// First trim everything
.map( function( s ) {
return s.trim();
} )
// Then remove blanks and duplicates
.filter( function( el, index, me ) {
return el !== '' && me.indexOf( el ) === index;
} );
 
if ( users.length === 0 ) {
// Easy
return;
}
submitBtn.setDisabled( true );
 
FormData.init();
 
// Array of Promises, one for each user. Each one is resolved after the user
Line 314 ⟶ 288:
deferreds.push(
doBlock( user )
.then(
function( data ) {
return successHandler( datauser );
},
function( e ) {
errorHandler ErrorHandler.add( e, user, "block" );
// Return so that this counts as resolved and won't leave
// other promises unresolved.
return $.when();
}
)
);
} );
 
$.when.apply( $, deferreds ).always( function()doPostBlockActions {);
doPostBlockActions( errors );
OO.ui.alert(
msg( 'result-alert' ).replace( '$1', blocked ).replace( '$2', talkpageedited ).replace( '$3', userpageedited )
.replace( '$4', talkpageprotected ).replace( '$5', userpageprotected )
);
} );
}
 
/**
* 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 ) {
var errors = ErrorHandler.errors;
if ( Object.keys( errors ).length > 0 ) {
var linkedList = ""'';
 
var errorsToCodes = function( el ) {
var key = Object.keys( el )[ 0 ],
action = key.split( "-" )[ 0 ],
link = '//mediawiki.org/wiki/API:' + action + '#Possible_errors';
return key + ': <code style="color:red">' +
el[ key ] + '</code> (<a href="' + link + '">' +
msg( 'failure-help' ) + '</a>)';
};
 
for ( var user in errors ) {
var codes = errors[ user ]ErrorHandler.mapgetCodesForUser( errorsToCodesuser );
linkedList +=
"<li><a href=\"" + mw.config.get( 'wgScript' ) + "?title=Special:Contributions/" + encodeURIComponent( user ) + "\">" + user + "</a>: " +
user + "</a>: " + codes.join( "; " ) + "</li>";
}
$( "#wpMassBlockFailedContainer" ).html(
Line 365 ⟶ 323:
);
}
 
OO.ui.alert( Main.getAlertText() );
}
 
/**
* Perform a single block via API
*
* @param {string} user The user to block
* @return {Promise}
*/
function doBlock( user ) {
return mwapi.postWithToken( "csrf", {
action: 'block',
allowusertalk: !FormData.talkpageBlocked,
autoblock: FormData.autoblock,
nocreate: FormData.nocreate,
expiry: FormData.expiry === "" ? "indefinite" : FormData.expiry,
anononly: FormData.anononly,
noemail: FormData.noEmail,
reblock: FormData.reblock,
reason: FormData.dropdownReason === "other" ? FormData.otherReason : FormData.dropdownReason + ( FormData.otherReason ? ": " + FormData.otherReason : "" ),
user: user
} );
}
 
Line 389 ⟶ 370:
params.text = text;
}
return new mw.Api()mwapi.postWithEditToken( params );
}
 
Line 400 ⟶ 381:
*/
function doProtectPage( title, protections ) {
return new mw.Api()mwapi.postWithToken( 'csrf', {
action: 'protect',
title: title,
protections: protections,
reason: $( "#wpMassBlockProtectReason input" )FormData.val().trim()protectReason,
watchlist: 'nochange'
} );
Line 416 ⟶ 397:
*/
function msg( msg ) {
return localMsg[mw.messages.get( msg ] ||'massblock-' defaultMsg[+ msg ]);
}
 
Line 427 ⟶ 408:
talkTextField, userTextField, talkProtectCb, talkSummaryField,
userSummaryField, userProtectCb, protectReasonField;
 
// Ideally this would use $wgBlockAllowsUTEdit, but it's not available.
blockAllowsTalkEdit = window.___location.href.indexOf( 'it.wikipedia' ) === -1;
 
$( "h1" ).first().html( msg( 'page-title' ) );
Line 446 ⟶ 424:
} );
 
var basicFieldsetmainField = new OO.ui.FieldsetLayout( {
label: msg( 'basic-datablockusers' ),
items: [
new OO.ui.FieldLayoutMultilineTextInputWidget( {
rows: 10,
new OO.ui.MultilineTextInputWidget( {
rowsid: 10'wpMassBlockUsers'
} ), {
label: msg( 'blockusers' ),
align: 'top',
id: 'wpMassBlockUsers'
}
),
new OO.ui.FieldLayout(
talkTextField, {
label: msg( 'talkmsg' ),
align: 'top',
id: 'wpMassBlockMessage'
}
),
new OO.ui.FieldLayout( userTextField, {
label: msg( 'upmsg' ),
align: 'top',
id: 'wpMassBlockTag'
} )
]
Line 608 ⟶ 569:
} );
 
userTextField.on(var 'change',toggleUserTextField = function() {
userSummaryField.setDisabled(var disabled = userTextField.getValue().trim() === '' );||
!isInfinity( $( '#wpMassBlockExpiry input' ).val().trim() );
} );
userSummaryField.setDisabled( disabled );
};
 
userTextField.on( 'change', toggleUserTextField );
 
talkProtectCb =
new OO.ui.CheckboxInputWidget( {
id: 'wpMassBlockProtectTalk',
selected: true
} );
 
userProtectCb =
new OO.ui.CheckboxInputWidget( {
id: 'wpMassBlockProtectUser',
selected: true
} );
 
Line 628 ⟶ 591:
maxLength: 255,
id: 'wpMassBlockProtectReason',
value: msg( 'protect-reason-default' ),
disabled: true
} );
 
Line 635 ⟶ 599:
*/
var toggleProtectionFields = function() {
if (
if ( !talkProtectCb.isSelected() && !userProtectCb.isSelected() ) {
!( talkProtectCb.isSelected() || userProtectCb.isSelected() ) ||
!isInfinity( $( '#wpMassBlockExpiry input' ).val().trim() )
) {
protectReasonField.setDisabled( true );
} else {
Line 648 ⟶ 615:
label: msg( 'further-options-label' ),
items: [
new OO.ui.HorizontalLayout( {
items: [
new OO.ui.FieldLayout(
talkTextField,
{
label: msg( 'talkmsg' ),
align: 'top',
id: 'wpMassBlockMessage',
classes: [ 'massblock-horiz-element' ]
}
),
new OO.ui.FieldLayout(
userTextField,
{
label: msg( 'upmsg' ),
align: 'top',
id: 'wpMassBlockTag',
classes: [ 'massblock-horiz-element' ]
}
)
]
} ),
new OO.ui.FieldLayout( talkSummaryField, {
label: msg( 'talksummary' )
Line 673 ⟶ 662:
userTextField,
talkProtectCb,
userSummaryField,userProtectCb
userProtectCb,
protectReasonField
];
 
Line 681 ⟶ 668:
disableEls[ el ].setDisabled( !enable );
}
 
toggleProtectionFields();
toggleUserTextField();
} );
 
Line 694 ⟶ 684:
.on( 'click', doMassBlock );
 
form.addItems( [ basicFieldsetmainField, blockOpts, furtherOpts, new OO.ui.FieldLayout( submitBtn ) ] );
 
 
Line 714 ⟶ 704:
$( function() {
if ( mw.config.get( "wgNamespaceNumber" ) === -1 &&
( mw.config.get( "wgTitle" ) === "Massblock" || mw.config.get( "wgTitle" ) === "MassBlock" ) &&
( /sysop/ ).test( mw.config.get( "wgUserGroups" ) )
) {
var style ='.massblock-horiz-element{ width: 40%; }';
mw.loader.using( [ 'mediawiki.api', 'mediawiki.jqueryMsg', 'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows' ], $.ready )
mw.thenutil.addCSS( functionstyle loadMsg() {;
mw.loader.using( [ 'mediawiki.jqueryMsg', 'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows' ], $.ready )
return new mw.Api().loadMessagesIfMissing( [ 'Ipbreason-dropdown' ] );
.done( function loadMsg() {
mwapi.loadMessagesIfMissing( [ 'Ipbreason-dropdown' ] )
.done( massblockform )
.fail( function ( e ) {
mw.log.error( msg( 'init-failure' ) + ' ' + e );
} );
} )
.thenfail( massblockformfunction ( e ); {
mw.log.error( msg( 'init-failure' ) + ' ' + e );
} );
} else {
mw.util.addPortletLink( 'p-tb', mw.configutil.getgetUrl( 'wgScript' ) + '?title=Special:Massblock' ), msg( 'toolbar-text' ) );
}
} );