Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/138301
Change subject: Update the dictionary test page as per api changes ...................................................................... Update the dictionary test page as per api changes Change-Id: I96a2fb6e957a59d18161b9433641232681393ee9 --- M public/dictionary/js/main.js 1 file changed, 21 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver refs/changes/01/138301/1 diff --git a/public/dictionary/js/main.js b/public/dictionary/js/main.js index 3f461f3..dc7b664 100644 --- a/public/dictionary/js/main.js +++ b/public/dictionary/js/main.js @@ -2,21 +2,33 @@ ( function ( $ ) { 'use strict'; - $( document ).ready( function () { - $( 'button' ).click( function () { - $( '.definition' ).empty(); - var word = $( 'input[name=word]' ).val(), - from = $( 'input[name=sourceLanguage]' ).val(), - to = $( 'input[name=targetLanguage]' ).val(); - $.get( word + '/' + from + '/' + to, function ( response ) { + function lookup() { + $( '.definition' ).empty(); + var word = $( 'input[name=word]' ).val(), + from = $( 'input[name=sourceLanguage]' ).val(), + to = $( 'input[name=targetLanguage]' ).val(); + $.get( word + '/' + from + '/' + to, function ( response ) { + if ( response.translations ) { $.each( response.translations, function ( index, translation ) { $( '.definition' ).append( translation.phrase ); $( '.definition' ).append( '\n' ); $( '.definition' ).append( translation.info ); $( '.definition' ).append( '\n' ); } ); - $( 'progress' ).hide(); - } ); + } + if ( response.freetext ) { + $.each( response.freetext, function ( index, freetext ) { + $( '.definition' ).append( freetext.text ); + $( '.definition' ).append( '\n' ); + $( '.definition' ).append( freetext.sources ); + $( '.definition' ).append( '\n' ); + } ); + } + $( 'progress' ).hide(); } ); + } + + $( document ).ready( function () { + $( 'button' ).click( lookup ); } ); }( jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/138301 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I96a2fb6e957a59d18161b9433641232681393ee9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits