Jump to content

MediaWiki:Gadget-libSensitiveIPs.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 03:32, 14 September 2016 (fix parameter name). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
( function ( $, mw, undefined ) {
	'use strict';
	var sensitiveIPs;
	sensitiveIPs = mw.libs.sensitiveips = {
		query: function ( args ) {
			if ( !( args instanceof Object ) ) {
				throw new TypeError( "type error in arg #1 to 'query' (object expected)" );
			}
			return mw.libs.lua.call( {
				format: 'json',
				module: 'Sensitive IP addresses/API',
				func: 'query',
				args: args
			} );
		},

		isSensitive: function ( s ) {
			return sensitiveIPs.query( { test: [ s ] } ).then( function ( data ) {
				return data.ips.length > 0;
			} );
		}
	};
} )( jQuery, mediaWiki );