diff options
Diffstat (limited to 'tempo.js')
-rw-r--r-- | tempo.js | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -1,5 +1,5 @@ -var timeformat = null; -var months = ['January', 'February', 'March', 'April', 'May', 'June', +let timefmt = null; +const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; function padTime(x) { @@ -7,29 +7,37 @@ function padTime(x) { } function updateTime() { - var date = new Date(); + let date = new Date(); - var h = date.getHours(); - var m = date.getMinutes(); - var s = date.getSeconds(); + let h = date.getHours(); + let m = date.getMinutes(); + let s = date.getSeconds(); - var dd = date.getDate(); - var dm = date.getMonth(); - var dy = date.getFullYear(); + let dd = date.getDate(); + let dm = date.getMonth(); + let dy = date.getFullYear(); - if (timeformat == 12) // default to 24 + if (timefmt == 12) // default to 24 h = (h + 11) % 12 + 1; - var str_t = padTime(h) + ' ' + padTime(m) + + let str_t = padTime(h) + ' ' + padTime(m) + '  ' + padTime(s); - var str_d = dd + ' ' + months[dm] + ' ' + dy; + let str_d = dd + ' ' + months[dm] + ' ' + dy; document.getElementById('timeval').innerHTML = str_t; document.getElementById('dateval').innerHTML = str_d; } function startTempo() { - timeformat = localStorage['timeformat']; + timefmt = localStorage['timefmt']; + + let fg = localStorage['fg']; + if (fg) + document.body.style.color = fg; + + let bg = localStorage['bg']; + if (bg) + document.body.style.backgroundColor = bg; updateTime(); setTimeout(function() { updateTime(); setInterval(updateTime, 1000) }, |