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