commit e0f3c75ce377e8d129fe385b84f12dd96ae2c353 Author: OverPoweredDev Date: Mon Jun 21 17:24:11 2021 +0530 enabled enable checkbox :) diff --git a/src/popup/popup.html b/src/popup/popup.html index 0c4e93a..cb1a0f4 100644 --- a/src/popup/popup.html +++ b/src/popup/popup.html @@ -84,8 +84,8 @@
- -
diff --git a/src/popup/popup.js b/src/popup/popup.js index 16d7bd7..f94d5fa 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -100,15 +100,24 @@ $("#translate-webpage-button").on('click', function () { }); // TODO: Enable hover if inactive before, disable if active -$("#enable-hover-checkbox").on('click', function () { +$("#enable-hover-checkbox").on('click', async function () { + await chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => { + let url = tabs[0].url; + if($(this).is(":checked")){ + addToEnabledWebsiteList(globalSettings, url); + } else { + let hostname = new URL(url).hostname; + removeFromEnabledWebsiteList(globalSettings, hostname); + } + }); }); -function init() { +async function init() { globalSettings = getGlobalSettings(); - console.log(globalSettings) + await setCheckBox($("#enable-hover-checkbox")); setTargetLanguage(globalSettings.defaultLanguage); createSourceDropdown($("#source-dropdown-div"), globalSettings.defaultLanguage); createTargetDropdown($("#target-dropdown-div")); @@ -185,6 +194,17 @@ async function getSourceLanguage(){ } } +async function setCheckBox(checkbox){ + await chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => { + let hostname = new URL(tabs[0].url).hostname; + let list = getEnabledWebsiteList(); + + if(list.includes(hostname)){ + checkbox.prop('checked', true); + } + }); +} + function setTargetLanguage(targetLanguage) { let codeMap = getLanguageCodeMap(); $("#target-language").val(targetLanguage);