31 lines
826 B
JavaScript
31 lines
826 B
JavaScript
function countdown() {
|
|
var timeleft = 3;
|
|
var reloadTimer = setInterval(function () {
|
|
if (timeleft <= 0) {
|
|
document.getElementById("next").innerHTML = 0;
|
|
clearInterval(reloadTimer);
|
|
window.location.replace('/')
|
|
} else {
|
|
document.getElementById("next").innerHTML = timeleft;
|
|
}
|
|
timeleft -= 1;
|
|
}, 1000);
|
|
}
|
|
|
|
function autoReload() {
|
|
document.querySelectorAll('input[type="radio"]').forEach(function (el) {
|
|
el.addEventListener('change', checkForm, { once: true });
|
|
});
|
|
|
|
const choices = [];
|
|
|
|
function checkForm(e) {
|
|
item = e.target.id.charAt(1);
|
|
if (choices.indexOf(item) === -1) {
|
|
choices.push(item);
|
|
}
|
|
if (choices.length === 5) {
|
|
countdown();
|
|
}
|
|
}
|
|
} |