19 lines
704 B
JavaScript
19 lines
704 B
JavaScript
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}`;
|
|
}
|