diff options
author | sageman_ <sageman@anomine.net> | 2021-07-04 13:45:13 +0200 |
---|---|---|
committer | sageman_ <sageman@anomine.net> | 2021-07-04 13:45:13 +0200 |
commit | bc868ba51864f2f1569f942cc44b01d631d0d337 (patch) | |
tree | e95d6a3d54349d416cf7f271bb2319f3934943e1 /static/js/timer.js | |
parent | d287a2d0bb19f6a7eef682cd411e0e7cc31c1e3d (diff) | |
parent | 2d06abf5049e67e05c068461908c492f43ff4026 (diff) |
Merge branch 'development' of https://github.com/FChannel0/FChannel-Server into faq-and-rules
# Conflicts:
# client.go
# static/faq.html
Diffstat (limited to 'static/js/timer.js')
-rw-r--r-- | static/js/timer.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/static/js/timer.js b/static/js/timer.js new file mode 100644 index 0000000..8f6516c --- /dev/null +++ b/static/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 = 5; + document.getElementById("autoreload-countdown").innerHTML = "5"; + 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 = 5; + document.getElementById("autoreload-countdown").innerHTML = "5"; + document.getElementById("autoreload-countdown").style.visibility = "visible"; + timer = setInterval(timerFunction, 1000); + }else{ + clearInterval(timer); + document.getElementById("autoreload-countdown").style.visibility = "hidden"; + } +}
\ No newline at end of file |