From 16cdb1f13e96d78f712c862db8aae6d9b4d54112 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 16 Oct 2016 17:56:00 -0700 Subject: [PATCH] WIP --- ext/bg/img/spinner.gif | Bin 0 -> 7358 bytes ext/bg/js/ankiweb.js | 4 ++++ ext/bg/js/options-form.js | 32 ++++++++++++++----------- ext/bg/options.html | 48 +++++++++++++++++++++----------------- 4 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 ext/bg/img/spinner.gif diff --git a/ext/bg/img/spinner.gif b/ext/bg/img/spinner.gif new file mode 100644 index 0000000000000000000000000000000000000000..8ed30cb6362966f7f8210cf5317a178707578ff1 GIT binary patch literal 7358 zcmb8!X;hPU+6M6KWCOC3KnQt4NCG4w1Vlt$2a*Sbu#{*}u&4nM(4qoGMXNT1#jw-? z+;E+MxYVKrN~u-qu!M@#I?&oq7iSKlwbZdKwoYrU+PPzF>N_*1uP-0?M$X~VvHDb6oVn)2-VhV$B+Znp*N;(bhLNm7vxK2(p@dPu6%Ii?ss>4dwR<^ zlt)HIHr6*@8oPA+*6rf8#RvBvy!zSI2lpTJpY0d=3RBZlJ5P2-Y9qI7+Y&o3wz{_3 z@vh^>%^St5i8^xqIImPUf~ti0$GS|2dER~#o+nc{xK8YW zOi9=P!ZA_9rIw(On|XczOba9^@82J5P}6WEX)~^>n!)li*t(MvNf<_8!GML4tE+7g zC04g00e|3K^u;xHTcm@sA5M03=&&P#Xi7%ciy!3S>WEVHo9B|PBQ*v@gxSMs(xp<{ zXgT9=NV*CSabg-2iqEVg?^`z2=Ij>G?6zGhmh{b!dZcZLh=m?v%rtsn4J+;BdxbVD z;nB>U{4Wu^mim%k{nCuRmgPvXPk;6GwaW39n@da;KD+Bb;orTl9{tC)n^Pf&-kA6I zR06T?sOQSNBL~k?i9Wc3dJ68z!)Shcn3{jrcdP^G0YDc$Flbs}0yP{K=V^d0dUP*3 zxC5RpcR(^{Ne&<)kO(e-Xd(&*0VWs(i7tcS%Vidvx*56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g/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($('