Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.mwsuggest.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | var $container = $( '<div>', { 'class' : 'open-search-suggestions' } ), |
4 | 4 | cache = {}, |
5 | 5 | $suggestionList, |
6 | | - url = mw.config.get( 'wgScriptPath' ) + '/api.php?format=json&action=opensearch&search=', |
| 6 | + url = mw.util.wikiScript( 'api' ), |
7 | 7 | maxRowWindow; |
8 | 8 | |
9 | 9 | //Append the container which will hold the menu to the body |
— | — | @@ -14,19 +14,19 @@ |
15 | 15 | */ |
16 | 16 | var getNamespaces = function() { |
17 | 17 | var namespaces = []; |
18 | | - $('form#powersearch, form#search').find( '[name^="ns"]' ).each(function() { |
| 18 | + $( 'form#powersearch, form#search' ).find( '[name^="ns"]' ).each(function() { |
19 | 19 | if ( this.checked || ( this.type == 'hidden' && this.value == '1' ) ) { |
20 | 20 | namespaces.push( this.name.substring( 2 ) ); |
21 | 21 | } |
22 | 22 | }); |
23 | 23 | if ( !namespaces.length ) { |
24 | | - namespaces = mw.config.get('wgSearchNamespaces'); |
| 24 | + namespaces = mw.config.get( 'wgSearchNamespaces' ); |
25 | 25 | } |
26 | 26 | return namespaces.join('|'); |
27 | 27 | }; |
28 | 28 | |
29 | 29 | /* Helper function to make sure that the list doesn't expand below the visible part of the window */ |
30 | | - var deliverResult = function( obj, response, maxRowWindow ) { |
| 30 | + var deliverResult = function( obj, response ) { |
31 | 31 | if ( obj && obj.length > 1 ) { |
32 | 32 | response( obj[1] ); |
33 | 33 | // Get the lowest from multiple numbers using fn.apply |
— | — | @@ -45,13 +45,19 @@ |
46 | 46 | // We're caching queries for performance |
47 | 47 | var term = request.term + namespaces; |
48 | 48 | if ( term in cache ) { |
49 | | - deliverResult( cache[term], response, maxRowWindow ); |
| 49 | + deliverResult( cache[term], response ); |
50 | 50 | return; |
51 | 51 | } |
52 | | - $.getJSON( url + mw.util.rawurlencode( request.term ) + '&namespace=' + namespaces, function ( obj ) { |
| 52 | + var params = { |
| 53 | + format : 'json', |
| 54 | + action : 'opensearch', |
| 55 | + search : request.term, |
| 56 | + namespaces : namespaces |
| 57 | + }; |
| 58 | + $.getJSON( url, params, function ( obj ) { |
53 | 59 | // Save to cache |
54 | 60 | cache[ term ] = obj; |
55 | | - deliverResult( obj, response, maxRowWindow ); |
| 61 | + deliverResult( obj, response ); |
56 | 62 | }); |
57 | 63 | }, |
58 | 64 | select : function() { |