2 * Additional mw.Api methods to assist with API calls to the API module of the TitleBlacklist extension.
5 ( function( $, mw
, undefined ) {
7 $.extend( mw
.Api
.prototype, {
9 * Convinience method for 'action=titleblacklist'.
10 * Note: This action is not provided by MediaWiki core, but as part of the TitleBlacklist extension.
12 * @param title {mw.Title}
13 * @param success {Function} Called on successfull request. First argument is false if title wasn't blacklisted,
14 * object with 'reason', 'line' and 'message' properties if title was blacklisted.
15 * @param err {Function} optional callback to run if api error
18 isBlacklisted: function( title
, success
, err
) {
20 action
: 'titleblacklist',
22 tbtitle
: title
.toString()
24 ok = function( data
) {
27 // this fails open (if nothing valid is returned by the api, allows the title)
28 // also fails open when the API is not present, which will be most of the time
29 // as this API module is part of the TitleBlacklist extension.
30 if ( data
.titleblacklist
&& data
.titleblacklist
.result
&& data
.titleblacklist
.result
=== 'blacklisted') {
31 if ( data
.titleblacklist
.reason
) {
33 reason
: data
.titleblacklist
.reason
,
34 line
: data
.titleblacklist
.line
,
35 message
: data
.titleblacklist
.message
38 mw
.log('mw.Api.titleblacklist::isBlacklisted> no reason data for blacklisted title', 'debug');
39 result
= { reason
: 'Blacklisted, but no reason supplied', line
: 'Unknown', message
: null };
47 return this.get( params
, { ok
: ok
, err
: err
} );
51 } )( jQuery
, mediaWiki
);