summaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
Diffstat (limited to 'site')
-rw-r--r--site/examples/example.json2
-rw-r--r--site/index.html28
-rw-r--r--site/style.css1
3 files changed, 30 insertions, 1 deletions
diff --git a/site/examples/example.json b/site/examples/example.json
index fcd09d8..140fe7f 100644
--- a/site/examples/example.json
+++ b/site/examples/example.json
@@ -1 +1 @@
-{"title":"Test Survey","description":"This is a test survey.","questions":[{"question":"first question","name":"question1","space":"YesOrNo"},{"question":"second question","name":"question2","space":{"Freeform":"test"}},{"question":"third question","name":"question3","space":{"Multiple":["first possible answer","second possible answer","third possible answer"]}}],"pubkey":"age1f380w6eaeuydey65mmu88h4kqv50dda96pxlgkal78sufpnngypqnetmuu","lang":"en"} \ No newline at end of file
+{"title":"Test Survey","description":"This is a test survey.","questions":[{"question":"first question","name":"question1","space":"YesOrNo"},{"question":"second question","name":"question2","space":{"Freeform":"test"}},{"question":"third question","name":"question3","space":{"Multiple":["first possible answer","second possible answer","third possible answer"]}},{"question":"fourth question","name":"question4","space":"Date"}],"pubkey":"age1f380w6eaeuydey65mmu88h4kqv50dda96pxlgkal78sufpnngypqnetmuu","lang":"en"} \ No newline at end of file
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) {
diff --git a/site/style.css b/site/style.css
index 08f22a6..9c4f668 100644
--- a/site/style.css
+++ b/site/style.css
@@ -22,6 +22,7 @@ li {
.error {
color: red;
+ margin-top: 0.5em;
}
textarea {