summaryrefslogtreecommitdiff
path: root/ext/bg/js/options.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/options.js')
-rw-r--r--ext/bg/js/options.js46
1 files changed, 21 insertions, 25 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 0b8b7ac3..cde1fc3f 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -250,31 +250,27 @@ function onDictionaryPurge(e) {
});
}
-function onDictionaryImport() {
- alert('import');
-
- // dictionaryErrorShow(null);
- // dictionarySpinnerShow(true);
-
- // const dictUrl = $('#dict-url');
- // const dictImporter = $('#dict-importer').hide();
- // const dictProgress = $('#dict-import-progress').show();
- // const setProgress = percent => dictProgress.find('.progress-bar').css('width', `${percent}%`);
-
- // setProgress(0.0);
-
- // optionsLoad().then(options => {
- // instDb().importDictionary(dictUrl.val(), (total, current) => setProgress(current / total * 100.0)).then(summary => {
- // options.dictionaries[summary.title] = {enabled: true, priority: 0};
- // return optionsSave(options);
- // }).then(() => dictionaryGroupsPopulate(options)).catch(dictionaryErrorShow).then(() => {
- // dictionarySpinnerShow(false);
- // dictProgress.hide();
- // dictImporter.show();
- // dictUrl.val('');
- // dictUrl.trigger('input');
- // });
- // });
+function onDictionaryImport(e) {
+ dictionaryErrorShow(null);
+ dictionarySpinnerShow(true);
+
+ const dictUrl = $('#dict-url');
+ const dictImporter = $('#dict-importer').hide();
+ const dictProgress = $('#dict-import-progress').show();
+ const setProgress = percent => dictProgress.find('.progress-bar').css('width', `${percent}%`);
+
+ setProgress(0.0);
+
+ optionsLoad().then(options => {
+ return instDb().importDictionary(e.target.files[0], (total, current) => setProgress(current / total * 100.0)).then(summary => {
+ options.dictionaries[summary.title] = {enabled: true, priority: 0};
+ return optionsSave(options);
+ }).then(() => dictionaryGroupsPopulate(options));
+ }).catch(dictionaryErrorShow).then(() => {
+ dictionarySpinnerShow(false);
+ dictProgress.hide();
+ dictImporter.show();
+ });
}
/*