From: Ed Sanders Date: Mon, 9 Oct 2017 08:54:29 +0000 (+0100) Subject: SearchInputWidget: Pass through description data X-Git-Tag: 1.31.0-rc.0~1836^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=a13cb08330290b52470912e3bd40b4c7bc5c0b24;p=lhc%2Fweb%2Fwiklou.git SearchInputWidget: Pass through description data Also make result-parsing code clearer. Change-Id: Ibf90ba3fc330f442606f243855721182701f7c02 --- diff --git a/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js index 8707bfaeff..e73f347cfd 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js @@ -184,9 +184,12 @@ */ mw.widgets.SearchInputWidget.prototype.getOptionsFromData = function ( data ) { var items = [], + titles = data.data[ 1 ], + descriptions = data.data[ 2 ], + urls = data.data[ 3 ], self = this; - $.each( data.data[ 1 ], function ( i, result ) { + $.each( titles, function ( i, result ) { items.push( new mw.widgets.TitleOptionWidget( self.getOptionWidgetData( result, @@ -194,10 +197,9 @@ // the parent's API query. { data: result, - // data[ 3 ][ i ] is the link for this result - url: data.data[ 3 ][ i ], - imageUrl: null, - description: null, + url: urls[ i ], + imageUrl: null, // The JSON 'opensearch' API doesn't have images + description: descriptions[ i ], missing: false, redirect: false, disambiguation: false