summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-15 18:02:48 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-15 18:22:02 -0700
commit1546d1ad242f65fcb9ad0ec3c2fcc4b237dc7ff0 (patch)
tree102a86c70f841c3871b67be6c43ff041baa4594b
parentcb2b45a5d6b1972b20dc715dfdf16320435167e4 (diff)
downloadtempo-1546d1ad242f65fcb9ad0ec3c2fcc4b237dc7ff0.tar.gz
tempo-1546d1ad242f65fcb9ad0ec3c2fcc4b237dc7ff0.tar.xz
reuse variables for conciseness
-rw-r--r--manifest.json2
-rw-r--r--options.js25
-rw-r--r--tempo.js18
3 files changed, 18 insertions, 27 deletions
diff --git a/manifest.json b/manifest.json
index 6679373..b752d9a 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Tempo",
- "version": "0.9",
+ "version": "0.10",
"description": "Replace new tab page with a clock.",
"icons": {
diff --git a/options.js b/options.js
index a0b6b71..a218528 100644
--- a/options.js
+++ b/options.js
@@ -17,22 +17,17 @@ function saveOptions() {
function restoreOptions() {
// default to 24 for both unset and invalid
- let timefmt = localStorage['timefmt'] || 24;
- let timefmt_btn = document.getElementById('t' + timefmt) ||
+ let val = localStorage['timefmt'] || 24;
+ let btn = document.getElementById('t' + val) ||
document.getElementById('t24');
- timefmt_btn.checked = true;
-
- let fg = localStorage['fg'];
- if (fg)
- document.getElementById('fg').value = fg;
-
- let fg_date = localStorage['fg_date'];
- if (fg_date)
- document.getElementById('fg_date').value = fg_date;
-
- let bg = localStorage['bg'];
- if (bg)
- document.getElementById('bg').value = bg;
+ btn.checked = true;
+
+ if ((val = localStorage['fg']))
+ document.getElementById('fg').value = val;
+ if ((val = localStorage['fg_date']))
+ document.getElementById('fg_date').value = val;
+ if ((val = localStorage['bg']))
+ document.getElementById('bg').value = val;
}
function startOptions() {
diff --git a/tempo.js b/tempo.js
index 3dcb1b9..4380603 100644
--- a/tempo.js
+++ b/tempo.js
@@ -31,17 +31,13 @@ function updateTime() {
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;
+ let val;
+ if ((val = localStorage['fg']))
+ document.body.style.color = val;
+ if ((val = localStorage['fg_date']))
+ document.getElementById('dateval').style.color = val;
+ if ((val = localStorage['bg']))
+ document.body.style.backgroundColor = val;
updateTime();
setTimeout(function() { updateTime(); setInterval(updateTime, 1000) },