diff --git a/ext/bg/img/spinner.gif b/ext/bg/img/spinner.gif new file mode 100644 index 00000000..8ed30cb6 Binary files /dev/null and b/ext/bg/img/spinner.gif differ diff --git a/ext/bg/js/ankiweb.js b/ext/bg/js/ankiweb.js index ce909fcf..11142637 100644 --- a/ext/bg/js/ankiweb.js +++ b/ext/bg/js/ankiweb.js @@ -61,6 +61,10 @@ class AnkiWeb { } authenticate() { + if (this.username.length === 0 || this.password.length === 0) { + return Promise.reject('missing login credentials'); + } + if (this.logged) { return Promise.resolve(true); } diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index fb8ef77b..ceee9e3f 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -110,15 +110,15 @@ function getAnkiOptions() { function updateVisibility(opts) { switch (opts.ankiMethod) { case 'ankiweb': - $('.options-anki-general').show(); - $('.options-anki-login').show(); + $('#options-anki-general').show(); + $('#options-anki-login').show(); break; case 'ankiconnect': - $('.options-anki-general').show(); - $('.options-anki-login').hide(); + $('#options-anki-general').show(); + $('#options-anki-login').hide(); break; default: - $('.options-anki-general').hide(); + $('#options-anki-general').hide(); break; } @@ -130,9 +130,14 @@ function updateVisibility(opts) { } function populateAnkiDeckAndModel(opts) { - $('.options-anki-format').hide(); $('.status-dlg').hide(); + const ankiSpinner = $('#ankiSpinner'); + ankiSpinner.show(); + + const ankiFormat = $('#options-anki-format'); + ankiFormat.hide(); + const ankiDeck = $('.anki-deck'); ankiDeck.find('option').remove(); @@ -147,17 +152,18 @@ function populateAnkiDeckAndModel(opts) { return anki().getModelNames(); }).then(names => { names.forEach(name => ankiModel.append($('