r93383 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93382‎ | r93383 | r93384 >
Date:11:22, 28 July 2011
Author:diebuche
Status:reverted (Comments)
Tags:
Comment:
r91728 : Fix a problem for api.php5 users and remove an unneeded function parameter from deliverResult
Modified paths:
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.mwsuggest.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.mwsuggest.js
@@ -2,7 +2,7 @@
33 var $container = $( '<div>', { 'class' : 'open-search-suggestions' } ),
44 cache = {},
55 $suggestionList,
6 - url = mw.config.get( 'wgScriptPath' ) + '/api.php?format=json&action=opensearch&search=',
 6+ url = mw.util.wikiScript( 'api' ),
77 maxRowWindow;
88
99 //Append the container which will hold the menu to the body
@@ -14,19 +14,19 @@
1515 */
1616 var getNamespaces = function() {
1717 var namespaces = [];
18 - $('form#powersearch, form#search').find( '[name^="ns"]' ).each(function() {
 18+ $( 'form#powersearch, form#search' ).find( '[name^="ns"]' ).each(function() {
1919 if ( this.checked || ( this.type == 'hidden' && this.value == '1' ) ) {
2020 namespaces.push( this.name.substring( 2 ) );
2121 }
2222 });
2323 if ( !namespaces.length ) {
24 - namespaces = mw.config.get('wgSearchNamespaces');
 24+ namespaces = mw.config.get( 'wgSearchNamespaces' );
2525 }
2626 return namespaces.join('|');
2727 };
2828
2929 /* 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 ) {
3131 if ( obj && obj.length > 1 ) {
3232 response( obj[1] );
3333 // Get the lowest from multiple numbers using fn.apply
@@ -45,13 +45,19 @@
4646 // We're caching queries for performance
4747 var term = request.term + namespaces;
4848 if ( term in cache ) {
49 - deliverResult( cache[term], response, maxRowWindow );
 49+ deliverResult( cache[term], response );
5050 return;
5151 }
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 ) {
5359 // Save to cache
5460 cache[ term ] = obj;
55 - deliverResult( obj, response, maxRowWindow );
 61+ deliverResult( obj, response );
5662 });
5763 },
5864 select : function() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r94236Follow-up r93383: api param is 'namespace', not 'namespaces'.krinkle11:09, 11 August 2011
r964981.18: MFT r95171, r95409, r95436, r95458, r95467, r95470, r95475, r95493, r95...catrope21:04, 7 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91728Rewrite mwsuggest.js using j.ui.autocomplete. This gets rid of a lot of the l...diebuche14:59, 8 July 2011

Comments

#Comment by Krinkle (talk | contribs)   21:46, 28 July 2011

Hi,

This commit changes the parameter name from "namespace" to "namespaces", which makes it fail. Marking fixme.

Status & tagging log