answer prompt flips between question options as ul and input text
parent
f750f055b7
commit
44c670b7db
|
|
@ -4,22 +4,24 @@
|
||||||
<!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/light.css">-->
|
<!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/light.css">-->
|
||||||
<link rel="stylesheet" href="/light.css">
|
<link rel="stylesheet" href="/light.css">
|
||||||
<style>
|
<style>
|
||||||
:not(#answers[hidden]) + #question {
|
:not(#answers-list[hidden]) + #question,
|
||||||
|
:not(#answers-list[hidden]) + #question + #answer-form,
|
||||||
|
:not(#question-options:empty) + #answers-freeform
|
||||||
|
{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</header>
|
</header>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello World</h1>
|
<h1>Hello World</h1>
|
||||||
<div id="answers">
|
<div id="answers-list"></div>
|
||||||
<ul id="answers-list"></ul>
|
|
||||||
<form id="answers-form" action="#" onsubmit="submitAnswersForm(this); return false;">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div id="question">
|
<div id="question">
|
||||||
<h1><span id="question-text"></span></h1>
|
<h1><span id="question-text"></span></h1>
|
||||||
<ul id="question-options"></ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
<form id="answer-form" action="#" onsubmit="submitAnswersForm(this); return false;">
|
||||||
|
<ul id="question-options"></ul>
|
||||||
|
<input id="answers-freeform" type="text" hidden/>
|
||||||
|
</form>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
<footer>
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -53,16 +55,16 @@
|
||||||
|
|
||||||
function pollLiveAnswer() {
|
function pollLiveAnswer() {
|
||||||
if (!g_live_question || !g_live_question.Closed) {
|
if (!g_live_question || !g_live_question.Closed) {
|
||||||
document.getElementById("answers").hidden = true;
|
document.getElementById("answers-list").hidden = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.getElementById("answers").hidden = false;
|
document.getElementById("answers-list").hidden = false;
|
||||||
http("GET", `/api/v1/questions/${g_live_question.ID}/answers`, (body) => {
|
http("GET", `/api/v1/questions/${g_live_question.ID}/answers`, (body) => {
|
||||||
let answers = JSON.parse(body);
|
let answers = JSON.parse(body);
|
||||||
let result = "";
|
let result = "";
|
||||||
for (let i of answers)
|
for (let i of answers)
|
||||||
result += `<li>${i.Text}</li>`;
|
result += `<li>${i.Text}</li>`;
|
||||||
document.getElementById("answers-list").innerHTML = result;
|
document.getElementById("answers-list").innerHTML = `<ul>${result}</ul>`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue