summaryrefslogtreecommitdiff
path: root/ext/bg/js/options.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-06-25 15:36:28 -0700
committerAlex Yatskov <alex@foosoft.net>2017-06-25 15:36:28 -0700
commitd3c342071f1397a59f94d89ca617e6294c50f861 (patch)
tree1a5b0f563e69f3c512741c40a8f09d97616f456f /ext/bg/js/options.js
parent98d22a92f33e50d6c75df08be70cf801610b4fb7 (diff)
support importing from zip files
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();
+ });
}
/*