i guess that counts as mvp right

main v0.0.0
Bel LaPointe 2024-02-20 15:39:58 -07:00
parent d4da09dc5a
commit 44a80255bb
1 changed files with 15 additions and 5 deletions

View File

@ -20,8 +20,8 @@
<div id="answers-list"></div>
<div id="question-text"></div>
<form id="answer-form" action="#" onsubmit="submitAnswersForm(this); return false;">
<div id="question-options"></div>
<input id="answers-freeform" type="text" hidden/>
<fieldset id="question-options" name="question-options"></fieldset>
<input id="answers-freeform" name="answers-freeform" type="text" hidden/>
<button type="submit">Submit</button>
</form>
</body>
@ -35,7 +35,6 @@
if (!body)
return;
g_questions = JSON.parse(body);
console.log("TODO polled state:", body);
pollLiveAnswer();
pollLiveQuestion();
});
@ -53,7 +52,6 @@
<input type="radio" value="${i}" name="g_live_question.Options" />
<label for="${i}">${i}</label>
</div>`
options = `<fieldset>${options}</fieldset>`;
if (document.getElementById("question-text").value != g_live_question.Text) {
document.getElementById("question-text").innerHTML = `<h1>${g_live_question.Text}</h1>`;
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) {