From 5b90d8ef06791f7b9ec9c02595786ffb9db26450 Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Sun, 14 Jul 2024 00:04:39 +0700 Subject: [PATCH 1/3] Helper text when no dictionary enabled --- ext/js/display/display.js | 17 ++++++++++++++++- ext/popup.html | 6 ++++++ ext/search.html | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 97b29bbd78..913bd64153 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -1296,6 +1296,7 @@ export class Display extends EventDispatcher { async _setContentTermsOrKanji(type, urlSearchParams, token) { const lookup = (urlSearchParams.get('lookup') !== 'false'); const wildcardsEnabled = (urlSearchParams.get('wildcards') !== 'off'); + const hasEnabledDictionaries = this._options ? this._options.dictionaries.some(({enabled}) => enabled) : false; // Set query let query = urlSearchParams.get('query'); @@ -1367,7 +1368,8 @@ export class Display extends EventDispatcher { this._dictionaryEntries = dictionaryEntries; this._updateNavigationAuto(); - this._setNoContentVisible(dictionaryEntries.length === 0 && lookup); + this._setNoContentVisible(hasEnabledDictionaries && dictionaryEntries.length === 0 && lookup); + this._setNoDictionariesVisible(!hasEnabledDictionaries); const container = this._container; container.textContent = ''; @@ -1424,6 +1426,7 @@ export class Display extends EventDispatcher { this._updateNavigation(false, false); this._setNoContentVisible(false); + this._setNoDictionariesVisible(false); this._setQuery('', '', 0); this._triggerContentUpdateStart(); @@ -1452,6 +1455,18 @@ export class Display extends EventDispatcher { } } + /** + * @param {boolean} visible + */ + _setNoDictionariesVisible(visible) { + /** @type {?HTMLElement} */ + const noDictionaries = document.querySelector('#no-dictionaries'); + + if (noDictionaries !== null) { + noDictionaries.hidden = !visible; + } + } + /** * @param {string} query * @param {string} fullQuery diff --git a/ext/popup.html b/ext/popup.html index 2b55df5de6..b3b8782529 100644 --- a/ext/popup.html +++ b/ext/popup.html @@ -45,6 +45,12 @@ + + From 284ac511a905da76c33e8856d3bbd66879a29a67 Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Sun, 14 Jul 2024 00:19:45 +0700 Subject: [PATCH 2/3] Don't need to search if there is no dictionary entries --- ext/js/display/display.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 913bd64153..b2f96e363c 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -1332,7 +1332,7 @@ export class Display extends EventDispatcher { let {dictionaryEntries} = content; if (!Array.isArray(dictionaryEntries)) { - dictionaryEntries = lookup && query.length > 0 ? await this._findDictionaryEntries(type === 'kanji', query, wildcardsEnabled, optionsContext) : []; + dictionaryEntries = hasEnabledDictionaries && lookup && query.length > 0 ? await this._findDictionaryEntries(type === 'kanji', query, wildcardsEnabled, optionsContext) : []; if (this._setContentToken !== token) { return; } content.dictionaryEntries = dictionaryEntries; changeHistory = true; From 068a4275d39100d0bbb2e4db38a903c537cb7405 Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Sun, 14 Jul 2024 13:45:46 +0700 Subject: [PATCH 3/3] update helper link --- ext/popup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/popup.html b/ext/popup.html index b3b8782529..07201b89a9 100644 --- a/ext/popup.html +++ b/ext/popup.html @@ -48,7 +48,7 @@