diff --git a/static/js/autoReload.js b/static/js/autoReload.js index 9f14a93..c998169 100644 --- a/static/js/autoReload.js +++ b/static/js/autoReload.js @@ -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); - } } \ No newline at end of file diff --git a/static/js/shortcut.js b/static/js/shortcut.js new file mode 100644 index 0000000..f5a51b8 --- /dev/null +++ b/static/js/shortcut.js @@ -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); diff --git a/templates/base.html b/templates/base.html index e5b33a0..76e3293 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,6 +9,7 @@ {{ title }} + @@ -38,6 +39,7 @@