MediaWiki:Gadget-libSensitiveIPs.js: Difference between revisions

Content deleted Content added
document the query function
 
(6 intermediate revisions by the same user not shown)
Line 26:
*
* mw.loader.using( [ 'ext.gadget.libSensitiveIPs' ], function () {
* mw.libs.sensitiveIPs.query( {
* test: [ '1.2.3.4', '5.6.7.8' ]
* } ).then( function ( result ) {
* // Do something with the result
* } );
Line 39 ⟶ 41:
* The MIT License (MIT)
*
* Copyright (c) 20152016 Mr. Stradivarius
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Line 103 ⟶ 105:
func: 'query',
args: [ params ]
} ).then( function ( data ) {
// Return a rejected promise if the Lua API reported an error.
return $.Deferred( function ( deferred ) {
if ( data.sensitiveips ) {
return deferred.resolve( data );
} else if ( data.error ) {
return deferred.reject( data.error.code, data );
} else {
return deferred.reject(
'libsips-unknown-api-error',
{ error: {
code: 'libsips-unknown-api-error',
info: 'unexpected API response from mw.libs.lua'
} }
);
}
} ).promise();
} );
}