From a82a5ed69075d1069d3bbe64db5a162906062611 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 15 Apr 2022 02:54:39 -0700 Subject: make colours configurable --- tempo.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'tempo.js') diff --git a/tempo.js b/tempo.js index f280142..ae3fa22 100644 --- a/tempo.js +++ b/tempo.js @@ -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) }, -- cgit v1.2.3-70-g09d2