Check titleblacklist

This commit is contained in:
theopolisme 2014-03-26 12:16:04 -05:00
parent bb3906d0eb
commit 6c3b4b2e3b
2 changed files with 19 additions and 7 deletions

View File

@ -141,7 +141,8 @@
// Load css
mw.loader.load( AFCH.consts.scriptpath + '?action=raw&ctype=text/css&title=MediaWiki:Gadget-afch.css', 'text/css' );
// Load dependencies
mw.loader.load( [ 'mediawiki.feedback', 'mediawiki.api', 'mediawiki.api.category', 'jquery.chosen', 'jquery.spinner' ] );
mw.loader.load( [ 'mediawiki.feedback', 'mediawiki.api', 'mediawiki.api.category', 'mediawiki.api.titleblacklist',
'jquery.chosen', 'jquery.spinner' ] );
}
// And finally load the subscript

View File

@ -1380,13 +1380,17 @@
}
page = new AFCH.Page( value );
AFCH.api.get( {
action: 'query',
prop: 'info',
inprop: 'protection',
titles: page.rawTitle
} ).done( function ( data ) {
$.when(
AFCH.api.isBlacklisted( page ),
AFCH.api.get( {
action: 'query',
prop: 'info',
inprop: 'protection',
titles: page.rawTitle
} )
).then( function ( isBlacklisted, rawData ) {
var errorHtml, buttonText,
data = rawData[0], // Get just the result, not the Promise object
linkToPage = AFCH.jQueryToHtml( AFCH.makeLinkElementToPage( page.rawTitle ) );
// If the page already exists, display an error
@ -1407,6 +1411,13 @@
} );
}
// Now check the blacklist result, but if another error already exists,
// don't bother showing this one too
if ( !errorHtml && isBlacklisted !== false ) {
errorHtml = 'Shoot! ' + isBlacklisted.reason.replace( /\s+/g, ' ' );
buttonText = 'The proposed title is blacklisted';
}
if ( !errorHtml ) {
return;
}