diff options
-rw-r--r-- | index.html | 1 | ||||
-rw-r--r-- | manifest.json | 11 | ||||
-rw-r--r-- | options.css | 84 | ||||
-rw-r--r-- | options.html | 23 | ||||
-rw-r--r-- | options.js | 31 | ||||
-rw-r--r-- | style.css | 1 | ||||
-rw-r--r-- | tempo.js | 17 |
7 files changed, 36 insertions, 132 deletions
@@ -5,7 +5,6 @@ <link rel="stylesheet" type="text/css" href="fonts/lato.css" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>New Tab</title> - <script type="text/javascript" src="tempo.js"></script> </head> <body> 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 @@ <head> <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="options.css" /> - <title>Tempo Options</title> - + <title>Tempo options</title> <script type="text/javascript" src="options.js"></script> </head> <body> - <div id="container"> - <h1>Options</h1> - <div class="section"> - <p>Time format:</p> - <p class="option"><input type="radio" name="timeformat" id="t12" /><label for="t12"> 12-hour</label></p> - <p class="option"><input type="radio" name="timeformat" id="t24" /><label for="t24"> 24-hour</label></p> - </div> - <div class="button"> - <button id="save">Save</button> - </div> + <div> + <p>Time format:</p> + <p><input type="radio" name="timeformat" id="t12" /><label for="t12"> 12-hour</label></p> + <p><input type="radio" name="timeformat" id="t24" /><label for="t24"> 24-hour</label></p> </div> - <div id="status">Options saved.</div> + <div> + <button id="save">Save</button> + </div> + <div id="status"></div> </body> </html> @@ -1,29 +1,24 @@ -// Copyright 2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> -// 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; } @@ -5,7 +5,6 @@ body { padding: 0em; margin: 0em; - -webkit-user-select: none; user-select: none; } @@ -1,18 +1,12 @@ -// Copyright 2014 David Vazgenovich Shakaryan <dvshakaryan@gmail.com> -// 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() }); |