-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLED.html
59 lines (58 loc) · 1.96 KB
/
LED.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
<!Doctype html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.wrapper {
margin-top:10vh;
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
}
button {
margin:10px;
}
input {
margin-top:20px;
border-radius: 5px;
width:100px;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
</head>
<body>
<div class="wrapper">
<h3>LED SWITCH</h3>
{{distance}}
<button class="btn btn-success" onclick="turnFan(1)">Level 1</button>
<button class="btn btn-warning" onclick="turnFan(2)">Level 2</button>
<button class="btn btn-info" onclick="turnFan(3)">Level 3</button>
<button class="btn btn-danger" onclick="turnFan(0)">Turn off</button>
<button id="blink" onclick="turnFan(4)">blink:on</button>
</div>
<script>
function turnFan(level) {
var xmlhttp = new XMLHttpRequest();
var element=document.getElementById("blink");
if(level==1)
{xmlhttp.open("GET","level1",true);}
else if(level==2)
{xmlhttp.open("GET","level2",true);}
else if(level==3)
{xmlhttp.open("GET","level3",true);}
else if(level==0)
{xmlhttp.open("GET","turnOff",true)}
else if(element.innerHTML.match("blink:on")){
element.innerHTML = "blink:off";
xmlhttp.open("GET","boff",true);
}
else{
element.innerHTML = "blink:on";
xmlhttp.open("GET","bon",true);
}
xmlhttp.send();
}
</script>
</body>
</html>