-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbtl-event.js
55 lines (41 loc) · 1.01 KB
/
btl-event.js
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
var req = new XMLHttpRequest();
function quickstate() {
//var photos = req.responseXML.getElementsByTagName("photo");
obj = JSON.parse(req.responseText);
cnt=0;
for(x=0; x<obj.length; x++) {
if(localStorage["alerts_only"] == "true") {
if(obj[x].current_state == 0) {
continue;
}
}
if( localStorage["downtimes"] == "true") {
if(obj[x].is_downtime == 1) {
continue;
}
}
if(localStorage["warnings"] == "true") {
if(obj[x].current_state == 1) {
continue;
}
}
if(localStorage["infos"] == "true") {
if(obj[x].current_state == 4) {
continue;
}
}
cnt++;
}
console.log("OBJ COUNT:" + obj.length);
chrome.browserAction.setBadgeText({text:"" + cnt});
}
function updateState() {
console.log("UPD");
req.open(
"GET",
localStorage["bartlby_url"] + "/services.php?json_output=1",
true);
req.onload = quickstate;
req.send(null);
}
setInterval(function() { updateState() },5000);