From df273e22b94ddc85d2f1fcd692bd7107d00d6e9c Mon Sep 17 00:00:00 2001 From: def00111 Date: Wed, 27 Dec 2017 08:45:00 +0100 Subject: [PATCH] Show more if only one word is selected (#39) --- simple-translate/simple-translate.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/simple-translate/simple-translate.js b/simple-translate/simple-translate.js index 91fb72d..6fcf5b9 100644 --- a/simple-translate/simple-translate.js +++ b/simple-translate/simple-translate.js @@ -99,7 +99,7 @@ function getRequest(word) { return new Promise(function (resolve, reject) { let xhr = new XMLHttpRequest(); xhr.responseType = 'json'; - let url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=" + S.get().targetLang + "&dt=t&q=" + encodeURIComponent(word); + let url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=" + S.get().targetLang + "&dt=t&dt=bd&q=" + encodeURIComponent(word); xhr.open("GET", url); xhr.send(); xhr.onload = function () { @@ -117,6 +117,12 @@ function showResult(results) { resultText += results[j].response[0][i][0]; } resultText += "\n"; // + + if (results[j].response[1]) { + for (let i = 0; i < results[j].response[1].length; i++) { + resultText += "\n" + results[j].response[1][i][0] + ": " + results[j].response[1][i][1].join(", "); + } + } } panel.innerHTML = "

" panel.getElementsByTagName("p")[0].innerText = resultText;