-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_preview_options.html
97 lines (86 loc) · 2.68 KB
/
image_preview_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
95
96
97
<html>
<head><title>Image Preview Options</title></head>
<script type="text/javascript">
// Saves options to localStorage.
function save_options() {
var youtube_select = document.getElementById("youtube_select");
var image_select = document.getElementById("image_select");
var zoom_select = document.getElementById("zoom_select");
localStorage.youtube_enabled = youtube_select.children[youtube_select.selectedIndex].value;
localStorage.image_enabled = image_select.children[image_select.selectedIndex].value;
localStorage.zoom_enabled = zoom_select.children[zoom_select.selectedIndex].value;
// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 2000);
}
// Restores select box state to saved value from localStorage.
function restore_options() {
var youtube_enabled = localStorage.youtube_enabled;
if (!youtube_enabled) {
localStorage.youtube_enabled = "enabled";
return;
}
var youtube_select = document.getElementById("youtube_select");
for (var i = 0; i < youtube_select.children.length; i++) {
var child = youtube_select.children[i];
if (child.value == youtube_enabled) {
child.selected = "true";
break;
}
}
var image_enabled = localStorage.image_enabled;
if (!image_enabled) {
localStorage.image_enabled = "enabled";
return;
}
var image_select = document.getElementById("image_select");
for (var i = 0; i < image_select.children.length; i++) {
var child = image_select.children[i];
if (child.value == image_enabled) {
child.selected = "true";
break;
}
}
var zoom_enabled = localStorage.zoom_enabled;
if (!zoom_enabled) {
localStorage.zoom_enabled = "enabled";
return;
}
var zoom_select = document.getElementById("zoom_select");
for (var i = 0; i < zoom_select.children.length; i++) {
var child = zoom_select.children[i];
if (child.value == zoom_enabled) {
child.selected = "true";
break;
}
}
}
</script>
<body onload="restore_options()">
<h1>Image Preview options</h1>
Youtube Preview:
<select id="youtube_select">
<option value="enabled">Enabled</option>
<option value="disabled">Disabled</option>
</select>
<br>
Image Preview:
<select id="image_select">
<option value="enabled">Enabled</option>
<option value="disabled">Disabled</option>
</select>
<br>
Image Zoom:
<select id="zoom_select">
<option value="enabled">Enabled</option>
<option value="disabled">Disabled</option>
</select>
<br>
<button onclick="save_options()">Save</button>
<br>
<p id="status" style="color:red;"></p>
</body>
</html>