diff options
author | tdro <tdro@noreply.example.com> | 2023-04-08 22:26:43 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-04-08 22:26:43 -0400 |
commit | 242e7870c809e1a89cc00aa4caa8f6e0ca8f065f (patch) | |
tree | 82f28ad51e8b3e38f102a8eaf825cb78b52ad180 /static | |
parent | 787b97a30f788957eb471f2ed3f08b66a405b092 (diff) | |
download | canory-242e7870c809e1a89cc00aa4caa8f6e0ca8f065f.tar.gz canory-242e7870c809e1a89cc00aa4caa8f6e0ca8f065f.tar.bz2 canory-242e7870c809e1a89cc00aa4caa8f6e0ca8f065f.zip |
static/js/refresh: Hook into blur
Keep it simple
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); })(); |