From 44638b7ceb8ec4e2a235ad4ffc9aa23ec66f21d2 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 29 Oct 2019 16:31:27 -0400 Subject: Simplify how option visibility is changed --- ext/bg/css/settings.css | 11 +++++++++-- ext/bg/js/settings.js | 30 +++++------------------------- ext/bg/settings.html | 2 +- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css index b3d5b884..1036622d 100644 --- a/ext/bg/css/settings.css +++ b/ext/bg/css/settings.css @@ -17,9 +17,16 @@ */ -#anki-spinner, #anki-general, #anki-error, +#anki-spinner, #anki-error, #dict-spinner, #dict-error, #dict-warning, #dict-purge, #dict-import-progress, -#debug, .options-advanced, .storage-hidden, #storage-spinner { +.storage-hidden, #storage-spinner { + display: none; +} + +html:root:not([data-options-anki-enable=true]) #anki-general, +html:root:not([data-options-general-debug-info=true]) .debug, +html:root:not([data-options-general-show-advanced=true]) .options-advanced, +html:root:not([data-options-general-result-output-mode=merge]) #dict-main-group { display: none; } diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index 05a0604a..f2250911 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -171,36 +171,16 @@ function formSetupEventListeners() { } function formUpdateVisibility(options) { - const general = $('#anki-general'); - if (options.anki.enable) { - general.show(); - } else { - general.hide(); - } - - const advanced = $('.options-advanced'); - if (options.general.showAdvanced) { - advanced.show(); - } else { - advanced.hide(); - } + document.documentElement.dataset.optionsAnkiEnable = `${!!options.anki.enable}`; + document.documentElement.dataset.optionsGeneralDebugInfo = `${!!options.general.debugInfo}`; + document.documentElement.dataset.optionsGeneralShowAdvanced = `${!!options.general.showAdvanced}`; + document.documentElement.dataset.optionsGeneralResultOutputMode = `${options.general.resultOutputMode}`; - const mainGroup = $('#dict-main-group'); - if (options.general.resultOutputMode === 'merge') { - mainGroup.show(); - } else { - mainGroup.hide(); - } - - const debug = $('#debug'); if (options.general.debugInfo) { const temp = utilIsolate(options); temp.anki.fieldTemplates = '...'; const text = JSON.stringify(temp, null, 4); - debug.html(handlebarsEscape(text)); - debug.show(); - } else { - debug.hide(); + $('#debug').text(text); } } diff --git a/ext/bg/settings.html b/ext/bg/settings.html index a3b75576..b281501d 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -673,7 +673,7 @@

-

+            

 
             
             
 
-            
+

Dictionaries

@@ -434,6 +434,7 @@
+
Dictionary data is being imported, please be patient... @@ -451,6 +452,32 @@
+ + + +
@@ -700,6 +727,7 @@ + diff --git a/tmpl/dictionary.html b/tmpl/dictionary.html deleted file mode 100644 index 61bb79ac..00000000 --- a/tmpl/dictionary.html +++ /dev/null @@ -1,17 +0,0 @@ -
-

{{title}} rev.{{revision}}

- {{#if outdated}} -

This dictionary is outdated and may not support new extension features; please import the latest version.

- {{/if}} - -
- -
-
- -
-
- - -
-
-- cgit v1.2.3 From 3d78d5400d2ed6e9d8f5147f7212ec786f4f16bd Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 2 Nov 2019 14:30:17 -0400 Subject: Add button and confirmation dialog for database purge --- ext/bg/js/settings-dictionaries.js | 10 +++++++++- ext/bg/settings.html | 28 +++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ext/bg/js/settings-dictionaries.js b/ext/bg/js/settings-dictionaries.js index 635b95c6..72a27475 100644 --- a/ext/bg/js/settings-dictionaries.js +++ b/ext/bg/js/settings-dictionaries.js @@ -256,7 +256,8 @@ async function dictSettingsInitialize() { ); dictionaryUI.save = () => apiOptionsSave(); - document.querySelector('#dict-purge-link').addEventListener('click', (e) => onDictionaryPurge(e), false); + document.querySelector('#dict-purge-button').addEventListener('click', (e) => onDictionaryPurgeButtonClick(e), false); + document.querySelector('#dict-purge-confirm').addEventListener('click', (e) => onDictionaryPurge(e), false); document.querySelector('#dict-file-button').addEventListener('click', (e) => onDictionaryImportButtonClick(e), false); document.querySelector('#dict-file').addEventListener('change', (e) => onDictionaryImport(e), false); document.querySelector('#dict-main').addEventListener('change', (e) => onDictionaryMainChanged(e), false); @@ -398,9 +399,16 @@ function onDictionaryImportButtonClick() { dictFile.click(); } +function onDictionaryPurgeButtonClick(e) { + e.preventDefault(); + $('#dict-purge-modal').modal('show'); +} + async function onDictionaryPurge(e) { e.preventDefault(); + $('#dict-purge-modal').modal('hide'); + const dictControls = $('#dict-importer, #dict-groups, #dict-groups-extra, #dict-main-group').hide(); const dictProgress = $('#dict-purge').show(); diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 7ac196f2..fb39e5c3 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -417,10 +417,7 @@

- Yomichan can import and use a variety of dictionary formats. Unneeded dictionaries can be disabled, - or you can simply purge the database to delete everything. -

-

+ Yomichan can import and use a variety of dictionary formats. Unneeded dictionaries can be disabled. Deleting individual dictionaries is not currently feasible due to limitations of browser database technology.

@@ -449,10 +446,31 @@ download free dictionaries for use with this extension and to learn about importing proprietary EPWING dictionaries.

- +
+ + +
+ +