diff options
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; } |