-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebUI.html
209 lines (188 loc) · 5.45 KB
/
webUI.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html>
<body>
<center>
<br>
<h1 style='color: #1c203b; font-weight: 20px;border: 3px solid #800080;background-color:#e4dfe0'> PalmShade Hospital </h1>
<br>
<h2 style='color: #f5f2f2;font-size:18px; font-weight: lighter;'>Underground Motor Control</h2>
<br>
<h3> Motor </h3>
<br>
<button id="but1" onclick="button_1_on()">On</button>
<label></label>
<button id="but2" onclick="button_1_off()">Off</button>
<br>
<br>
<label for="UG">UnderGround Tank</label>
<br>
<input type="number" id="UG" name="UG">
<br>
<br>
<label>Threshold is set at</label>
<label id="toDoContainer"></label>
<br>
<br>
<button onclick="button3()">Set</button>
<div style="text-align: center;">
<br>
<h3>Tank Meter</h3>
<meter value="0" min="0" max="200" id="sensor_meter"></meter>
<h3 id="sensor_value" style="display: inline-block;"> 0 </h3>
<br>
<button id="MO" onclick="Mfun()">Manual</button>
<button id="DM" onclick="myFunction()">Dark Mode</button>
<br>
<br>
<button>
<a href='https://docs.google.com/spreadsheets/d/16eYNuYUn9b_OIwkkaLYzcUyh3fn7tc5XTC3Xr6NlkQ8/edit#gid=0' target="_blank" style=" color:#7e35cc; text-decoration: none;">Analytics</a>
</button>
<button>
<a href='http://192.168.29.101/' target="_blank" style=" color:#7e35cc; text-decoration: none;">OverHead Control</a>
</button>
<br>
<br>
</center>
</div>
<style>
.dark-mode {
background-color: black;
color: white;
}
meter {
width: 420px;
height: 35px;
padding-left: 20px;
}
button {
width: 150px;
height: 50px;
color: #105694;
background-color: beige;
border-radius: 8px;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
border: 3px solid #800080;
}
body {
color: #e4dfe0;
background-color: #1c203b;
font-family: "Sen", sans-serif;
font-weight: 2px;
}
h2,
h1,
h3 {
font-family: 'Karla', sans-serif;
font-weight: 2px;
}
h3 {
color: azure;
}
* {
margin: 0px;
padding: 0px;
}
body {
font-family: 'Exo', sans-serif;
}
.dummy {
position: fixed;
}
.context {
width: 100%;
position: absolute;
top: 50vh;
}
</style>
<script>
var connection = new WebSocket('ws://' + location.hostname + ':81/');
var yy = 0;
var UG = document.getElementById('UG');
var OH = document.getElementById('OH');
var but3 = document.getElementById('but3')
var MO = document.getElementById('MO')
var todocntainer = document.getElementById('toDoContainer');
var button_1_status = 0;
var button_2_status = 0;
var UG_Per = 0;
var OH_Per = 0;
var mode1 = 0;
var sens_data = 0;
var xc = 0;
connection.onmessage = function(event) {
var full_data = event.data;
console.log(full_data);
var data = JSON.parse(full_data);
sens_data = data.sens;
document.getElementById("sensor_meter").value = sens_data;
document.getElementById("sensor_value").innerHTML = sens_data;
}
function myFunction() {
var DM = document.getElementById('DM')
if (DM.innerHTML == "Dark Mode") {
DM.innerHTML = "Normal Mode";
yy = 1;
} else if (DM.innerHTML == "Normal Mode") {
DM.innerHTML = "Dark Mode";
yy = 0;
}
var element = document.body;
element.classList.toggle("dark-mode");
}
function Mfun() {
var elem = document.getElementById("MO");
console.log("clicked1");
if (xc == 0) {
elem.innerHTML = "Manual";
mode1 = 0;
xc = 1;
console.log("working");
} else {
elem.innerHTML = "Auto";
mode1 = 1;
xc = 0;
console.log("still working");
}
send_data();
}
function button3() {
console.log("clicked");
todocntainer.textContent = `${UG.value}%`;
UG_Per = UG.value;
UG.value = "";
console.log(UG_Per);
send_data();
}
function button_1_on() {
but1.style.background = "#C4DDFF";
but2.style.background = "beige";
button_1_status = 1;
console.log("LED 1 is ON");
send_data();
}
function button_1_off() {
but1.style.background = "beige";
but2.style.background = "#C4DDFF";
button_1_status = 0;
console.log("LED 1 is OFF");
send_data();
}
function button_2_on() {
button_2_status = 1;
console.log("LED 2 is ON");
send_data();
}
function button_2_off() {
button_2_status = 0;
console.log("LED 2 is OFF");
send_data();
}
function send_data() {
var full_data = '{"LED1":' + button_1_status + ',"LED2":' + button_2_status + ',"UG":' + UG_Per + ',"OH":' + OH_Per + ',"mode":' + mode1 + '}';
connection.send(full_data);
console.log(full_data);
}
</script>
</body>
</html>