commit 501c61680b5f2c6dda55e9c55c2a2e7935370865 Author: OverPoweredDev Date: Sun Jun 27 10:54:10 2021 +0530 fixed some minor bugs - exchange language needed input text when source = 'detect' - translate was reformatting to html unnecessarily - added options.test.js to tests/README diff --git a/src/popup/popup.js b/src/popup/popup.js index 2fe26c4..60e1dd8 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -51,7 +51,7 @@ $("#target-dropdown-div").on('click', '.target-language-option', function () { //Exchange source and target languages if possible $("#exchange-source-target").on('click', async function () { - let sourceLanguage = await getSourceLanguage(); + let sourceLanguage = await getSourceLanguage(true); let targetLanguage = await getTargetLanguage(); console.log(sourceLanguage+targetLanguage); @@ -117,7 +117,7 @@ $("#enable-hover-checkbox").on('click', async function () { }); }); -$(document).click(function(){ +$(document).on('click', function(){ $("#target-dropdown-div").hide(); $("#source-dropdown-div").hide(); }); @@ -162,7 +162,7 @@ async function getTranslation(inputText, sourceLanguage, targetLanguage) { langPair = langPair.concat(sourceLanguage, "|", targetLanguage); let url = new URL(getTranslationEndpoint()); - let params = {langpair: langPair, q: inputText, format: "html"}; + let params = {langpair: langPair, q: inputText, deformat: "html"}; url.search = new URLSearchParams(params).toString(); outputText = await fetch(url) @@ -188,14 +188,17 @@ function getTargetLanguage(){ } } -async function getSourceLanguage(){ +async function getSourceLanguage(noDetect = false) { let languageCode = $("#source-language").val(); if (languageCode === undefined) { $("#source-language").addClass('error'); return null; } else if (languageCode === 'detect') { - return await detectInputLanguage(); + if (noDetect) + return 'detect'; + else + return await detectInputLanguage(); } else { return languageCode } diff --git a/tests/README.md b/tests/README.md index 16d5dad..c894ed1 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,10 +7,13 @@ npm init npm install puppeteer mocha --dev ``` +
+ then run the tests with ``` cd tests/ mocha popup.test.js +mocha options.test.js mocha settings.test.js ``` \ No newline at end of file