aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-10-25 00:00:00 +0000
committertdro <tdro@noreply.example.com>2024-10-25 00:00:00 +0000
commit4ee5a7da311b93d11cdff7a04cb502181eaed1b9 (patch)
tree9f3421a5f0319de7f85038cc57f60080c07745a8
parent2552497d91b01be75de080d7b3321566cfb6a619 (diff)
downloadcanory-4ee5a7da311b93d11cdff7a04cb502181eaed1b9.tar.gz
canory-4ee5a7da311b93d11cdff7a04cb502181eaed1b9.tar.bz2
canory-4ee5a7da311b93d11cdff7a04cb502181eaed1b9.zip
static/js/update: Try reset
-rw-r--r--assets/js/index.js11
-rw-r--r--static/js/update.ts6
2 files changed, 15 insertions, 2 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index d82870e..949aae5 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -113,13 +113,17 @@
const url = self.location.href.split("#")[0].split("?")[0];
const indicator = document.querySelector("a[data-update]");
if (indicator === null || indicator.dataset.update === "refresh") return;
- indicator.cloneNode();
+ const anchor = indicator.cloneNode();
fetch(url, "HEAD", function(request) {
const local = document.querySelector('meta[name="last-modified"]').content || document.lastModified;
const remote = request.getResponseHeader("last-modified") || '';
const modified = Date.parse(remote || local) > Date.parse(local);
const drift = Date.parse(remote || local) - Date.parse(local);
if (drift < 10000) return;
+ function reset() {
+ indicator.href = anchor.href;
+ indicator.dataset.update = anchor.dataset.update;
+ }
stamps = JSON.parse(sessionStorage[key + ".urls"]);
if (stamps[url] === remote) return;
stamps[url] = remote;
@@ -129,6 +133,11 @@
indicator.href = url.replace(/^https:/, "http:");
indicator.removeAttribute("id");
indicator.dataset.update = "refresh";
+ indicator.addEventListener("click", function(event) {
+ event.preventDefault();
+ reset();
+ self.location.reload();
+ });
console.log("INFO: R: " + remote);
console.log("INFO: L: " + local);
console.log("INFO: D: " + drift);
diff --git a/static/js/update.ts b/static/js/update.ts
index f6461eb..3377dd0 100644
--- a/static/js/update.ts
+++ b/static/js/update.ts
@@ -42,7 +42,6 @@
function reset() {
indicator.href = anchor.href;
- indicator.setAttribute("id", anchor.id);
indicator.dataset.update = anchor.dataset.update;
}
@@ -56,6 +55,11 @@
indicator.href = url.replace(/^https:/, "http:");
indicator.removeAttribute("id");
indicator.dataset.update = "refresh";
+ indicator.addEventListener("click", function(event) {
+ event.preventDefault();
+ reset();
+ self.location.reload();
+ });
console.log("INFO: R: " + remote);
console.log("INFO: L: " + local);
console.log("INFO: D: " + drift);