aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/options-form.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-10-16 18:44:36 -0700
committerAlex Yatskov <alex@foosoft.net>2016-10-16 18:44:36 -0700
commitc076821e3709333bf19934d547c372d669f8ad84 (patch)
treea0110ee83b73f4d1579ad3a3fba43a5995442680 /ext/bg/js/options-form.js
parent1fe2626443daad810c1bfdb5749a76b036631783 (diff)
WIP
Diffstat (limited to 'ext/bg/js/options-form.js')
-rw-r--r--ext/bg/js/options-form.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index f66a678c..6731c007 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -120,9 +120,7 @@ function updateVisibility(opts) {
}
function populateAnkiDeckAndModel(opts) {
- $('.status-dlg').hide();
-
- const ankiSpinner = $('#ankiSpinner');
+ const ankiSpinner = $('#anki-spinner');
ankiSpinner.show();
const ankiFormat = $('#anki-format');
@@ -146,12 +144,10 @@ function populateAnkiDeckAndModel(opts) {
}).then(() => {
return populateAnkiFields($('#anki-kanji-model').val(opts.ankiKanjiModel), opts);
}).then(() => {
+ $('#anki-error').hide();
ankiFormat.show();
- if (opts.ankiMethod !== 'none') {
- $('#success-dlg').show();
- }
}).catch(error => {
- $('#error-dlg').show().find('span').text(error);
+ $('#anki-error').show().find('span').text(error);
}).then(() => {
ankiSpinner.hide();
});
@@ -218,6 +214,7 @@ function onOptionsChanged(e) {
saveOptions(optsNew).then(() => {
yomichan().setOptions(optsNew);
updateVisibility(optsNew);
+
if (optsNew.ankiMethod !== optsOld.ankiMethod) {
populateAnkiDeckAndModel(optsNew);
}
@@ -233,16 +230,15 @@ function onAnkiModelChanged(e) {
getFormValues().then(({optsNew, optsOld}) => {
optsNew[modelIdToFieldOptKey($(this).id)] = {};
- const ankiSpinner = $('#ankiSpinner');
+ const ankiSpinner = $('#anki-spinner');
ankiSpinner.show();
populateAnkiFields($(this), optsNew).then(() => {
saveOptions(optsNew).then(() => yomichan().setOptions(optsNew));
}).catch(error => {
- $('#success-dlg').hide();
- $('#error-dlg').show().find('span').text(error);
+ $('#anki-error').show().find('span').text(error);
}).then(() => {
- $('#success-dlg').show();
+ $('#anki-error').hide();
ankiSpinner.hide();
});
});