let timefmt = null; const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; function padTime(x) { return (x < 10) ? '0' + x : x; } function updateTime() { let date = new Date(); let h = date.getHours(); let m = date.getMinutes(); let s = date.getSeconds(); let dd = date.getDate(); let dm = date.getMonth(); let dy = date.getFullYear(); if (timefmt == 12) // default to 24 h = (h + 11) % 12 + 1; let str_t = padTime(h) + '\u00A0\u00A0' + padTime(m) + '\u00A0\u00A0' + padTime(s); let str_d = dd + ' ' + months[dm] + ' ' + dy; document.getElementById('timeval').textContent = str_t; document.getElementById('dateval').textContent = str_d; } function startTempo() { timefmt = localStorage['timefmt']; let fg = localStorage['fg']; if (fg) document.body.style.color = fg; let fg_date = localStorage['fg_date']; if (fg_date) document.getElementById('dateval').style.color = fg_date; let bg = localStorage['bg']; if (bg) document.body.style.backgroundColor = bg; updateTime(); setTimeout(function() { updateTime(); setInterval(updateTime, 1000) }, 1000 - (new Date()).getTime() % 1000); } window.onload = startTempo; document.addEventListener('contextmenu', function(e) { e.preventDefault() });