User:קיפודנחש/CuteSearch.js

if ( mw.user.options.get( 'skin' ) === 'vector' ) $(function { setTimeout( function { 'use strict'; var $searchBoxes = $( '#searchInput, #searchInput2, #powerSearchText, #searchText' ); if(!$searchBoxes.suggestions) return; $searchBoxes.suggestions( {       fetch: function( query ) {            var $this = $( this );            if ( query.length !== 0 ) {                var params = {                    action: 'opensearch',                    search: query,                    suggest: ''                };                $.ajax( { data: params, url: mw.util.wikiScript('api'), dataType: 'json', success: function( data ) { if ($.isArray( data ) && 1 in data) { var orig = data[1]; $this.suggestions( 'suggestions', orig ); if ( data[1].length < 10 ) { params.search = query.replace( /^{{/, 'Template:' ); if ( params.search === query ) return; params.limit = 10 - data[1].length; $.ajax({                                   data: params,                                    url: mw.util.wikiScript('api'),                                    dataType: 'json',                                    success: function( data ) {                                        if ( $.isArray( data ) && 1 in data )                                             $this.suggestions( 'suggestions', orig.concat( data[1] ) );                                    }                                }); }                       }                    }                } );            }        }    }); }, 1200); // setTimeout }); // document.ready