summaryrefslogtreecommitdiff
path: root/options.js
blob: 0c640b4061f54c3bffc2d4690e55a1217124b208 (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
33
34
35
36
37
// 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;
	}

	localStorage['timeformat'] = timeformat;

	var status = document.getElementById('status');
	status.style['visibility'] = 'visible';

	setTimeout(function() {status.style['visibility'] = 'hidden'}, 2000);
}

function restoreOptions() {
	var timeformat = localStorage['timeformat'];

	if(!timeformat) {
		timeformat = 24;
	}

	var option = document.getElementById('t' + timeformat);

	option.checked = true;
}

function startOptions() {
	restoreOptions();

	document.querySelector('#save').addEventListener('click', saveOptions);
}

window.onload = startOptions;