From dab46eda3e42e5f0a624bb285a555b078b999a99 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 13 Nov 2016 11:58:23 -0800 Subject: WIP --- ext/bg/guide.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ext/bg/guide.html (limited to 'ext/bg/guide.html') diff --git a/ext/bg/guide.html b/ext/bg/guide.html new file mode 100644 index 00000000..e5ec59d7 --- /dev/null +++ b/ext/bg/guide.html @@ -0,0 +1,35 @@ + + + + + Yomichan + + + + +
+ + +

Thank you for downloading this extension! I sincerely hope that it will assist you on your language learning journey.

+ +
+

Quick Guide

+ +

+ Please read the steps outlined below to get quickly get up and running with Yomichan. For complete documentation, + visit the official homepage. +

+ +
    +
  1. Left-click on the icon to enable or disable Yomichan for the current browser instance.
  2. +
  3. Right-click on the icon and select Options to open the Yomichan options page.
  4. +
  5. Hold down Shift (or the middle mouse button) as you hover over text to see term definitions.
  6. +
  7. Resize the definitions window by dragging the bottom-left corner inwards or outwards.
  8. +
  9. Click on Kanji in the definition window to view additional information about that character.
  10. +
+
+
+ + -- cgit v1.2.3 From a9fb56688434164e30f8f94868c652be7e7d69ad Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 13 Nov 2016 19:10:28 -0800 Subject: WIP --- ext/bg/guide.html | 3 ++- ext/bg/js/database.js | 12 ++++++++++++ ext/bg/js/options-form.js | 27 +++++++++++++++++++++------ ext/bg/options.html | 6 +++--- 4 files changed, 38 insertions(+), 10 deletions(-) (limited to 'ext/bg/guide.html') diff --git a/ext/bg/guide.html b/ext/bg/guide.html index e5ec59d7..d6809139 100644 --- a/ext/bg/guide.html +++ b/ext/bg/guide.html @@ -2,7 +2,7 @@ - Yomichan + Welcome to Yomichan! @@ -25,6 +25,7 @@
  1. Left-click on the icon to enable or disable Yomichan for the current browser instance.
  2. Right-click on the icon and select Options to open the Yomichan options page.
  3. +
  4. Import any dictionaries (bundled or custom) you wish to use for Kanji and term searches.
  5. Hold down Shift (or the middle mouse button) as you hover over text to see term definitions.
  6. Resize the definitions window by dragging the bottom-left corner inwards or outwards.
  7. Click on Kanji in the definition window to view additional information about that character.
  8. diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 5931e172..0621f1d6 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -39,6 +39,18 @@ class Database { return this.db.open(); } + purge() { + if (this.db === null) { + return Promise.reject('database not initialized'); + } + + this.db.close(); + return this.db.delete().then(() => { + this.db = null; + this.prepare(); + }); + } + findTerm(term, dictionaries) { if (this.db === null) { return Promise.reject('database not initialized'); diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 015c9a0a..68a18d8f 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -134,20 +134,19 @@ function onDictionaryDelete() { dictProgress.find('div').css('width', `${current / total * 100.0}%`); }; - database().deleteDictionary(dictGroup.data('title'), callback).then(() => { - dictGroup.slideUp(); - }).catch(error => { + database().deleteDictionary(dictGroup.data('title'), callback).catch(error => { dictError.show().find('span').text(error); }).then(() => { dictSpinner.hide(); dictProgress.hide(); dictControls.show(); + return loadOptions().then(opts => populateDictionaries(opts)); }); } function onDictionaryImport() { - const dictImport = $(this); - dictImport.prop('disabled', true); + const dictImporter = $('#dict-importer'); + dictImporter.hide(); const dictError = $('#dict-error'); dictError.hide(); @@ -174,7 +173,7 @@ function onDictionaryImport() { }).catch(error => { dictError.show().find('span').text(error); }).then(() => { - dictImport.prop('disabled', false); + dictImporter.show(); dictUrl.val(''); dictUrl.trigger('input'); dictProgress.hide(); @@ -313,6 +312,21 @@ function populateDictionaries(opts) { }); } +function onPurgeDb() { + const dictError = $('#dict-error'); + dictError.hide(); + + const dictSpinner = $('#dict-spinner'); + dictSpinner.show(); + + return database().purge().catch(error => { + dictError.show().find('span').text(error); + }).then(() => { + dictSpinner.hide(); + return loadOptions().then(opts => populateDictionaries(opts)); + }); +} + function onOptionsChanged(e) { if (!e.originalEvent && !e.isTrigger) { return; @@ -383,6 +397,7 @@ $(document).ready(() => { $('input, select').not('.anki-model').change(onOptionsChanged); $('.anki-model').change(onAnkiModelChanged); + $('#dict-purge').click(onPurgeDb); $('#dict-importer a').click(onDictionarySetUrl); $('#dict-import').click(onDictionaryImport); $('#dict-url').on('input', onDictionaryUpdateUrl); diff --git a/ext/bg/options.html b/ext/bg/options.html index 6d745b93..c3450c39 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -73,7 +73,7 @@

    Yomichan can import both bundled and custom (see the Yomichan Import page for details) dictionaries. Although it is also possible to delete unneeded dictionaries, this operation is extremely slow and it is often - easier to disable them or simply reset the database. Finally, please make sure to + easier to disable them or simply purge the database. Finally, please make sure to wait for import and delete operations to complete before closing this page.

    @@ -81,7 +81,7 @@
    No dictionaries found: - please use the dropdown below to install packaged and external dictionaries + please use the drop down below to install packaged and external dictionaries
    @@ -106,7 +106,7 @@
    -
    +
    -- cgit v1.2.3