| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
( function () { |
| 5 |
|
| 6 |
Object.assign( mw.Api.prototype, { |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
isBlacklisted: function ( title, ok, err ) { |
| 20 |
var d = $.Deferred(); |
| 21 |
|
| 22 |
d.done( ok ); |
| 23 |
d.fail( err ); |
| 24 |
|
| 25 |
this.get( { |
| 26 |
action: 'titleblacklist', |
| 27 |
tbaction: 'create', |
| 28 |
tbtitle: title.toString(), |
| 29 |
errorformat: 'html', |
| 30 |
errorlang: mw.config.get( 'wgUserLanguage' ), |
| 31 |
errorsuselocal: '', |
| 32 |
formatversion: 2 |
| 33 |
} ) |
| 34 |
.done( function ( data ) { |
| 35 |
var result; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
if ( data.titleblacklist && data.titleblacklist.result && data.titleblacklist.result === 'blacklisted' ) { |
| 41 |
if ( data.titleblacklist.reason ) { |
| 42 |
result = { |
| 43 |
reason: data.titleblacklist.reason, |
| 44 |
line: data.titleblacklist.line, |
| 45 |
message: data.titleblacklist.message |
| 46 |
}; |
| 47 |
} else { |
| 48 |
mw.log( 'mw.Api.titleblacklist::isBlacklisted> no reason data for blacklisted title', 'debug' ); |
| 49 |
result = { |
| 50 |
reason: 'Blacklisted, but no reason supplied', |
| 51 |
line: 'Unknown', |
| 52 |
message: null |
| 53 |
}; |
| 54 |
} |
| 55 |
d.resolve( result ); |
| 56 |
} else { |
| 57 |
d.resolve( false ); |
| 58 |
} |
| 59 |
} ) |
| 60 |
.fail( d.reject ); |
| 61 |
|
| 62 |
return d.promise(); |
| 63 |
} |
| 64 |
|
| 65 |
} ); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
}() ); |