From a9358b6ffad0ac98a4e60f43beda24a22bc0224d Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sun, 10 Apr 2022 03:26:28 -0700 Subject: refactor and make Firefox-friendly --- index.html | 1 - manifest.json | 11 ++++++-- options.css | 84 ----------------------------------------------------------- options.html | 23 +++++++--------- options.js | 31 +++++++++------------- style.css | 1 - tempo.js | 17 ++++-------- 7 files changed, 36 insertions(+), 132 deletions(-) delete mode 100644 options.css diff --git a/index.html b/index.html index 154a404..50ddd97 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,6 @@ New Tab - diff --git a/manifest.json b/manifest.json index 4cfbc9a..4a0aac5 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Tempo", - "version": "0.3", + "version": "0.4", "description": "Replace the New Tab page with a time display.", @@ -11,7 +11,14 @@ "128": "icon/clock128.png" }, - "options_page": "options.html", + "options_ui": { + "page": "options.html", + "browser_style": true + }, + + "chrome_settings_overrides": { + "homepage": "index.html" + }, "chrome_url_overrides": { "newtab": "index.html" diff --git a/options.css b/options.css deleted file mode 100644 index 2cb09b9..0000000 --- a/options.css +++ /dev/null @@ -1,84 +0,0 @@ -body { - color: #222; - background-color: #222; - font-family: 'Lato', sans-serif; - padding: 0em; - margin: 0em; - - -webkit-user-select: none; - user-select: none; -} - -div#container { - width: 20em; - height: 11.2em; - padding: 1em; - margin: auto; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - - background-color: #ddd; - border-radius: 1em; -} - -h1 { - font-size: 1.6em; - text-align: center; - padding: 0em; - margin: 0em; -} - -div.section { - margin: 1em; -} - -div.section p { - margin: 0.2em 0em; -} - -div.section p.option { - margin-left: 1em; -} - -div.button { - text-align: center; -} - -button { - color: #ddd; - background-color: #222; - font-family: inherit; - font-size: inherit; - font-weight: bold; - padding: 1em; - border: 0em; - border-radius: 1em; -} - -button:hover { - background-color: #130; -} - -button:focus { - outline: 0em; -} - -div#status { - width: 20em; - height: 1em; - padding: 1em; - margin: auto; - position: absolute; - top: 18.4em; - right: 0; - bottom: 0; - left: 0; - - visibility: hidden; - color: #fff; - background-color: #390; - border-radius: 1em; -} diff --git a/options.html b/options.html index bbd2036..65f5e80 100644 --- a/options.html +++ b/options.html @@ -3,23 +3,18 @@ - - Tempo Options - + Tempo options -
-

Options

-
-

Time format:

-

-

-
-
- -
+
+

Time format:

+

+

-
Options saved.
+
+ +
+
diff --git a/options.js b/options.js index 0c640b4..205cc2e 100644 --- a/options.js +++ b/options.js @@ -1,29 +1,24 @@ -// Copyright 2014 David Vazgenovich Shakaryan -// Distributed under the terms of the GNU General Public License v2. -// See http://www.gnu.org/licenses/gpl-2.0.txt for the full license text. - function saveOptions() { - var timeformat = 24; - if(document.getElementById('t12').checked) { - var timeformat = 12; - } + var timeformat; + if (document.getElementById('t24').checked) + timeformat = 24; + else if (document.getElementById('t12').checked) + timeformat = 12; + else + return; localStorage['timeformat'] = timeformat; var status = document.getElementById('status'); - status.style['visibility'] = 'visible'; - - setTimeout(function() {status.style['visibility'] = 'hidden'}, 2000); + status.innerHTML = 'Options saved'; + setTimeout(function() { status.innerHTML = '' }, 2000); } function restoreOptions() { - var timeformat = localStorage['timeformat']; - - if(!timeformat) { - timeformat = 24; - } - - var option = document.getElementById('t' + timeformat); + // default to 24 for both unset and invalid + var timeformat = localStorage['timeformat'] || 24; + var option = document.getElementById('t' + timeformat) || + document.getElementById('t24'); option.checked = true; } diff --git a/style.css b/style.css index 94cf41a..2b4ac4c 100644 --- a/style.css +++ b/style.css @@ -5,7 +5,6 @@ body { padding: 0em; margin: 0em; - -webkit-user-select: none; user-select: none; } diff --git a/tempo.js b/tempo.js index aafb078..40b426a 100644 --- a/tempo.js +++ b/tempo.js @@ -1,18 +1,12 @@ -// Copyright 2014 David Vazgenovich Shakaryan -// Distributed under the terms of the GNU General Public License v2. -// See http://www.gnu.org/licenses/gpl-2.0.txt for the full license text. - var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - var timeformat = null; function padTime(x) { - if(x < 10) { + if (x < 10) return '0' + x; - } else { + else return x; - } } function updateTime() { @@ -26,9 +20,8 @@ function updateTime() { var dm = date.getMonth(); var dy = date.getFullYear(); - if(timeformat == 12) { + if (timeformat == 12) h = (h + 11) % 12 + 1; - } var str_t = padTime(h) + '  ' + padTime(m) + '  ' + padTime(s); @@ -43,10 +36,10 @@ function startTempo() { updateTime(); - setTimeout(function() {updateTime(); setInterval(updateTime, 1000)}, + setTimeout(function() { updateTime(); setInterval(updateTime, 1000) }, 1000 - new Date().getTime() % 1000); } window.onload = startTempo; -document.addEventListener('contextmenu', function(e) {e.preventDefault()}); +document.addEventListener('contextmenu', function(e) { e.preventDefault() }); -- cgit v1.2.3-70-g09d2