forked from chucknthem/Simple-Usage-Meter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.html
40 lines (33 loc) · 999 Bytes
/
background.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
<html>
<script type="text/javascript" src="js/simple.js"></script>
<script>
//how often to refresh
var refreshInterval_min = 20;
var loaded = new Object();
//load params from localStorage then fetch and update
function _refreshHelper() {
params = new UsageParam(localStorage['isp'], localStorage['username'], localStorage['password']);
localStorage['cacheTime'] = null;
fetch(params, null);
data = loadUsageData();
}
function refreshFetch() {
//check if the ISP script is already loaded
//if not, load it before trying to refresh
if(localStorage['isp']) {
if(typeof (loaded[localStorage['isp'] + '.js']) == 'undefined') {
c_loadjs(localStorage['isp']+'.js', function() {
loaded[localStorage['isp'] + '.js'] = true;
_refreshHelper();
});
}
else { //isp js is already loaded
_refreshHelper();
}
}
}
window.setInterval(function() {
refreshFetch();
},refreshInterval_min*60*1000);
</script>
</html>