-
Notifications
You must be signed in to change notification settings - Fork 3
/
background.html
46 lines (39 loc) · 1.17 KB
/
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
40
41
42
43
44
45
<html>
<script type="text/javascript" src="js/xml.js"></script>
<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);
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') {
var jsfile = localStorage['isp'] + '.js';
c_loadjs(jsfile, function() {
loaded[jsfile] = true;
console.log('loaded ' + jsfile);
_refreshHelper();
});
}
else { //isp js is already loaded
_refreshHelper();
}
}
}
window.setInterval(function() {
console.log('refreshing ' + new Date());
refreshFetch();
},refreshInterval_min*60*1000);
console.log('refreshing ' + new Date());
refreshFetch();
</script>
</html>