summaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorstuebinm2021-04-12 16:56:08 +0200
committerstuebinm2021-04-12 17:05:19 +0200
commit6b892239f80e8523e02d7348e5483e9a7aea58ee (patch)
tree2e72f8e2fceb3698c31f208576cb7c82dd504400 /site
parent15d7a47bea2815d4852c62984b256d658e8b3742 (diff)
site: use errormsg function for general survey errors
the previous commit introduced handling error messages using a "setErrormsg" function. This is now also used for the general error messages which may show up at the bottom of surveys. However, since js and async things are weird, the code there is still a long repetitive mess which can't really be cut down further.
Diffstat (limited to '')
-rw-r--r--site/index.html19
1 files changed, 10 insertions, 9 deletions
diff --git a/site/index.html b/site/index.html
index 70d487b..6141163 100644
--- a/site/index.html
+++ b/site/index.html
@@ -172,13 +172,15 @@
let footer = mkElement("section");
let submit = mkElement("button", _("submit"));
- let errormsg = mkElement("p", "", "error");
+ let errormsg = setErrormsg (
+ mkElement("p", "", "error"),
+ null
+ );
appendChildren(footer, [
mkElement("hr"),
submit,
errormsg
]);
- errormsg.hidden = true;
submit.onclick = () => {
// the callback over the complete survey just maps all
// other callbacks to their values, i.e. calls them all
@@ -207,18 +209,17 @@
console.log(response.text())
window.location.href = "thanks.html";
}
- errormsg.innerText = _("Error: post returned error") + "\n"
- + response.status + ": " + response.statusText;
- errormsg.hidden = false;
+ setErrormsg(errormsg,
+ _("Error: post returned error") + "\n"
+ + response.status + ": " + response.statusText
+ );
}).catch(error => {
console.log(error);
- errormsg.innerText = _("Error: could not post");
- errormsg.hidden = false;
+ setErrormsg(errormsg, _("Error: could not post"));
});
} else {
- errormsg.innerText = _("Error: answers invalid");
- errormsg.hidden = false;
+ setErrormsg(errormsg, _("Error: answers invalid"));
}
}
root.appendChild(footer);