-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathab.html
94 lines (85 loc) · 2.25 KB
/
ab.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<title>A/B</title>
<style>
button {
display: block;
width: 50%;
padding-top: 50px;
padding-bottom: 50px;
padding-left: 0.5em;
padding-right: 0.5em;
border: 5px solid white;
border-radius: 1rem;
background-color: #1fa3ec;
color: #fff;
font-size: 30pt;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
text-align: center;
text-decoration: none;
font: verdana;
margin: 0 auto;
margin-top: 50px;
}
/*button:hover{
background-color: white;
border: 5px solid #1fa3ec;
color: #1fa3ec;
}*/
button:disabled {
background-color: lightgrey;
border: 5px solid white;
color: white;
}
</style>
<script type="text/javascript">
// function httpGet(theUrl)
// {
// var xmlHttp = new XMLHttpRequest();
// xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
// xmlHttp.send( null );
// return xmlHttp.responseText;
// }
function httpGetAsync(theUrl, btn, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.timeout = 2000; // time in milliseconds
xmlHttp.ontimeout = function () { resetBtn(btn); }
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
function desactivateBtn(b){
b.disabled = true;
// b.style.color = 'blue';
}
function resetBtn(b){
b.disabled = false;
// b.style.color = null;
}
function btnclick(elem)
{
desactivateBtn(elem);
var url = '#';
if(elem.id == "btnA")
url = 'http://192.168.1.42/cm?cmnd=Power%20On';
if(elem.id == "btnB")
url = 'http://192.168.1.93/cm?cmnd=Power%20On';
httpGetAsync(url,elem, function(e){
resetBtn(elem);
});
}
</script>
</head>
<body>
<button onclick="btnclick(this);" id="btnA">A - Porte</button>
<button onclick="btnclick(this);" id="btnB">B - Lumière</button>
</body>
</html>