Added keyboard shortcuts
This commit is contained in:
parent
e9ea6a6a7e
commit
69a911e957
|
@ -1,3 +1,17 @@
|
|||
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 });
|
||||
|
@ -14,18 +28,4 @@ function autoReload() {
|
|||
countdown();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
var checkedGroups = 0;
|
||||
|
||||
function monitorRadio() {
|
||||
document.querySelectorAll('input[type="radio"]').forEach(function (el) {
|
||||
el.addEventListener('change', incCounter, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
function incCounter() {
|
||||
checkedGroups++;
|
||||
}
|
||||
|
||||
function checkCount() {
|
||||
if (checkedGroups === 5) {
|
||||
countdown();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", function (event) {
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkCount();
|
||||
|
||||
switch (event.key) {
|
||||
case "a":
|
||||
checkedGroups++;
|
||||
getid = 'a'+checkedGroups;
|
||||
document.getElementById(getid).checked = true;
|
||||
checkCount();
|
||||
break;
|
||||
case "b":
|
||||
checkedGroups++;
|
||||
getid = 'b'+checkedGroups;
|
||||
document.getElementById(getid).checked = true;
|
||||
checkCount();
|
||||
break;
|
||||
default:
|
||||
checkCount();
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
}, true);
|
|
@ -9,6 +9,7 @@
|
|||
<title>{{ title }}</title>
|
||||
<script type="text/javascript" src="/js/toggle.js?t={{ epoch }}"></script>
|
||||
<script type="text/javascript" src="/js/autoReload.js?t={{ epoch }}"></script>
|
||||
<script type="text/javascript" src="/js/shortcut.js?t={{ epoch }}"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/css/base.css?t={{ epoch }}">
|
||||
<link rel="stylesheet" type="text/css" href="/css/colors.css?t={{ epoch }}">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='apple-touch-icon.png') }}">
|
||||
|
@ -38,6 +39,7 @@
|
|||
<script type="text/javascript">
|
||||
initToggle();
|
||||
autoReload();
|
||||
monitorRadio();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
Loading…
Reference in New Issue