From e8701cb950edd4c90f6c911e340db3af32194113 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 2 Feb 2020 14:53:32 -0500 Subject: Hide anki-invalid-response-error when there is no error --- ext/bg/js/settings/anki.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'ext/bg/js/settings') diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index 3b0912d4..f55989fc 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -33,20 +33,27 @@ function _ankiSpinnerShow(show) { function _ankiSetError(error) { const node = document.querySelector('#anki-error'); - if (!node) { return; } + const node2 = document.querySelector('#anki-invalid-response-error'); if (error) { const errorString = `${error}`; - node.hidden = false; - node.textContent = errorString; - _ankiSetErrorData(node, error); + if (node !== null) { + node.hidden = false; + node.textContent = errorString; + _ankiSetErrorData(node, error); + } - const node2 = document.querySelector('#anki-invalid-response-error'); if (node2 !== null) { node2.hidden = (errorString.indexOf('Invalid response') < 0); } } else { - node.hidden = true; - node.textContent = ''; + if (node !== null) { + node.hidden = true; + node.textContent = ''; + } + + if (node2 !== null) { + node2.hidden = true; + } } } -- cgit v1.2.3