diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-15 02:54:39 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-15 02:54:39 -0700 |
commit | a82a5ed69075d1069d3bbe64db5a162906062611 (patch) | |
tree | 40652ea73a506020df5c947ce0803b5d68c5c406 /options.js | |
parent | fd37abfe0ecfb4126f3c9b2cb8148f74fa17e97e (diff) | |
download | tempo-a82a5ed69075d1069d3bbe64db5a162906062611.tar.gz tempo-a82a5ed69075d1069d3bbe64db5a162906062611.tar.xz |
make colours configurable
Diffstat (limited to 'options.js')
-rw-r--r-- | options.js | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -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; |