Added informations about forms filled and being filled up
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
<head>
|
||||
<div th:replace="~{html-head}"/>
|
||||
<link rel="stylesheet" th:href="@{/css/showform.css}"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div th:replace="~{header}"/>
|
||||
<script th:src="@{/webjars/jquery/1.9.1/jquery.min.js}" type="text/javascript"></script>
|
||||
<script th:src="@{/webjars/lodash/4.17.21/lodash.js}" type="text/javascript"></script>
|
||||
<main>
|
||||
|
||||
<ol id="questions-list">
|
||||
</ol>
|
||||
|
||||
<span id="error-textbox" style="color: red"></span>
|
||||
|
||||
<script th:inline="javascript">
|
||||
/*<![CDATA[*/
|
||||
var formid = /*[[${formId}]]*/ -1;
|
||||
/*]]>*/
|
||||
</script>
|
||||
<script>
|
||||
function error(txt) {
|
||||
console.log(txt)
|
||||
$("#error-textbox").text(txt)
|
||||
}
|
||||
QTYPES = {
|
||||
"DCC": makeAnswerBlockBCC,
|
||||
}
|
||||
|
||||
// question position -> question data
|
||||
questiondata=[]
|
||||
|
||||
function getdata() {
|
||||
$.ajax({
|
||||
url: "/questions/getformdata/"+formid,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
success: function(res) {
|
||||
console.log(res)
|
||||
if(!res["success"]) {
|
||||
console.log(res["message"])
|
||||
error(res["message"])
|
||||
return
|
||||
}
|
||||
questiondata=res["data"]
|
||||
|
||||
for(let qd of questiondata) {
|
||||
content = QTYPES[qd["type"]](qd["qid"],qd["qvalue"],qd["avalue"])
|
||||
$(`#questions-list`).append(content)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function makeAnswerBlockBCC(id,qvalue,avalue) {
|
||||
switch(avalue["type"]){
|
||||
case 4:
|
||||
dcc = "carré"
|
||||
break
|
||||
case 2:
|
||||
dcc = "duo"
|
||||
break
|
||||
default:
|
||||
dcc = "cache"
|
||||
}
|
||||
html = `
|
||||
<li class="dcc-box" id="q-${id}">
|
||||
<h5>${_.escape(qvalue["text"])}</h5>
|
||||
Réponse ${dcc}: ${_.escape(avalue["answer"])}
|
||||
</li>
|
||||
`
|
||||
out = $('<li/>').html(html).contents()
|
||||
return out
|
||||
}
|
||||
|
||||
getdata()
|
||||
</script>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user