From a82a5ed69075d1069d3bbe64db5a162906062611 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 15 Apr 2022 02:54:39 -0700 Subject: make colours configurable --- options.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'options.js') diff --git a/options.js b/options.js index 205cc2e..c3f008b 100644 --- a/options.js +++ b/options.js @@ -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; -- cgit v1.2.3-70-g09d2