mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Inline/simplify smaller pieces of JavaScript code
The check if $() found an element is not needed. Method calls will operate happily on an empty result and do nothing, as expected. Change-Id: I985ac4623d7968f037613174b14348885afed7d1
This commit is contained in:
parent
1ed871a090
commit
e73f2076ad
|
@ -81,19 +81,14 @@
|
|||
params = {
|
||||
action: 'abusefiltercheckmatch',
|
||||
filter: filter
|
||||
},
|
||||
api = new mw.Api();
|
||||
};
|
||||
|
||||
$( this ).injectSpinner( { id: 'filter-check', size: 'large' } );
|
||||
|
||||
if ( examine.type === 'rc' ) {
|
||||
params.rcid = examine.id;
|
||||
} else {
|
||||
params.logid = examine.id;
|
||||
}
|
||||
params[ examine.type === 'rc' ? 'rcid' : 'logid' ] = examine.id;
|
||||
|
||||
// Use post due to the rather large amount of data
|
||||
api.post( params )
|
||||
new mw.Api().post( params )
|
||||
.done( examinerTestProcess )
|
||||
.fail( examinerTestProcessFailure );
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
* @param {jQuery.Event} e The event fired when the function is called
|
||||
*/
|
||||
function doExprSubmit( e ) {
|
||||
var expr = $( '#wpFilterRules' ).val(),
|
||||
api = new mw.Api();
|
||||
var expr = $( '#wpFilterRules' ).val();
|
||||
|
||||
$( this ).injectSpinner( { id: 'abusefilter-expr', size: 'large' } );
|
||||
|
||||
api.post( {
|
||||
new mw.Api().post( {
|
||||
action: 'abusefilterevalexpression',
|
||||
expression: expr,
|
||||
prettyprint: 1
|
||||
|
@ -106,8 +106,7 @@
|
|||
*/
|
||||
function doReautoSubmit() {
|
||||
var nameField = OO.ui.infuse( $( '#reautoconfirm-user' ) ),
|
||||
name = nameField.getValue(),
|
||||
api;
|
||||
name = nameField.getValue();
|
||||
|
||||
if ( name === '' ) {
|
||||
return false;
|
||||
|
@ -115,8 +114,7 @@
|
|||
|
||||
$( this ).injectSpinner( { id: 'abusefilter-reautoconfirm', size: 'large' } );
|
||||
|
||||
api = new mw.Api();
|
||||
api.post( {
|
||||
new mw.Api().post( {
|
||||
action: 'abusefilterunblockautopromote',
|
||||
user: name,
|
||||
token: mw.user.tokens.get( 'csrfToken' )
|
||||
|
@ -128,8 +126,6 @@
|
|||
|
||||
$( function initialize() {
|
||||
$( '#mw-abusefilter-submitexpr' ).on( 'click', doExprSubmit );
|
||||
if ( $( '#mw-abusefilter-reautoconfirmsubmit' ).length ) {
|
||||
$( '#mw-abusefilter-reautoconfirmsubmit' ).on( 'click', doReautoSubmit );
|
||||
}
|
||||
$( '#mw-abusefilter-reautoconfirmsubmit' ).on( 'click', doReautoSubmit );
|
||||
} );
|
||||
}() );
|
||||
|
|
Loading…
Reference in a new issue