2023-06-04 22:08:01 +02:00
|
|
|
var checkedGroups = [1,2,3,4,5];
|
|
|
|
var countdownActive = false;
|
2023-06-04 21:13:12 +02:00
|
|
|
|
|
|
|
function monitorRadio() {
|
|
|
|
document.querySelectorAll('input[type="radio"]').forEach(function (el) {
|
2023-06-04 22:08:01 +02:00
|
|
|
el.addEventListener('change', removeId, { once: true });
|
2023-06-04 21:13:12 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-04 22:08:01 +02:00
|
|
|
function removeId(e) {
|
|
|
|
if (e) {
|
|
|
|
value = e.target.id.charAt(1);
|
|
|
|
} else {
|
|
|
|
value = checkedGroups[0];
|
|
|
|
}
|
|
|
|
checkedGroups = checkedGroups.filter(function(item) {
|
|
|
|
return item != value;
|
|
|
|
})
|
2023-06-04 21:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkCount() {
|
2023-06-04 22:08:01 +02:00
|
|
|
if (checkedGroups.length == 0) {
|
|
|
|
if (countdownActive == false) {
|
|
|
|
countdown();
|
|
|
|
}
|
|
|
|
countdownActive = true;
|
|
|
|
return true;
|
2023-06-04 21:13:12 +02:00
|
|
|
}
|
2023-06-04 22:08:01 +02:00
|
|
|
return false;
|
2023-06-04 21:13:12 +02:00
|
|
|
}
|
|
|
|
|
2023-06-05 10:31:28 +02:00
|
|
|
function check(choice) {
|
|
|
|
value = checkedGroups[0];
|
|
|
|
removeId();
|
|
|
|
getid = choice+value;
|
|
|
|
document.getElementById(getid).checked = true;
|
|
|
|
checkCount();
|
|
|
|
}
|
|
|
|
|
2023-06-04 21:13:12 +02:00
|
|
|
window.addEventListener("keydown", function (event) {
|
|
|
|
if (event.defaultPrevented) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-04 22:08:01 +02:00
|
|
|
if (checkCount()) {
|
|
|
|
return;
|
|
|
|
};
|
2023-06-04 21:13:12 +02:00
|
|
|
|
|
|
|
switch (event.key) {
|
|
|
|
case "a":
|
2023-06-05 10:31:28 +02:00
|
|
|
check("a");
|
2023-06-04 21:13:12 +02:00
|
|
|
break;
|
|
|
|
case "b":
|
2023-06-05 10:31:28 +02:00
|
|
|
check("b");
|
2023-06-04 21:13:12 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
checkCount();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}, true);
|