From 16cdb1f13e96d78f712c862db8aae6d9b4d54112 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 16 Oct 2016 17:56:00 -0700 Subject: WIP --- ext/bg/js/ankiweb.js | 4 ++++ ext/bg/js/options-form.js | 32 +++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'ext/bg/js') 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($('