2 * @class mw.Api.plugin.titleblacklist
6 $.extend( mw
.Api
.prototype, {
8 * Convinience method for `action=titleblacklist`.
9 * Note: This action is not provided by MediaWiki core, but as part of the TitleBlacklist extension.
11 * @param {mw.Title|string} title
12 * @param {Function} [ok] Success callback (deprecated)
13 * @param {Function} [err] Error callback (deprecated)
14 * @return {jQuery.Promise}
15 * @return {Function} return.done
16 * @return {Object|boolean} return.done.result False if title wasn't blacklisted, an object with 'reason', 'line'
17 * and 'message' properties if title was blacklisted.
19 isBlacklisted: function ( title
, ok
, err
) {
21 // Backwards compatibility (< MW 1.20)
26 action
: 'titleblacklist',
28 tbtitle
: title
.toString()
30 .done( function ( data
) {
33 // this fails open (if nothing valid is returned by the api, allows the title)
34 // also fails open when the API is not present, which will be most of the time
35 // as this API module is part of the TitleBlacklist extension.
36 if ( data
.titleblacklist
&& data
.titleblacklist
.result
&& data
.titleblacklist
.result
=== 'blacklisted' ) {
37 if ( data
.titleblacklist
.reason
) {
39 reason
: data
.titleblacklist
.reason
,
40 line
: data
.titleblacklist
.line
,
41 message
: data
.titleblacklist
.message
44 mw
.log( 'mw.Api.titleblacklist::isBlacklisted> no reason data for blacklisted title', 'debug' );
46 reason
: 'Blacklisted, but no reason supplied',
65 * @mixins mw.Api.plugin.titleblacklist
68 }( mediaWiki
, jQuery
) );