From 44a80255bb71fc712521aa5f27fe007580c91363 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:39:58 -0700 Subject: [PATCH] i guess that counts as mvp right --- cmd/server/internal/public/index.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/server/internal/public/index.html b/cmd/server/internal/public/index.html index 2e19953..840a5b3 100644 --- a/cmd/server/internal/public/index.html +++ b/cmd/server/internal/public/index.html @@ -20,8 +20,8 @@
-
- +
+
@@ -35,7 +35,6 @@ if (!body) return; g_questions = JSON.parse(body); - console.log("TODO polled state:", body); pollLiveAnswer(); pollLiveQuestion(); }); @@ -53,7 +52,6 @@ ` - options = `
${options}
`; if (document.getElementById("question-text").value != g_live_question.Text) { document.getElementById("question-text").innerHTML = `

${g_live_question.Text}

`; document.getElementById("question-text").value = g_live_question.Text; @@ -86,7 +84,19 @@ } function submitAnswersForm(form) { - console.log("TODO submitAnswersForm") + let children = []; + for (let e of form["question-options"].elements) { + children.push(e); + } + let checked_children = children.filter((c) => c.checked); + let text = form["answers-freeform"].value; + if (checked_children) + text = checked_children[0].value; + http("POST", `/api/v1/questions/${g_live_question.ID}/answers`, (body, status) => { + console.log(status, body); + }, JSON.stringify({ + Text: text, + })); } function http(method, remote, callback, body) {