MediaWiki:Gadget-SearchAll.js

( function ( $ ) {	var typingTimer;	var doneTypingInterval = 1000;	var $input = $( 'input#searchInput' );

// XSS preventation function encodeHTML( s ) { return s.replace( /&/g, '&amp;' ).replace( /</g, '&lt;' ).replace( /"/g, '&quot;' );	}	$input.on( 'keyup', function {		clearTimeout( typingTimer );		typingTimer = setTimeout( doneTyping, doneTypingInterval );	} );	$input.on( 'keydown', function  {		clearTimeout( typingTimer );	} );

function doneTyping { var searchText = $( 'input#searchInput' ).val; $.get( 'https://famedata.org/w/api.php?action=opensearch&format=json&formatversion=2&search=' + encodeHTML( searchText ) + '&namespace=1|2|3|4|5|8|9|10|11|12|13|14|15|120|121|122|123|828|829|1198|1199|2300|2301|2302|2303|2600&limit=10&suggest=true', function ( data ) {			if ( data && data[ 1 ] && data[ 1 ].length ) {				var res = '';				$( '.itssoawesome' ).remove;				for ( var i = 0; i < data[ 1 ].length; i++ ) {					res += '' + encodeHTML( data[ 1 ][ i ] ) + '';				}				$( 'li.wb-entitysearch-suggestions' ).before( res );			}		} ); }

}( jQuery ) );