aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/guide.html3
-rw-r--r--ext/bg/js/database.js12
-rw-r--r--ext/bg/js/options-form.js27
-rw-r--r--ext/bg/options.html6
4 files changed, 38 insertions, 10 deletions
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 @@
<html lang="en">
<head>
<meta charset="UTF-8">
- <title>Yomichan</title>
+ <title>Welcome to Yomichan!</title>
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
</head>
@@ -25,6 +25,7 @@
<ol>
<li>Left-click on the <img src="../img/icon16.png" alt> icon to enable or disable Yomichan for the current browser instance.</li>
<li>Right-click on the <img src="../img/icon16.png" alt> icon and select <em>Options</em> to open the Yomichan options page.</li>
+ <li>Import any dictionaries (bundled or custom) you wish to use for Kanji and term searches.</li>
<li>Hold down <kbd>Shift</kbd> (or the middle mouse button) as you hover over text to see term definitions.</li>
<li>Resize the definitions window by dragging the bottom-left corner inwards or outwards.</li>
<li>Click on Kanji in the definition window to view additional information about that character.</li>
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 @@
<p class="help-block">
Yomichan can import both bundled and custom (see the <a href="https://foosoft.net/projects/yomichan-import">Yomichan Import</a>
page for details) dictionaries. Although it is also possible to delete unneeded dictionaries, this operation is <em>extremely slow</em> and it is often
- easier to disable them or simply <a href="javascript:resetDatabase();">reset the database</a>. Finally, please make sure to
+ easier to disable them or simply <a id="dict-purge">purge the database</a>. Finally, please make sure to
wait for import and delete operations to complete before closing this page.
</p>
@@ -81,7 +81,7 @@
<div class="alert alert-warning" id="dict-warning">
<strong>No dictionaries found:</strong>
- <span>please use the dropdown below to install packaged and external dictionaries</span>
+ <span>please use the drop down below to install packaged and external dictionaries</span>
</div>
<div class="alert alert-danger" id="dict-error">
@@ -106,7 +106,7 @@
</ul>
</div>
<input type="text" id="dict-url" class="form-control" placeholder="Dictionary import URL">
- <div class="input-group-btn disabled">
+ <div class="input-group-btn">
<button type="button" id="dict-import" class="btn btn-primary" disabled>Import</button>
</div>
</div>