aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/options-form.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/options-form.js')
-rw-r--r--ext/bg/js/options-form.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 3d1530ad..3a201bc5 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -141,6 +141,7 @@ function populateDictionaries(opts) {
});
$('.dict-enable-terms, .dict-enable-kanji').change(onOptionsChanged);
+ $('.dict-delete').click(onDictionaryDelete);
}).catch(error => {
dictError.show().find('span').text(error);
}).then(() => {
@@ -148,6 +149,36 @@ function populateDictionaries(opts) {
});
}
+function onDictionaryDelete() {
+ const dictGroup = $(this).closest('.dict-group');
+
+ const dictError = $('#dict-error');
+ dictError.hide();
+
+ const dictSpinner = $('#dict-spinner');
+ dictSpinner.show();
+
+ const dictProgress = dictGroup.find('.dict-delete-progress');
+ dictProgress.show();
+
+ const dictControls = dictGroup.find('.dict-controls');
+ dictControls.hide();
+
+ const callback = (total, current) => {
+ dictProgress.find('div').css('width', `${current / total * 100.0}%`);
+ };
+
+ database().deleteDictionary(dictGroup.data('title'), callback).then(() => {
+ dictGroup.slideUp();
+ }).catch(error => {
+ dictError.show().find('span').text(error);
+ }).then(() => {
+ dictSpinner.hide();
+ dictProgress.hide();
+ dictControls.show();
+ });
+}
+
function onDictionaryImport() {
const dictImport = $(this);
dictImport.prop('disabled', true);
@@ -155,7 +186,7 @@ function onDictionaryImport() {
const dictError = $('#dict-error');
dictError.hide();
- const dictProgress = $('.dict-progress');
+ const dictProgress = $('.dict-import-progress');
dictProgress.show();
const dictSpinner = $('#dict-spinner');