-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
98 lines (97 loc) · 2.62 KB
/
index.htm
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
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<title>SmartDoor</title>
<script>
strLock = "";
var Lock_state = 0;
function GetLockState()
{
nocache = "&nocache=" + Math.random() * 1000000;
var request = new XMLHttpRequest();
request.onreadystatechange = function()
{
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseXML != null) {
// XML file received - contains analog values, switch values and LED states
var count;
if (this.responseXML.getElementsByTagName('Lock')[0].childNodes[0].nodeValue === "locked") {
document.getElementById("Lock").style.display = "none";
document.getElementById("Unlock").style.display = "block";
Lock_state = 1;
} else {
document.getElementById("Lock").style.display = "block";
document.getElementById("Unlock").style.display = "none";
Lock_state = 0;
}
}
}
}
}
// send HTTP GET request with LEDs to switch on/off if any
request.open("GET", "ajax_inputs" + strLock + nocache, true);
request.send(null);
setTimeout('GetLockState()', 1000);
strLock = "";
}
function GetButton()
{
if (Lock_state === 1) {
Lock_state = 0;
strLock = "&Lock=0";
} else {
Lock_state = 1;
strLock = "&Lock=1";
}
}
</script>
<style>
body {
background-color: black;
background-repeat: no-repeat;
}
.IO_box {
float: left;
margin: 0 20px 20px 0;
border: 1px solid blue;
padding: 0 5px 0 5px;
width: 120px;
}
h1 {
font-size: 120%;
color: blue;
margin: 0 0 10px 0;
}
h2 {
font-size: 85%;
color: #5734E6;
margin: 5px 0 5px 0;
}
p, form, button {
font-size: 120%;
color: #819EAD;
}
.small_text {
font-size: 70%;
color: #737373;
}
#Lock {
display: none;
}
#Unlock {
display: none;
}
</style>
</head>
<body onload="GetLockState()">
<div id="Lock">
<p> The door is open<br/>Click to lock</p>
<input type="image" src="lock.jpg" onclick="GetButton()" />
</div>
<div id="Unlock">
<p>The door is locked<br/>Click to unlock</p>
<input type="image" src="unlock.jpg" onclick="GetButton()" />
</div>
</body>
</html>