change refresh interval behaviour

This commit is contained in:
Alex Janka 2024-01-07 11:21:33 +11:00
parent 77e9b19d26
commit 878652c24a

View file

@ -10,9 +10,20 @@
<script type="text/javascript">
const api_url = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
refresh_interval = register();
refresh();
document.addEventListener("visibilitychange", () => {
if (document.hidden) {
clearInterval(refresh_interval);
} else {
refresh();
refresh_interval = register();
}
});
function register() {
refresh();
setInterval(refresh, 15000);
return setInterval(refresh, 10000);
}
function flash() {
@ -66,7 +77,7 @@
</script>
</head>
<body onload="register()"></body>
<body></body>
<button onclick="flash()">flash</button>
<div id="info"></div>