diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-10 03:26:28 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-10 03:26:28 -0700 |
commit | a9358b6ffad0ac98a4e60f43beda24a22bc0224d (patch) | |
tree | b8f9e3ddbd299d16f8203029ab2b500e70e32c12 /options.js | |
parent | 21bbce4c069778b98441c2d0af69f8a1397bca9f (diff) | |
download | tempo-a9358b6ffad0ac98a4e60f43beda24a22bc0224d.tar.gz tempo-a9358b6ffad0ac98a4e60f43beda24a22bc0224d.tar.xz |
refactor and make Firefox-friendly
Diffstat (limited to 'options.js')
-rw-r--r-- | options.js | 31 |
1 files changed, 13 insertions, 18 deletions
@@ -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; } |