-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (69 loc) · 1.31 KB
/
index.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var REL1="";
var REL2="";
var REL3="";
var REL4="";
function AjaxColor(){
var r1=document.getElementById("REL1");
var r2=document.getElementById("REL2");
var r3=document.getElementById("REL3");
var r4=document.getElementById("REL4");
if(REL1 == "OFF"){
r1.innerHTML="OFF";
r1.style.color="#3F1F1F";
}else{
r1.innerHTML="ON";
r1.style.color="#FF0000";
}
if(REL2 == "OFF"){
r2.innerHTML="OFF";
r2.style.color="#3F3F1F";
}else{
r2.innerHTML="ON";
r2.style.color="#BFBF00";
}
if(REL3 == "OFF"){
r3.innerHTML="OFF";
r3.style.color="#1F3F1F";
}else{
r3.innerHTML="ON";
r3.style.color="#00FF00";
}
if(REL4 == "OFF"){
r4.innerHTML="OFF";
r4.style.color="#1F1F3F";
}else{
r4.innerHTML="ON";
r4.style.color="#0000FF";
}
}
function AjaxREL(relay){
var AR=new XMLHttpRequest();
var r=document.getElementById(relay);
r.innerHTML="WAIT";
r.style.color="#AFAFAF";
if(this[relay] == "ON"){
this[relay]="OFF";
}else{
this[relay]="ON";
}
AR.open("GET", "cfg.html?" + relay + "=" + this[relay], true);
AR.timeout = 300;
AR.send();
}
function AjaxLOOP(){
AjaxSTATUS();
setTimeout(AjaxLOOP, 1000);
}
function AjaxSTATUS(){
var AR=new XMLHttpRequest();
AR.onreadystatechange=function(){
if(AR.readyState == 4 && AR.status == 200){
eval(AR.responseText);
AjaxColor();
}
}
AR.open("GET", "cfg.html?REL=STATUS", true);
AR.timeout = 300;
AR.send();
}
AjaxLOOP();