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 --- COPYING | 24 +++++++++++------------- manifest.json | 2 +- options.html | 20 ++++++++++++++------ options.js | 28 +++++++++++++++++----------- tempo.html | 8 ++++---- tempo.js | 34 +++++++++++++++++++++------------- 6 files changed, 68 insertions(+), 48 deletions(-) diff --git a/COPYING b/COPYING index 415fdd6..633f1a7 100644 --- a/COPYING +++ b/COPYING @@ -1,21 +1,19 @@ -The MIT License (MIT) +Copyright 2014 David Vazgenovich Shakaryan -Copyright (c) 2014 David Vazgenovich Shakaryan +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/manifest.json b/manifest.json index 281f88c..0d646e6 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Tempo", - "version": "0.6", + "version": "0.7", "description": "Replace new tab page with a clock.", "icons": { diff --git a/options.html b/options.html index 53238ef..66f64e5 100644 --- a/options.html +++ b/options.html @@ -1,16 +1,24 @@ - - + + + Tempo options - Tempo options - +

Time format:

-
- +
+ +
+
+

+ +
+
+

+
diff --git a/options.js b/options.js index 205cc2e..c3f008b 100644 --- a/options.js +++ b/options.js @@ -1,32 +1,38 @@ function saveOptions() { - var timeformat; + let timefmt; if (document.getElementById('t24').checked) - timeformat = 24; + timefmt = 24; else if (document.getElementById('t12').checked) - timeformat = 12; - else - return; + timefmt = 12; + localStorage['timefmt'] = timefmt; - localStorage['timeformat'] = timeformat; + localStorage['fg'] = document.getElementById('fg').value; + localStorage['bg'] = document.getElementById('bg').value; - var status = document.getElementById('status'); + let status = document.getElementById('status'); status.innerHTML = 'Options saved'; setTimeout(function() { status.innerHTML = '' }, 2000); } function restoreOptions() { // default to 24 for both unset and invalid - var timeformat = localStorage['timeformat'] || 24; - var option = document.getElementById('t' + timeformat) || + let timefmt = localStorage['timefmt'] || 24; + let timefmt_btn = document.getElementById('t' + timefmt) || document.getElementById('t24'); + timefmt_btn.checked = true; - option.checked = true; + let fg = localStorage['fg']; + if (fg) + document.getElementById('fg').value = fg; + let bg = localStorage['bg']; + if (bg) + document.getElementById('bg').value = bg; } function startOptions() { restoreOptions(); - document.querySelector('#save').addEventListener('click', saveOptions); + document.getElementById('save').addEventListener('click', saveOptions); } window.onload = startOptions; diff --git a/tempo.html b/tempo.html index 8d03208..d504dc3 100644 --- a/tempo.html +++ b/tempo.html @@ -1,12 +1,12 @@ - - + + + New Tab - New Tab - +
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