diff options
author | tdro <tdro@noreply.example.com> | 2023-04-12 20:12:42 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-04-12 20:12:42 -0400 |
commit | 34c734a89530b5d83b1a4a5060ea7a887d9ccafd (patch) | |
tree | 371b9a91639ac2321e25db2db7d39473bffd1330 /static | |
parent | 1a083c05f74ba929da347263c91f1479bb66d221 (diff) | |
download | canory-34c734a89530b5d83b1a4a5060ea7a887d9ccafd.tar.gz canory-34c734a89530b5d83b1a4a5060ea7a887d9ccafd.tar.bz2 canory-34c734a89530b5d83b1a4a5060ea7a887d9ccafd.zip |
static/js/refresh: Convert dates to unix
Can't avoid Date.parse on lastModified ISO 8601?
Change label Refresh -> Update
Handle no cache?
Diffstat (limited to 'static')
-rw-r--r-- | static/js/refresh.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/static/js/refresh.ts b/static/js/refresh.ts index d308014..2a8a089 100644 --- a/static/js/refresh.ts +++ b/static/js/refresh.ts @@ -10,16 +10,16 @@ http.setRequestHeader("Pragma", "no-cache"); http.setRequestHeader("Cache-Control", "no-cache"); http.send(); + return http; } function update() { const url = self.location.href.split("#")[0].split("?")[0]; check(url, "HEAD", function (request) { - const local = document.querySelector('meta[name="last-modified"]').content; const remote = request.getResponseHeader("last-modified") || local; - const localSecond = local.substring(0, local.length - 5); - const remoteSecond = remote.substring(0, remote.length - 5); - const modified = localSecond !== remoteSecond; + const local = document.querySelector('meta[name="last-modified"]').content; + const modified = Date.parse(document.lastModified) !== Date.parse(remote); + const drift = Date.parse(remote) - Date.parse(local); if (modified) { const indicator = document.querySelector("a[data-update]"); @@ -30,6 +30,7 @@ self.removeEventListener("blur", update); console.log("R: " + remote); console.log("L: " + local); + console.log("D: " + drift); console.log("M: " + modified); } }); |