diff options
Diffstat (limited to 'static')
-rw-r--r-- | static/js/refresh.ts | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/static/js/refresh.ts b/static/js/refresh.ts index 5d44854..2033ea3 100644 --- a/static/js/refresh.ts +++ b/static/js/refresh.ts @@ -12,7 +12,7 @@ http.send(); } - function update(id) { + function update() { const url = self.location.href; check(url, "HEAD", function (request) { const local = document.querySelector('meta[name="last-modified"]').content; @@ -27,20 +27,13 @@ indicator.href = url; indicator.removeAttribute("id"); indicator.dataset.update = "refresh"; - clearInterval(id); + self.removeEventListener("blur", update); + console.log("R: " + remote); + console.log("L: " + local); + console.log("M: " + modified); } - console.log("R: " + remote); - console.log("L: " + local); - console.log("M: " + modified); }); } - self.addEventListener("load", function () { - let meta = document.querySelector('meta[name="refresh"]'); - if (meta) meta = document.querySelector('meta[name="refresh"]').content; - const interval = meta || 3600000; - const monitor = setInterval(function () { - if (navigator.onLine) update(monitor); - }, interval); - }); + self.addEventListener("blur", update); })(); |