diff options
-rw-r--r-- | assets/js/index.js | 9 | ||||
-rw-r--r-- | static/js/refresh.ts | 9 | ||||
-rw-r--r-- | themes/default/layouts/partials/navigator-middle.html | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/assets/js/index.js b/assets/js/index.js index 98b53d2..f2c4ae4 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -75,15 +75,15 @@ 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]"); check(url, "GET"); @@ -93,6 +93,7 @@ self.removeEventListener("blur", update); console.log("R: " + remote); console.log("L: " + local); + console.log("D: " + drift); console.log("M: " + modified); } }); 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); } }); diff --git a/themes/default/layouts/partials/navigator-middle.html b/themes/default/layouts/partials/navigator-middle.html index 688963a..6521119 100644 --- a/themes/default/layouts/partials/navigator-middle.html +++ b/themes/default/layouts/partials/navigator-middle.html @@ -22,7 +22,7 @@ {{ safeHTML $icon }} {{ safeHTML $refresh }} <small>{{ $label }}</small> - <small>Refresh</small> + <small>Update</small> </a> </icon-button> |