Add /api/info endpoint for build time, title.js, UI tweaks
This commit is contained in:
1 parent
bdd3173e5f
commit
6556d62f17
10 files changed
+77
-20
No files matched your search
@@ -0,0 +1,18 @@
|
||||
let buildTime = 0;
|
||||
|
||||
fetch('/api/info').then(r => r.json()).then(data => {
|
||||
buildTime = data.buildTime || 0;
|
||||
updateTitle();
|
||||
setInterval(updateTitle, 1000);
|
||||
});
|
||||
|
||||
function updateTitle() {
|
||||
if (!buildTime) { document.title = '// gott'; return; }
|
||||
const s = Math.floor(Date.now() / 1000) - buildTime;
|
||||
let ago;
|
||||
if (s < 60) ago = `${s} Sekunde${s !== 1 ? 'n' : ''}`;
|
||||
else if (s < 3600) { const m = Math.floor(s / 60); ago = `${m} Minute${m !== 1 ? 'n' : ''}`; }
|
||||
else if (s < 86400) { const h = Math.floor(s / 3600); ago = `${h} Stunde${h !== 1 ? 'n' : ''}`; }
|
||||
else { const d = Math.floor(s / 86400); ago = `${d} Tag${d !== 1 ? 'en' : ''}`; }
|
||||
document.title = `// gott :: Build vor ${ago}`;
|
||||
}
|
||||
Reference in new issue
Block a user