diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-02-26 13:11:45 -0800 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-02-26 13:11:45 -0800 |
commit | eabbe53c13e5fcf45a50b2163c871e6f9d55f991 (patch) | |
tree | a24f23561feca6e50084a1ca083911293114e17f /options.js | |
parent | 89ca2bfe654ee86b1190ebe28fd0038cb6fddc42 (diff) | |
download | tempo-eabbe53c13e5fcf45a50b2163c871e6f9d55f991.tar.gz tempo-eabbe53c13e5fcf45a50b2163c871e6f9d55f991.tar.xz |
Add option for 12-hour time.
Diffstat (limited to 'options.js')
-rw-r--r-- | options.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/options.js b/options.js new file mode 100644 index 0000000..b8986ae --- /dev/null +++ b/options.js @@ -0,0 +1,42 @@ +// 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 save_options() { + var select = document.getElementById('timeformat'); + var timeformat = select.children[select.selectedIndex].value; + localStorage['timeformat'] = timeformat; + + var status = document.getElementById('status'); + status.innerHTML = 'Options saved.'; + + setTimeout(function() {status.innerHTML = ''}, 1000); +} + +function restore_options() { + var timeformat = localStorage['timeformat']; + + if(!timeformat) { + return; + } + + var select = document.getElementById('timeformat'); + + for(var i = 0; i < select.children.length; i++) { + var child = select.children[i]; + + if(child.value == timeformat) { + child.selected = 'true'; + + break; + } + } +} + +function start_options() { + restore_options(); + + document.querySelector('#save').addEventListener('click', save_options); +} + +window.onload = start_options; |