forked from cheeaun/hackerweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.html
94 lines (94 loc) · 2.29 KB
/
options.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>HackerWeb Options</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="icons/favicon.ico">
<style>
body{
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
-webkit-text-size-adjust: none;
-ms-text-size-adjust: none;
max-width: 640px;
margin: 0 auto;
padding: 10px;
font-size: 14px;
}
h1{
font-size: 1.2em;
}
#options-list{
margin: 0;
padding: 0;
list-style: none;
}
#options-list li{
padding: 10px;
background-color: #eee;
margin-bottom: 2px;
}
#options-list li .label{
font-weight: bold;
}
footer{
font-size: .9em;
}
footer button{
margin: 0;
float: right;
}
</style>
</head>
<body>
<header>
<h1>HackerWeb Options</h1>
</header>
<ul id="options-list">
<li>
<span class="label">UI Theme <small>(experimental)</small></span>
<label><input type="radio" name="hackerweb:options:theme" value="" checked> Auto (default)</label>
<label><input type="radio" name="hackerweb:options:theme" value="web"> Web</label>
<label><input type="radio" name="hackerweb:options:theme" value="ios"> iOS</label>
</li>
</ul>
<footer>
<button id="reset">Reset all options</button>
<p>Note: Reload HackerWeb after changing these options.</p>
</footer>
<script>
var validOption = 'hackerweb:options';
for (var i=0, l=localStorage.length; i<l; i++){
var key = localStorage.key(i);
var value = localStorage[key];
if (key.indexOf(validOption) != -1 && value){
var el = document.querySelector('[name="' + key + '"][value="' + value + '"]');
if (el && el.type == 'radio') el.checked = true;
}
}
document.addEventListener('change', function(e){
var el = e.target;
if (!el) return;
var name = el.name;
var value = el.value;
if (name.indexOf(validOption) != -1){
if (value){
localStorage[name] = value;
} else {
delete localStorage[name];
}
}
}, true);
document.getElementById('reset').addEventListener('click', function(){
for (var i=0, l=localStorage.length; i<l; i++){
var key = localStorage.key(i);
if (key.indexOf(validOption) != -1){
delete localStorage[key];
}
}
location.reload();
}, false);
</script>
</body>
</html>