aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-08 17:52:46 -0500
committerGitHub <noreply@github.com>2021-02-08 17:52:46 -0500
commit4b6703114c3fedaaf24cc7a376d885e22dfdc4f3 (patch)
tree5065ab70a1e56ee6187aeb9af46491ab1667b524 /ext/bg/js
parent849e4fabe1dffc2851fcb338dae8400d6c8e46ca (diff)
Improve dictionaries not enabled badges (#1349)
* Improve badges on the settings page * Add badges on the context page
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/context-main.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/bg/js/context-main.js b/ext/bg/js/context-main.js
index 65853514..e9833687 100644
--- a/ext/bg/js/context-main.js
+++ b/ext/bg/js/context-main.js
@@ -100,6 +100,7 @@ class DisplayController {
toggle.checked = extensionEnabled;
toggle.addEventListener('change', onToggleChanged, false);
}
+ this._updateDictionariesEnabledWarnings(options);
}
async _setupHotkeys() {
@@ -150,6 +151,26 @@ class DisplayController {
}]
);
}
+
+ async _updateDictionariesEnabledWarnings(options) {
+ const noDictionariesEnabledWarnings = document.querySelectorAll('.no-dictionaries-enabled-warning');
+ const dictionaries = await api.getDictionaryInfo();
+
+ let enabledCount = 0;
+ for (const {title} of dictionaries) {
+ if (
+ Object.prototype.hasOwnProperty.call(options.dictionaries, title) &&
+ options.dictionaries[title].enabled
+ ) {
+ ++enabledCount;
+ }
+ }
+
+ const hasEnabledDictionary = (enabledCount > 0);
+ for (const node of noDictionariesEnabledWarnings) {
+ node.hidden = hasEnabledDictionary;
+ }
+ }
}
(async () => {