aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/yomichan.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-26 17:14:50 -0700
committerAlex Yatskov <alex@foosoft.net>2017-03-26 17:14:50 -0700
commit5de3005d0b9ce8dc30e6e1d8d869c57876ca136f (patch)
tree2465b5d1663e9c9497926e0d0abecf3c729d88bd /ext/bg/js/yomichan.js
parentfefadf78085d251a6b5f1c3ca081f10a5ffc4012 (diff)
show "off" on button when extension is disabled
Diffstat (limited to 'ext/bg/js/yomichan.js')
-rw-r--r--ext/bg/js/yomichan.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 39105c54..cbbcae63 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -37,17 +37,16 @@ window.yomichan = new class {
optionsSet(options) {
this.options = options;
- let configured = false;
- for (const title in options.dictionaries) {
- if (options.dictionaries[title].enabled) {
- configured = true;
- break;
- }
+ if (!options.general.enable) {
+ chrome.browserAction.setBadgeBackgroundColor({color: '#d9534f'});
+ chrome.browserAction.setBadgeText({text: 'off'});
+ } else if (!dictConfigured(options)) {
+ chrome.browserAction.setBadgeBackgroundColor({color: '#f0ad4e'});
+ chrome.browserAction.setBadgeText({text: '!'});
+ } else {
+ chrome.browserAction.setBadgeText({text: ''});
}
- chrome.browserAction.setBadgeBackgroundColor({color: '#f0ad4e'});
- chrome.browserAction.setBadgeText({text: configured ? '' : '!'});
-
if (options.anki.enable) {
this.anki = new AnkiConnect(this.options.anki.server);
} else {
@@ -108,13 +107,13 @@ window.yomichan = new class {
this.translator.findTermsGrouped.bind(this.translator) :
this.translator.findTerms.bind(this.translator);
- return searcher(text, dictEnabled(this.options), this.options.general.softKatakana).then(({definitions, length}) => {
+ return searcher(text, dictEnabledSet(this.options), this.options.general.softKatakana).then(({definitions, length}) => {
return {length, definitions: definitions.slice(0, this.options.general.maxResults)};
});
}
kanjiFind(text) {
- return this.translator.findKanji(text, dictEnabled(this.options)).then(definitions => {
+ return this.translator.findKanji(text, dictEnabledSet(this.options)).then(definitions => {
return definitions.slice(0, this.options.general.maxResults);
});
}