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
|
|
|
}
|
|
|
|
|
|
|
|
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-04 22:08:01 +02:00
|
|
|
value = checkedGroups[0];
|
|
|
|
removeId();
|
|
|
|
getid = 'a'+value;
|
2023-06-04 21:13:12 +02:00
|
|
|
document.getElementById(getid).checked = true;
|
|
|
|
checkCount();
|
|
|
|
break;
|
|
|
|
case "b":
|
2023-06-04 22:08:01 +02:00
|
|
|
value = checkedGroups[0];
|
|
|
|
removeId();
|
|
|
|
getid = 'b'+value;
|
2023-06-04 21:13:12 +02:00
|
|
|
document.getElementById(getid).checked = true;
|
|
|
|
checkCount();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
checkCount();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}, true);
|