-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.html
171 lines (150 loc) · 5.56 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<html>
<head><title>Internet Usage Meter</title>
<style>
body {
background-color:#CCDDFF;
}
#wrapper {
padding:30px;
width:375px;
height:250px;
border:solid 1px;
margin:0px auto;
margin-top:10%;
background-color:#FFF;
}
abbr{border-bottom:1px dotted #000;cursor:help;}
</style>
<script type="text/javascript">
// Saves options to localStorage.
function save_options() {
var username = document.getElementById("username").value;
localStorage["username"] = username;
var password = document.getElementById("password").value;
localStorage["password"] = password;
var ispSelect = document.getElementById("isp");
var isp = ispSelect.children[ispSelect.selectedIndex].value;
localStorage["isp"] = isp;
var gbformatSel = document.getElementById("gbformat");
var gbformat = gbformatSel.children[gbformatSel.selectedIndex].value;
localStorage["gbformat"] = gbformat;
var badgeDisplaySel = document.getElementById("badgeDisplay");
var badgeDisplay = badgeDisplaySel.children[badgeDisplaySel.selectedIndex].value;
localStorage["badgeDisplay"] = badgeDisplay;
//var formatDataSel = document.getElementById("formatData");
//var formatData = formatDataSel.children[formatDataSel.selectedIndex].value;
//localStorage["formatData"] = formatData;
var byteFormatSel = document.getElementById("byteFormat");
var byteFormat = byteFormatSel.children[byteFormatSel.selectedIndex].value;
localStorage["byteFormat"] = byteFormat;
var suffixSel = document.getElementById("suffix");
var suffix = suffixSel.children[suffixSel.selectedIndex].value;
localStorage["suffix"] = suffix;
var roundDataSel = document.getElementById("roundData");
var roundData = roundDataSel.children[roundDataSel.selectedIndex].value;
localStorage["roundData"] = roundData;
localStorage.removeItem('cache');
localStorage.removeItem('cacheTime');
// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 1000);
}
function _restoreSelection(id, value) {
var sel = document.getElementById(id);
for (var i = 0; i < sel.children.length; i++) {
var child = sel.children[i];
if (child.value == value) {
child.selected = "true";
break;
}
}
}
// Restores select box state to saved value from localStorage.
function restore_options() {
var isp = localStorage["isp"];
var gbformat = localStorage["gbformat"];
var badgeDisplay = localStorage["badgeDisplay"];
//var formatData = localStorage["formatData"];
var byteFormat = localStorage["byteFormat"];
var suffix = localStorage["suffix"];
var roundData = localStorage["roundData"];
if(isp) _restoreSelection("isp", isp);
if(gbformat) _restoreSelection("gbformat", gbformat);
if(badgeDisplay) _restoreSelection("badgeDisplay", badgeDisplay);
//if(formatData) _restoreSelection("formatData", formatData);
if(byteFormat) _restoreSelection("byteFormat", byteFormat);
if(suffix) _restoreSelection("suffix", suffix);
if(roundData) _restoreSelection("roundData", roundData);
var username = localStorage["username"];
var password = localStorage["password"];
if(username) {
document.getElementById("username").value = username;
}
if(password) {
document.getElementById("password").value = password;
}
}
</script>
</head>
<body onload="restore_options()">
<div id="wrapper">
<label for="ISP">My ISP is </label>
<!-- keep the list of ISPs in alphabetical order -->
<select name="isp" id="isp">
<option value="aaNet">aaNet</option>
<option value="adam">Adam Internet</option>
<option value="apex">Apex Internet</option>
<option value="dodo">Dodo Internet</option>
<option value="exetel">Exetel</option>
<option value="iiNet">iiNet</option>
<option value="netspace">Netspace</option>
</select>
<br />
<label for="username">My Username is </label>
<input type="text" id="username" name="username" />
<br />
<label for="password">My Password is </label>
<input type="password" name="password" id="password" />
<p><strong>Advanced Options</strong></p>
<label for="gbformat">Display 1GB as </label>
<select id="gbformat" name="gbformat">
<option value="1024">1024</option>
<option value="1000">1000</option>
</select>MB.<br />
<label for="byteFormat">Display all data in </label>
<select id="byteFormat" name="byteFormat">
<option value="GB">Gigabytes</option>
<option value="MB">Megabytes</option>
</select>
<select id="suffix" name="suffix">
<option value="yes">with</option>
<option value="no">without</option>
</select> suffix,<br />
<label for="roundData">rounded to </label>
<select id="roundData" name="roundData">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select> decimal place(s).<br />
<label for="badgeDisplay">Display </label>
<select id="badgeDisplay" name="badgeDisplay">
<option value="Target">Target</option>
<option value="Percent Used">Percent Used</option>
<option value="Percent Remaining">Percent Remaining</option>
<option value="Quota Used">Quota Used</option>
<option value="Quota Remaining">Quota Remaining</option>
<option value="0">Nothing</option>
</select> in the <abbr title="Chrome's name for the information area in the lower right of an extension's icon.">badge</abbr><!--, with the data
<select id="formatData" name="formatData">
<option value="unformatted">unformatted</option>
<option value="formatted">formatted GB</option>
</select>-->.
<br /><br />
<button onclick="save_options()">Save</button>
<div id="status"></div>
</div>
</body>
</html>