summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/anki.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-01 22:26:23 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-01 22:26:23 -0500
commitf89806e05d9db2924ee5bc80c6f640914d8ae2e5 (patch)
treef94faa22b5e75551390e8ed72f911d5d03cb3c13 /ext/bg/js/settings/anki.js
parent093fa3a43729a789bf31568405166770fcca2ad9 (diff)
Simplify how anki errors are shown
Diffstat (limited to 'ext/bg/js/settings/anki.js')
-rw-r--r--ext/bg/js/settings/anki.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js
index b7fce011..68230139 100644
--- a/ext/bg/js/settings/anki.js
+++ b/ext/bg/js/settings/anki.js
@@ -31,13 +31,16 @@ function _ankiSpinnerShow(show) {
}
}
-function _ankiErrorShow(error) {
- const dialog = $('#anki-error');
+function _ankiSetError(error) {
+ const node = document.querySelector('#anki-error');
+ if (!node) { return; }
if (error) {
- dialog.show().text(error);
+ node.hidden = false;
+ node.textContent = `${error}`;
}
else {
- dialog.hide();
+ node.hidden = true;
+ node.textContent = '';
}
}
@@ -119,9 +122,9 @@ async function _onAnkiModelChanged(e) {
_ankiSpinnerShow(true);
await _ankiFieldsPopulate(element, options);
- _ankiErrorShow();
+ _ankiSetError(null);
} catch (error) {
- _ankiErrorShow(error);
+ _ankiSetError(error);
} finally {
_ankiSpinnerShow(false);
}
@@ -131,7 +134,8 @@ async function _onAnkiModelChanged(e) {
// Public
function ankiErrorShown() {
- return $('#anki-error').is(':visible');
+ const node = document.querySelector('#anki-error');
+ return node && !node.hidden;
}
function ankiFieldsToDict(selection) {
@@ -212,10 +216,10 @@ async function onAnkiOptionsChanged(options) {
try {
_ankiSpinnerShow(true);
await _ankiDeckAndModelPopulate(options);
- _ankiErrorShow();
+ _ankiSetError(null);
_ankiDataPopulated = true;
- } catch (e) {
- _ankiErrorShow(e);
+ } catch (error) {
+ _ankiSetError(error);
} finally {
_ankiSpinnerShow(false);
}