-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
143 lines (139 loc) · 7.3 KB
/
index.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebSocket Lightbulb</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
.center-this {
display: flex;
justify-content: center;
align-items: center;
height: 50%;
width: 15%;
}
</style>
</head>
<body>
<?xml version="1.0" encoding="iso-8859-1"?>
<div class="center-this">
<svg id="send" height="800px" width="800px" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 283.994 283.994" xml:space="preserve">
<g>
<g>
<g>
<g id="XMLID_19_">
<g>
<g>
<g>
<path style="fill:#FEDE94;" d="M122.086,132.667c3.136,3.199,8.236,3.199,11.372,0c3.168-3.168,3.168-8.331,0-11.499
l-2.217-2.281h24.772l-18.215,18.437c-1.489,1.521-2.344,3.611-2.344,5.765v54.74h-27.813V169.35
c0-2.914-1.552-5.607-4.055-7.064c-23.949-13.938-38.806-39.914-38.806-67.823c0-43.114,34.624-78.181,77.199-78.181
s77.231,35.068,77.231,78.181c0,28.732-15.522,55.088-40.484,68.805c-2.598,1.394-4.213,4.15-4.213,7.159v27.401h-22.967
v-51.382l29.587-29.936c2.281-2.344,2.978-5.829,1.742-8.87s-4.181-5.037-7.444-5.037h-63.609
c-3.263,0-6.209,1.996-7.444,5.037s-0.57,6.526,1.742,8.87L122.086,132.667z"/>
</g>
</g>
<g>
<g>
<path style="fill:#2D213F;" d="M64.78,94.464c0,27.908,14.857,53.884,38.806,67.823c2.503,1.457,4.055,4.15,4.055,7.064
v28.478h27.813v-54.74c0-2.154,0.855-4.245,2.344-5.765l18.215-18.437h-24.772l2.217,2.281c3.168,3.168,3.168,8.331,0,11.499
c-3.136,3.199-8.236,3.199-11.372,0l-15.966-16.156c-2.312-2.344-2.978-5.829-1.742-8.87
c1.235-3.041,4.181-5.037,7.444-5.037h63.609c3.263,0,6.209,1.996,7.444,5.037s0.539,6.526-1.742,8.87l-29.587,29.936v51.382
h22.967v-27.401c0-3.009,1.616-5.765,4.213-7.159c24.962-13.717,40.484-40.073,40.484-68.805
c0-43.114-34.656-78.181-77.231-78.181S64.78,51.35,64.78,94.464z M235.303,94.464c0,33.072-17.011,63.546-44.698,80.652
v30.886c0,0.539-0.063,1.077-0.158,1.584c2.914,3.358,4.752,7.729,4.752,12.544v0.634c0,4.055-1.267,7.793-3.421,10.897
c2.154,3.073,3.421,6.811,3.421,10.866v0.634c0,10.517-8.426,19.038-18.785,19.038h-8.553v0.697
c0,11.626-9.345,21.098-20.844,21.098h-10.675c-11.499,0-20.844-9.472-20.844-21.098v-0.697h-10.707
c-10.359,0-18.785-8.521-18.785-19.038v-0.634c0-4.055,1.299-7.793,3.421-10.866c-2.122-3.104-3.421-6.842-3.421-10.897
v-0.634c0-5.29,2.154-10.074,5.607-13.526c-0.032-0.19-0.063-0.412-0.063-0.602v-32.09
c-26.546-17.296-42.86-47.327-42.86-79.448C48.688,42.385,90.535,0,141.98,0C193.456,0,235.303,42.385,235.303,94.464z
M179.106,243.16v-0.634c0-1.489-1.204-2.724-2.693-2.724h-71.624c-1.489,0-2.693,1.235-2.693,2.724v0.634
c0,1.521,1.204,2.756,2.693,2.756h71.624C177.904,245.916,179.106,244.681,179.106,243.16z M179.106,220.764v-0.634
c0-1.489-1.204-2.724-2.693-2.724h-71.624c-1.489,0-2.693,1.235-2.693,2.724v0.634c0,1.521,1.204,2.756,2.693,2.756h71.624
C177.904,223.52,179.106,222.284,179.106,220.764z M151.768,262.896v-0.697h-20.179v0.697c0,2.629,2.154,4.783,4.752,4.783
h10.675C149.646,267.679,151.768,265.525,151.768,262.896z"/>
</g>
</g>
<g>
<g>
<path style="fill:#C5CBCF;" d="M176.414,245.916H104.79c-1.489,0-2.693-1.235-2.693-2.756v-0.634
c0-1.489,1.204-2.724,2.693-2.724h71.624c1.489,0,2.693,1.235,2.693,2.724v0.634
C179.106,244.681,177.904,245.916,176.414,245.916z"/>
</g>
</g>
<g>
<g>
<path style="fill:#EAEEEF;" d="M176.414,223.52H104.79c-1.489,0-2.693-1.235-2.693-2.756v-0.634
c0-1.489,1.204-2.724,2.693-2.724h71.624c1.489,0,2.693,1.235,2.693,2.724v0.634
C179.106,222.284,177.904,223.52,176.414,223.52z"/>
</g>
</g>
<g>
<g>
<path style="fill:#C5CBCF;" d="M151.768,262.199v0.697c0,2.629-2.122,4.783-4.752,4.783h-10.675
c-2.598,0-4.752-2.154-4.752-4.783v-0.697H151.768z"/>
</g>
</g>
</g>
</g>
</g>
<g>
<g>
<g>
<path style="fill:#F2CE75;" d="M103.586,162.286c2.503,1.457,4.055,4.15,4.055,7.064v28.478h27.813v-54.74
c0-2.154,0.855-4.245,2.344-5.765l1.438-1.454c-28.497-0.653-52.709-8.499-70.458-16.71
C74.702,137.086,86.939,152.599,103.586,162.286z"/>
</g>
</g>
<g>
<g>
<path style="fill:#F2CE75;" d="M163.156,134.701l-11.61,11.746v51.382h22.967v-27.401c0-3.009,1.616-5.765,4.213-7.159
c17.29-9.5,30.037-25.067,36.249-43.285C196.874,128.141,179.49,132.718,163.156,134.701z"/>
</g>
</g>
</g>
</g>
</g>
</svg>
</div>
<script>
const socket = new WebSocket("ws://localhost:8080/lightbulb");
socket.onopen = event => {
console.log("WebSocket connected", event);
};
socket.onmessage = event => {
console.log("Lightbulb state received:", event.data);
if (event.data === "true") {
document.body.style.backgroundColor = "yellow";
document.getElementById("send").style.backgroundColor = "yellow";
document.getElementById("send").style.filter = "grayscale(0%)";
} else {
document.body.style.backgroundColor = "black";
document.getElementById("send").style.backgroundColor = "black";
document.getElementById("send").style.filter = "grayscale(100%)";
}
};
socket.onclose = event => {
document.body.style.backgroundColor = "gray";
document.getElementById("send").style.backgroundColor = "gray";
document.getElementById("send").style.filter = "grayscale(100%)";
console.log("WebSocket closed", event.data);
};
document.getElementById("send").onclick = function () {
if (!socket) {
return false;
}
socket.send("");
console.log("Lightbulb switched");
return false;
};
</script>
</body>
</html>