abgame/static/js/autoReload.js

30 lines
815 B
JavaScript

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();
}
}
function countdown() {
var timeleft = 3;
var reloadTimer = setInterval(function () {
if (timeleft <= 0) {
clearInterval(reloadTimer);
window.location.replace('/')
} else {
document.getElementById("next").innerHTML = timeleft;
}
timeleft -= 1;
}, 1000);
}
}