blob: 205cc2ee970cfa3f93fd4d6daf7522d3033b8a02 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
function saveOptions() {
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.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) ||
document.getElementById('t24');
option.checked = true;
}
function startOptions() {
restoreOptions();
document.querySelector('#save').addEventListener('click', saveOptions);
}
window.onload = startOptions;
|