watchyourlan/internal/web/public/js/refresh.js
2025-03-18 22:04:12 +07:00

26 lines
No EOL
548 B
JavaScript

let ref = false;
let refInterval;
autoRefresh();
function toggleRefresh() {
ref = !ref;
localStorage.setItem("refAuto", ref);
autoRefresh();
}
function autoRefresh() {
ref = JSON.parse(localStorage.getItem("refAuto"));
document.getElementById("ref").checked = ref;
if (ref) {
const timeout = document.getElementById("ref-timeout").value;
console.log("Refresh timeout", timeout);
refInterval = setInterval(loadAddrs, timeout * 1000);
} else {
clearInterval(refInterval);
}
}