mediawiki-extensions-AbuseF.../modules/ext.abuseFilter.tools.js
Marius Hoch 1958d74854 Fix AbuseFilter JS
Temp. fix, please look at https://gerrit.wikimedia.org/r/30110

Change-Id: Ic890a6f7b39618dba9f310244777e69435940cce
2012-10-26 16:21:08 +02:00

78 lines
1.9 KiB
JavaScript

// AbuseFilter tools JS
( function( $, mw ) {
// Reference to this
var that = this;
// Submits the expression to be evaluated
this.doExprSubmit = function() {
var expr = $( '#wpTestExpr' ).val();
$( this ).injectSpinner( 'abusefilter-expr' );
$.getJSON(
mw.util.wikiScript( 'api' ), {
action: 'abusefilterevalexpression',
expression: expr,
format: 'json'
}, that.processExprResult
);
};
// Processes the result of the evaluation
// @param {Object} data
this.processExprResult = function( data ) {
$.removeSpinner( 'abusefilter-expr' );
$( '#mw-abusefilter-expr-result' )
.text( data.abusefilterevalexpression.result );
};
// Submits a call to unblock autopromotions for a user
this.doReautoSubmit = function() {
var name = $( '#reautoconfirm-user' ).val();
if ( name === '' ) {
return;
}
$( this ).injectSpinner( 'abusefilter-reautoconfirm' );
$.post(
mw.util.wikiScript( 'api' ), {
action: 'abusefilterunblockautopromote',
user: name,
token: mw.user.tokens.get( 'editToken' ),
format: 'json'
}, that.processReautoconfirm, 'json'
);
};
// Processes the result of the unblocking autopromotions for a user
// @param {Object} data
this.processReautoconfirm = function( data ) {
var msg;
if ( data.error !== undefined ) {
switch ( data.error.code ) {
case 'permissiondenied':
msg = mw.msg( 'abusefilter-reautoconfirm-notallowed' );
break;
case 'notsuspended':
msg = data.error.info;
break;
}
} else {
msg = mw.message( 'abusefilter-reautoconfirm-done', data.abusefilterunblockautopromote.user ).toString();
}
mw.util.jsMessage( msg );
$.removeSpinner( 'abusefilter-reautoconfirm' );
};
$( function( $ ) {
$( '#mw-abusefilter-submitexpr' ).click( that.doExprSubmit );
$( '#mw-abusefilter-reautoconfirmsubmit' ).click( that.doReautoSubmit );
} );
} ( jQuery, mediaWiki ) );