summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING24
-rw-r--r--manifest.json2
-rw-r--r--options.html20
-rw-r--r--options.js28
-rw-r--r--tempo.html8
-rw-r--r--tempo.js34
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 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!DOCTYPE html>
+<html lang="en">
<head>
+ <title>Tempo options</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="fonts/lato.css" />
- <title>Tempo options</title>
- <script type="text/javascript" src="options.js"></script>
+ <script src="options.js"></script>
</head>
<body>
<div>
<p style="margin: 0em;">Time format:</p>
- <input type="radio" name="timeformat" id="t12" /><label for="t12"> 12-hour</label><br />
- <input type="radio" name="timeformat" id="t24" /><label for="t24"> 24-hour</label>
+ <input type="radio" name="timefmt" id="t12" /><label for="t12"> 12-hour</label><br />
+ <input type="radio" name="timefmt" id="t24" /><label for="t24"> 24-hour</label>
+ </div>
+ <div style="margin-top: 1em;">
+ <p style="margin: 0em"><label for="fg">Foreground colour: <span style="color: #409;">(blank for default)</span></label></p>
+ <input type="text" name="fg" id="fg" placeholder="#ddd" />
+ </div>
+ <div style="margin-top: 1em;">
+ <p style="margin: 0em;"><label for="bg">Background colour: <span style="color: #409;">(blank for default)</span></label></p>
+ <input type="text" name="bg" id="bg" placeholder="#222" />
</div>
<div style="margin-top: 1em;">
<button id="save">Save</button>
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 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!DOCTYPE html>
+<html lang="en">
<head>
+ <title>New Tab</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="fonts/lato.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="icon" type="image/png" href="icon/clock16.png" />
- <title>New Tab</title>
- <script type="text/javascript" src="tempo.js"></script>
+ <script src="tempo.js"></script>
</head>
<body>
<div id="container">
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) + '&nbsp;&nbsp;' + padTime(m) +
+ let str_t = padTime(h) + '&nbsp;&nbsp;' + padTime(m) +
'&nbsp;&nbsp' + 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) },