diff options
author | Andrew Dolgov <[email protected]> | 2021-04-08 19:54:49 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-04-08 19:54:49 +0300 |
commit | ca5c66775a1c5d7928931cfead8ae4ac9d7b479a (patch) | |
tree | 0c3e8653fad3c090c466d6fb2ec3a80a786da59c /js | |
parent | 787cb6732840a7f0bb1d28bd076e8d16f329a59a (diff) |
show git version in the UI
Diffstat (limited to 'js')
-rw-r--r-- | js/app.js | 4 | ||||
-rw-r--r-- | js/reader.js | 22 |
2 files changed, 14 insertions, 12 deletions
@@ -39,6 +39,7 @@ const App = { _dl_progress_timeout: false, index_mode: "", last_mtime: -1, + version: "UNKNOWN", csrf_token: "", init: function() { let refreshed_files = 0; @@ -97,6 +98,7 @@ const App = { if (event.data == 'client-reload') { localforage.setItem("epube.cache-timestamp", App.last_mtime); + localforage.setItem("epube.cache-version", App.version); window.location.reload() } @@ -183,7 +185,7 @@ const App = { refreshCache: function(force) { if ('serviceWorker' in navigator) { localforage.getItem("epube.cache-timestamp").then(function(stamp) { - console.log('stamp', stamp, 'last mtime', App.last_mtime); + console.log('stamp', stamp, 'last mtime', App.last_mtime, 'version', App.version); if (force || stamp != App.last_mtime) { console.log('asking worker to refresh cache'); diff --git a/js/reader.js b/js/reader.js index b1db806..a38513e 100644 --- a/js/reader.js +++ b/js/reader.js @@ -322,17 +322,17 @@ const Reader = { }); }); - localforage.getItem("epube.cache-timestamp").then(function(stamp) { - let msg = "V: "; - - if (parseInt(stamp)) - msg += new Date(stamp*1000).toLocaleString("en-GB"); - else - msg += "Unknown"; - - msg += " (" + (App.isOnline() ? "Online" : "Offline") + ")"; - - $(".last-mod-timestamp").text(msg) + Promise.all([ + localforage.getItem("epube.cache-timestamp"), + localforage.getItem("epube.cache-version") + ]).then((res) => { + const stamp = res[0]; + const version = res[1]; + + $(".last-mod-timestamp").html(`${version} + — ${parseInt(stamp) ? new Date(stamp*1000).toLocaleString("en-GB") : "Unknown"} + (${App.isOnline() ? `<span class='text-success'>Online</span>` : `<span class='text-danger'>Offline</span>`}) + `); }); localforage.getItem("epube.fontFamily").then(function(font) { |