MediaWiki:Gadget-libSensitiveIPs.js: Difference between revisions
Content deleted Content added
add top comment |
document the query function |
||
Line 62:
( function ( $, mw, undefined ) {
'use strict';
sensitiveIPs = mw.libs.sensitiveIPs = {▼
/**
* Query the API
* @param {Object} params - API query parameters
*
* @param {string[]} options.test - IP addresses or IP ranges to test for
* sensitivity.
*
* @param {string[]} options.entities - Entity IDs to display data for.
* "Entities" are countries or organizations whose IPs are deemed
* sensitive by Wikipedia. Entity IDs are defined in
* https://en.wikipedia.org/wiki/Module:Sensitive_IP_addresses/list.
*
* @return {$.Promise}
* A jQuery Promise that is resolved with the query result, as a
* JavaScript object. For the structure of the query results, see
* https://en.wikipedia.org/wiki/Module:Sensitive_IP_addresses/API#Results.
*
@example
// Find whether the IP "1.2.3.4" is sensitive.
mw.loader.using( 'ext.gadget.libSensitiveIPs', function () {
"test": [ "1.2.3.4" ]
} ).done( function( data ) {
} );▼
} );
*
*/
query: function ( params ) {
if ( !( params instanceof Object ) ) {
Line 74 ⟶ 103:
func: 'query',
args: [ params ]
▲ } );
▲ },
▲ return data.sensitiveips.matches.length > 0;
} );
}
|