aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-04-08 22:26:43 -0400
committertdro <tdro@noreply.example.com>2023-04-08 22:26:43 -0400
commit242e7870c809e1a89cc00aa4caa8f6e0ca8f065f (patch)
tree82f28ad51e8b3e38f102a8eaf825cb78b52ad180
parent787b97a30f788957eb471f2ed3f08b66a405b092 (diff)
downloadcanory-242e7870c809e1a89cc00aa4caa8f6e0ca8f065f.tar.gz
canory-242e7870c809e1a89cc00aa4caa8f6e0ca8f065f.tar.bz2
canory-242e7870c809e1a89cc00aa4caa8f6e0ca8f065f.zip
static/js/refresh: Hook into blur
Keep it simple
-rw-r--r--assets/css/default.css2
-rw-r--r--assets/js/index.js19
-rw-r--r--config.json5
-rw-r--r--config.toml2
-rw-r--r--config.yaml2
-rw-r--r--static/js/refresh.ts19
-rw-r--r--themes/default/layouts/partials/base-head.html1
7 files changed, 14 insertions, 36 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index e5eaa16..2cd30b3 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -1386,7 +1386,7 @@ icon-button a[data-update="refresh"] small:nth-of-type(1) {
icon-button a[data-update="refresh"] svg:nth-of-type(2),
icon-button a[data-update="refresh"] small:nth-of-type(2) {
- display: initial;
+ display: block;
}
icon-button a:hover {
diff --git a/assets/js/index.js b/assets/js/index.js
index 22c6cb7..87cb4b1 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -76,7 +76,7 @@
http.setRequestHeader("Cache-Control", "no-cache");
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;
@@ -90,21 +90,14 @@
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);
})();
(function() {
const options = "targetWindow,width=700,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
diff --git a/config.json b/config.json
index c977045..8ae6924 100644
--- a/config.json
+++ b/config.json
@@ -87,10 +87,7 @@
"production": false,
"referrer": "no-referrer",
"robots": "index,follow",
- "canonical": null,
- "refresh": {
- "milliseconds": null
- }
+ "canonical": null
},
"webmanifest": {
"name": "Micro Blog",
diff --git a/config.toml b/config.toml
index 3801026..d615726 100644
--- a/config.toml
+++ b/config.toml
@@ -82,8 +82,6 @@ enableRobotsTXT = true
referrer = "no-referrer"
robots = "index,follow"
- [params.site.refresh]
-
[params.webmanifest]
name = "Micro Blog"
shortName = "Micro"
diff --git a/config.yaml b/config.yaml
index bc69a0d..539ba0c 100644
--- a/config.yaml
+++ b/config.yaml
@@ -72,8 +72,6 @@ params:
referrer: no-referrer
robots: index,follow
canonical:
- refresh:
- milliseconds:
webmanifest:
name: Micro Blog
shortName: Micro
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);
})();
diff --git a/themes/default/layouts/partials/base-head.html b/themes/default/layouts/partials/base-head.html
index acedcf0..1fdfe4e 100644
--- a/themes/default/layouts/partials/base-head.html
+++ b/themes/default/layouts/partials/base-head.html
@@ -42,7 +42,6 @@
<!-- Extra Meta Tags -->
<meta name='base-url' content="{{ "" | absURL }}" />
-<meta name='refresh' content="{{ .Site.Params.site.refresh.milliseconds }}" />
<meta name='last-modified' content="{{ now.UTC.Format "Mon, 02 Jan 2006 15:04:05 GMT" }}" />
<!-- Link Tags -->