summaryrefslogtreecommitdiff
path: root/site/index.html
diff options
context:
space:
mode:
authorstuebinm2021-04-12 18:07:41 +0200
committerstuebinm2021-04-12 18:07:41 +0200
commit5596ebcbad7721f767972c3143f8e5be1ba8fc09 (patch)
tree4f792eaf042e6d8236690588b4bf59641463002c /site/index.html
parent6b892239f80e8523e02d7348e5483e9a7aea58ee (diff)
add date answer space
for now, this is just a simple date picker done via the html input type "date". Unfortunately, that's not supported by Safari, so the rust util now prints out a warning if it's used. I'm not sure if there's any other reasonable option which would go around this that's not "using a web framework" or "hacking a fallback date picker which just consists of a couple of combo boxes".
Diffstat (limited to 'site/index.html')
-rw-r--r--site/index.html28
1 files changed, 28 insertions, 0 deletions
diff --git a/site/index.html b/site/index.html
index 6141163..1555a21 100644
--- a/site/index.html
+++ b/site/index.html
@@ -125,6 +125,32 @@
];
}
+ function mkDatePicker (name) {
+ let [input, label] = mkOption("date", name);
+ let errormsg = setErrormsg(
+ mkElement("div","","error"),
+ null
+ );
+ let div = appendChildren (
+ mkElement("div"),
+ [label,
+ mkElement("span", " "),
+ input,
+ errormsg]
+ );
+ return [
+ div,
+ () => {
+ let date = input.valueAsDate;
+ let [ret, error] = date !== null && !isNaN(date.valueOf())
+ ? [date.toISOString(), null]
+ : [null, _("Please pick a date")]
+ setErrormsg (errormsg, error);
+ return ret;
+ }
+ ]
+ }
+
// essentially a case - of statement over the answerspace type.
// since there is no validation of the config json, it may turn
// out to be a partial function in practice.
@@ -132,6 +158,8 @@
let space = question.space;
if (space === "YesOrNo") {
return mkListSpace("radio", ["yes", "no"], question.name, question.question);
+ } if (space === "Date") {
+ return mkDatePicker(question.name);
} if ("Single" in space) {
return mkListSpace("radio", space.Single, question.name, question.question);
} if ("Multiple" in space) {