abgame/static/js/autoReload.js

31 lines
826 B
JavaScript
Raw Normal View History

2023-06-04 21:13:12 +02:00
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);
}
2023-06-04 02:59:37 +02:00
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();
}
}
}