From 5a0a5673486bd4ee8b22c704bee949da3e538ffc Mon Sep 17 00:00:00 2001 From: gpkvt Date: Sun, 4 Jun 2023 02:59:37 +0200 Subject: [PATCH] Added autoreload --- config.ini | 2 +- static/js/autoReload.js | 30 ++++++++++++++++++++++++++++++ templates/index.html | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 static/js/autoReload.js diff --git a/config.ini b/config.ini index f8a090e..3398905 100644 --- a/config.ini +++ b/config.ini @@ -9,7 +9,7 @@ theme = dark [i18n] lang = de -more = Mehr Fragen +more = Weiter »»» title = A oder B separator = oder questions_prefix = Es gibt derzeit diff --git a/static/js/autoReload.js b/static/js/autoReload.js new file mode 100644 index 0000000..8627a69 --- /dev/null +++ b/static/js/autoReload.js @@ -0,0 +1,30 @@ +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); + } +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 84866c5..36fe93b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,6 +8,7 @@ {{ title }} + @@ -69,6 +70,7 @@