diff options
author | Simon Rettberg | 2024-07-02 14:48:12 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-07-02 14:48:12 +0200 |
commit | df545c1bacce581eb83a48e015f5a2d8b27144f7 (patch) | |
tree | df4615ec56ee38373e12cb8488919c16df2b5dae /modules-available/main/templates/page-main.html | |
parent | Update/Cleanup translations (diff) | |
download | slx-admin-df545c1bacce581eb83a48e015f5a2d8b27144f7.tar.gz slx-admin-df545c1bacce581eb83a48e015f5a2d8b27144f7.tar.xz slx-admin-df545c1bacce581eb83a48e015f5a2d8b27144f7.zip |
[main] Try to avoid false clock drift warnings
If the browser tries to recover the state of a page after a restart, it
will re-check for clock drift using stale data. Let's hope the browser
will also restore sessionStorage in this case; we store the time of
check in there, to prevent another check after the page is restored from
cache.
Diffstat (limited to 'modules-available/main/templates/page-main.html')
-rw-r--r-- | modules-available/main/templates/page-main.html | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules-available/main/templates/page-main.html b/modules-available/main/templates/page-main.html index 1b7cc62d..ee85220e 100644 --- a/modules-available/main/templates/page-main.html +++ b/modules-available/main/templates/page-main.html @@ -5,11 +5,13 @@ <script type="application/javascript"><!-- document.addEventListener("DOMContentLoaded", function () { - if (Date.now && Math.abs(Date.now() / 1000 - {{now}}) > 300) { + if (Date.now && Math.abs(Date.now() / 1000 - {{now}}) > 300 + && (!window.sessionStorage || window.sessionStorage.getItem('nau') != {{now}})) { $('#browser-time').text(new Date().toLocaleString()); $('#server-time').text(new Date({{now}} * 1000).toLocaleString()); $('#time-warner').show(); } + if (window.sessionStorage) window.sessionStorage.setItem('nau', {{now}}); }); //--></script> |