diff options
author | FChannel <> | 2021-10-24 10:40:45 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 48fefb76c0a908cc3fa00abc9c090ce3ac8cb560 (patch) | |
tree | a7a24aec9f43222949e1f004fd5cd8a247e5024e /views/js/timer.js | |
parent | 65e79e6a743f447f320595dafec530212a568b9d (diff) |
gofiber conversion, index, board posts, board post hooked up
Diffstat (limited to 'views/js/timer.js')
-rw-r--r-- | views/js/timer.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/views/js/timer.js b/views/js/timer.js new file mode 100644 index 0000000..d8be9de --- /dev/null +++ b/views/js/timer.js @@ -0,0 +1,38 @@ +var timerCount; +var timerToggle = false; +var timer; +const contentLoadHandler = function(event){ + timerToggle = !!document.getElementById("autoreload-checkbox").checked; + if(timerToggle){ + timerCount = 45; + document.getElementById("autoreload-countdown").innerHTML = "45"; + document.getElementById("autoreload-countdown").style.visibility = "visible"; + timer = setInterval(timerFunction, 1000); + document.removeEventListener("DOMContentLoaded", contentLoadHandler, false); + } +}; + +document.addEventListener("DOMContentLoaded", contentLoadHandler, false); + +function timerFunction(){ + timerCount--; + document.getElementById("autoreload-countdown").innerHTML = timerCount; + if(timerCount <= 0){ + document.getElementById("autoreload-countdown").innerHTML = "Refreshing..."; + clearInterval(timer); + location.reload(); + } +} + +function autoTimer(){ + timerToggle = !timerToggle; + if(timerToggle === true){ + timerCount = 45; + document.getElementById("autoreload-countdown").innerHTML = "45"; + document.getElementById("autoreload-countdown").style.visibility = "visible"; + timer = setInterval(timerFunction, 1000); + }else{ + clearInterval(timer); + document.getElementById("autoreload-countdown").style.visibility = "hidden"; + } +} |