show "off" on button when extension is disabled
This commit is contained in:
parent
fefadf7808
commit
5de3005d0b
@ -256,7 +256,7 @@ function optionsSave(options) {
|
|||||||
* Dictionary
|
* Dictionary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function dictEnabled(options) {
|
function dictEnabledSet(options) {
|
||||||
const dictionaries = {};
|
const dictionaries = {};
|
||||||
for (const title in options.dictionaries) {
|
for (const title in options.dictionaries) {
|
||||||
const dictionary = options.dictionaries[title];
|
const dictionary = options.dictionaries[title];
|
||||||
@ -268,6 +268,16 @@ function dictEnabled(options) {
|
|||||||
return dictionaries;
|
return dictionaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dictConfigured(options) {
|
||||||
|
for (const title in options.dictionaries) {
|
||||||
|
if (options.dictionaries[title].enabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function dictRowsSort(rows, options) {
|
function dictRowsSort(rows, options) {
|
||||||
return rows.sort((ra, rb) => {
|
return rows.sort((ra, rb) => {
|
||||||
const pa = (options.dictionaries[ra.title] || {}).priority || 0;
|
const pa = (options.dictionaries[ra.title] || {}).priority || 0;
|
||||||
|
@ -37,17 +37,16 @@ window.yomichan = new class {
|
|||||||
optionsSet(options) {
|
optionsSet(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
let configured = false;
|
if (!options.general.enable) {
|
||||||
for (const title in options.dictionaries) {
|
chrome.browserAction.setBadgeBackgroundColor({color: '#d9534f'});
|
||||||
if (options.dictionaries[title].enabled) {
|
chrome.browserAction.setBadgeText({text: 'off'});
|
||||||
configured = true;
|
} else if (!dictConfigured(options)) {
|
||||||
break;
|
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) {
|
if (options.anki.enable) {
|
||||||
this.anki = new AnkiConnect(this.options.anki.server);
|
this.anki = new AnkiConnect(this.options.anki.server);
|
||||||
} else {
|
} else {
|
||||||
@ -108,13 +107,13 @@ window.yomichan = new class {
|
|||||||
this.translator.findTermsGrouped.bind(this.translator) :
|
this.translator.findTermsGrouped.bind(this.translator) :
|
||||||
this.translator.findTerms.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)};
|
return {length, definitions: definitions.slice(0, this.options.general.maxResults)};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
kanjiFind(text) {
|
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);
|
return definitions.slice(0, this.options.general.maxResults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user