parent
619425e3d2
commit
765770c9e0
|
@ -127,7 +127,7 @@ bg-dark
|
||||||
<li><a href="https://www3.gobiernodecanarias.org/medusa/edublog/ieselchapatal/">IES El Chapatal</a></li>
|
<li><a href="https://www3.gobiernodecanarias.org/medusa/edublog/ieselchapatal/">IES El Chapatal</a></li>
|
||||||
<li><a href="https://www3.gobiernodecanarias.org/medusa/edublog/ieslalaboraldelalaguna/">IES La Laboral</a></li>
|
<li><a href="https://www3.gobiernodecanarias.org/medusa/edublog/ieslalaboraldelalaguna/">IES La Laboral</a></li>
|
||||||
<li><a href="https://rcasys.com/">RCA Systems</a></li>
|
<li><a href="https://rcasys.com/">RCA Systems</a></li>
|
||||||
<li><a href="htts://www.ull.es/">Universidad de La Laguna</a></li>
|
<li><a href="https://www.ull.es/">Universidad de La Laguna</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -156,6 +156,75 @@ bg-dark
|
||||||
baguetteBox.run('div#content', {
|
baguetteBox.run('div#content', {
|
||||||
ignoreClass: 'islink',
|
ignoreClass: 'islink',
|
||||||
captions: function(element){var i=element.getElementsByTagName('img')[0];return i===undefined?'':i.alt;}});
|
captions: function(element){var i=element.getElementsByTagName('img')[0];return i===undefined?'':i.alt;}});
|
||||||
</script>
|
</script><script>(function () {
|
||||||
|
function submit(ev) {
|
||||||
|
const form = ev.target;
|
||||||
|
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
|
const answers = {};
|
||||||
|
const [,formId] = form.id.split("-");
|
||||||
|
|
||||||
|
for (let i = 0; i < form.length; i++) {
|
||||||
|
var input = form[i];
|
||||||
|
|
||||||
|
// extract question id (qid) and answer id (aid)
|
||||||
|
var [,,qid,,aid] = input.id.split("-");
|
||||||
|
|
||||||
|
if ( qid && !(qid in answers) )
|
||||||
|
answers[qid] = [];
|
||||||
|
|
||||||
|
switch (input.type) {
|
||||||
|
case "checkbox":
|
||||||
|
case "radio":
|
||||||
|
if (input.checked)
|
||||||
|
answers[qid].push(aid);
|
||||||
|
console.log(input.type, input.id, qid, aid, input.checked);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "select-one":
|
||||||
|
case "text":
|
||||||
|
case "textarea":
|
||||||
|
case "date":
|
||||||
|
case "datetime-local":
|
||||||
|
if (input.value)
|
||||||
|
answers[qid].push(input.value);
|
||||||
|
console.log(input.type, input.id, qid, input.value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.log("unknown form element type:", input.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open("POST", form.action, true);
|
||||||
|
request.setRequestHeader("OCS-APIRequest", "true");
|
||||||
|
request.setRequestHeader("Accept", "application/json");
|
||||||
|
request.setRequestHeader("Content-Type", "application/json");
|
||||||
|
request.onload = function () {
|
||||||
|
const message = document.getElementById("form-" + formId + "-messages");
|
||||||
|
const form = document.getElementById("form-" + formId);
|
||||||
|
const success = document.getElementById("form-" + formId + "-success");
|
||||||
|
const response = JSON.parse(this.response);
|
||||||
|
|
||||||
|
if (this.status == 200) {
|
||||||
|
// success
|
||||||
|
form.style.display = "none";
|
||||||
|
success.style.display = "block";
|
||||||
|
} else {
|
||||||
|
message.innerHTML = '<div class="alert alert-danger" role="alert">' +
|
||||||
|
this.statusText + "(" + this.status + "): " +
|
||||||
|
response['ocs']['meta']['message'] +
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
request.send(JSON.stringify({'formId': formId, 'answers': answers}));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < document.forms.length; i++)
|
||||||
|
document.forms[i].onsubmit = submit;
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -38,4 +38,4 @@ A lo largo de los años de vida de {{% blog_title %}} hemos colaborado con múlt
|
||||||
* [IES El Chapatal](https://www3.gobiernodecanarias.org/medusa/edublog/ieselchapatal/)
|
* [IES El Chapatal](https://www3.gobiernodecanarias.org/medusa/edublog/ieselchapatal/)
|
||||||
* [IES La Laboral](https://www3.gobiernodecanarias.org/medusa/edublog/ieslalaboraldelalaguna/)
|
* [IES La Laboral](https://www3.gobiernodecanarias.org/medusa/edublog/ieslalaboraldelalaguna/)
|
||||||
* [RCA Systems](https://rcasys.com/)
|
* [RCA Systems](https://rcasys.com/)
|
||||||
* [Universidad de La Laguna](htts://www.ull.es/)
|
* [Universidad de La Laguna](https://www.ull.es/)
|
||||||
|
|
Loading…
Reference in New Issue