From 00785304ebf86fd92f66de63ffcee3da24a9fc53 Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Fri, 26 Aug 2016 19:30:46 -0400 Subject: [PATCH] Displays source of data --- api/bing-wrapper.js | 10 +++------- api/glosbe-wrapper.js | 4 +++- data/wobtranslate-dialog.html | 16 +++++++++++++--- data/wobtranslate-dialog.js | 30 +++++++++++++++++++++++++----- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/api/bing-wrapper.js b/api/bing-wrapper.js index 9f80bf1..6c05546 100644 --- a/api/bing-wrapper.js +++ b/api/bing-wrapper.js @@ -19,11 +19,7 @@ exports.Wrapper = function (Request, Promise, parseString, clientID, clientSecre * PROMISE that, on success, returns an object with the following properties: * translation (string) Text of the translation in `to` language * source (string) Source of translation (bing) - * authors (object array) array of single object having properties - * url (string) https://www.microsoft.com/en-us/translator/translatorapi.aspx - * - * Now, you're probably wondering, why would we have an authors array with only one element? - * The answer is, unsatisfyingly, to stay consistent with Glosbe. + * url (string) https://www.microsoft.com/en-us/translator/translatorapi.aspx */ this.translate = function (x) { if (!x) { @@ -64,8 +60,8 @@ exports.Wrapper = function (Request, Promise, parseString, clientID, clientSecre } else { resolve({ translation: result.string._, - source: "bing", - authors: [ { url: "https://www.microsoft.com/en-us/translator/translatorapi.aspx" } ] + source: "Bing", + url: "https://www.microsoft.com/en-us/translator/translatorapi.aspx" }); } }); diff --git a/api/glosbe-wrapper.js b/api/glosbe-wrapper.js index 37cf55a..0a9b1ea 100644 --- a/api/glosbe-wrapper.js +++ b/api/glosbe-wrapper.js @@ -150,7 +150,7 @@ function glosbeTranslateJsonToArray(data) { }); return { translation: tucElement.phrase.text, - source: "glosbe", + source: "Glosbe", authors: authors } }); @@ -163,6 +163,7 @@ function glosbeTranslateJsonToArray(data) { * Array whose elements have properties: * toSentence (string) Sentence containing `phrase` in `to` language * fromSentence (string) Sentence containing `phrase` in `from` language + * source (string) Name of website source (Glosbe) * author (object) object having properties * url (string) URL of source on glosbe * id (int) unique author id on glosbe @@ -173,6 +174,7 @@ function glosbeTMJsonToArray(data) { return { fromSentence: example.first, toSentence: example.second, + source: "Glosbe", author: { id: example.author, url: "https://www.glosbe.com/source/" + example.author diff --git a/data/wobtranslate-dialog.html b/data/wobtranslate-dialog.html index 25709ce..bd3358d 100644 --- a/data/wobtranslate-dialog.html +++ b/data/wobtranslate-dialog.html @@ -39,6 +39,12 @@ font-size: 20pt; } +.source { + font-style: italic; + color: #666; + cursor: pointer; +} + .title { font-weight: bold; } @@ -87,12 +93,16 @@