-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTML.h
336 lines (303 loc) · 9.6 KB
/
HTML.h
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
const char indexHTML[]
PROGMEM = R"rawliteral(
<html>
<head>
<meta charset="UTF-8">
<style>
body{
font-family: "Helvetica";
}
input[type="submit"] {
background-color: #4CAF50; /* Green */
color: white;
width: 200px;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
display: block;
margin: 0 auto;
}
button {
background-color: #4CAF50; /* Green */
color: white;
width: 150px;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 4px;
font-size: 16px;
display: block;
margin: 0 auto;
transition: 0.3s;
}
button:hover {
background-color: #3d8b40;
}
.rssi {
color: green;
text-align: center;
}
.encrypt1 {
color: green;
text-align: center;
}
</style>
</head>
<body>
<center>
<h1>ESP config</h1>
<button onclick="window.location.href=window.location.href">Scan</button>
<button onclick="location.href = '/nodes';">Node IP</button>
<button onclick="location.href = '/jsonConfigure';">Configure</button>
<button onclick="location.href = '/settings';">Settings</button>
<button onclick="location.href = '/exit';">Exit</button>
<p>Skanování může chvíli trvat</p>
<h1>WIFI sítě</h1>
<script>
var getJSON = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true); // Otevre http request
xhr.responseType = 'json';
xhr.onload = function () {
var status = xhr.status; // zkontroluje se status http
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
getJSON('scannedWiFi.json', // pracuje s ipAdresa/scannedWiFi.json
function (err, data) {
if (err !== null) { // kontrola zda se stal error
alert('Something went wrong: ' + err);
} else { // vezme data z jsonu a ulozi se do pole
for (i = 0; i < data.numOfNetworks; i++) {
buttons(i, data.networks, data.strengh, data.protection);
}
}
});
function buttons(i, networks, rssi, protection) {
// vytvori tlacitka na zaklade json zpravy
var button = document.createElement('input');
button.class = 'button';
button.type = 'submit';
button.value = networks[i]; // hodnota se nastavi na SSID site
var form = document.createElement('form'); // vytvori se formular do ktereho se tlacitko vlozi
// pokud sit je zabezpecena, odkaze na overeni s heslem
if (protection[i] == "None") {
form.method = 'POST';
form.action = '/wifi/redirect'
} else {
form.method = 'GET'
form.action = '/wifi';
}
var inputs = document.createElement('input');
inputs.type = 'hidden';
inputs.name = 'ssid';
inputs.value = networks[i]; // skryty input s ssid
var rssi1 = document.createElement("p");
rssi1.innerHTML = rssi[i]; // text s rrsi konkretni site
rssi1.className = 'rssi';
var encrypt = document.createElement("p");
encrypt.innerHTML = protection[i];
encrypt.className = 'encrypt1';
// sestaveni html stromu
document.body.appendChild(form);
form.appendChild(inputs);
form.appendChild(button);
form.appendChild(rssi1);
form.appendChild(encrypt);
}
</script>
</center>
</body>
</html>
)rawliteral";
const char passwordHTML[]
PROGMEM = R"rawliteral(
<html>
<head>
<meta charset="UTF-8">
<style>
body {
font-family: "Helvetica";
}
input[type=password], select {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
background-color: #0080FF; /* azurová */
color: white;
width: 150px;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 4px;
font-size: 16px;
display: block;
margin: 0 auto;
transition: 0.3s;
}
button:hover {
background-color: #5fc2ed;
}
</style>
</head>
<center>
<h1>Security</h1>
<form method="POST" action="/wifi/redirect">
<label for="password">WiFi password</label>
<br>
<input type="password" name="password" id="password">
<button type="submit">submit</button>
<p>WiFi name: </p>
</form>
<body>
<script>
const queryString = window.location.search; // slouzi k ziskani argumentu z url
const urlParams = new URLSearchParams(queryString);
var form = document.getElementsByTagName('form')[0]; // najdu formular na strance a ulozim do promenne
// vytvorim skryty vstup a ulozim do nej ssid argument z url
var wifiname = document.createElement('input');
wifiname.type = "hidden";
wifiname.name = "ssid";
wifiname.value = urlParams.get('ssid');
form.appendChild(wifiname);
form.appendChild(document.createTextNode(urlParams.get('ssid')));
</script>
<button onClick="location.href = '/';">Return</button>
</body>
</center>
</html>
)rawliteral";
const char DeviceHTML[]
PROGMEM = R"rawliteral(
<html lang="cs">
<head>
<style>
body {
font-family: "Helvetica";
}
input[type=input] {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
background-color: #0080FF;
color: white;
width: 150px;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 4px;
font-size: 16px;
display: block;
margin: 0 auto;
transition: 0.3s;
}
button:hover {
background-color: #5fc2ed;
}
</style>
</head>
<body>
<center>
<meta charset="UTF-8">
<h1>IP adresses of Nodes</h1>
<form method="POST" action="/nodes/check">
<label for="ip1">Node #1</label><br>
<input type="input" name="ip1" id="ip1">
<button type="submit">submit</button>
</form>
<form method="POST" action="/nodes/check">
<label for="ip2">Node #2</label><br>
<input type="input" name="ip2" id="ip2">
<button type="submit">submit</button>
</form>
<button onClick="location.href = '/';">Return</button>
<h6>If you want to use one socket with multiple outputs, put same IP Address to both fields.</h6>
</center>
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
var input1 = document.getElementsByTagName('input')[0];
wifiname.value = urlParams.get('ssid');
form.appendChild(wifiname);
form.appendChild(document.createTextNode(urlParams.get('ssid')));
</script>
</body>
</html>
)rawliteral";
const char configHTML[]
PROGMEM = R"rawliteral(
<html>
<head>
<meta charset="UTF-8">
<style>
body {
font-family: "Helvetica";
}
input[type=input] {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
background-color: #0080FF;
color: white;
width: 150px;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 4px;
font-size: 16px;
display: block;
margin: 0 auto;
transition: 0.3s;
}
button:hover {
background-color: #5fc2ed;
}
</style>
</head>
<body>
<center>
<h1>Configuration for JSON API</h1>
<form method ="POST" action ="/jsonConfigure/check">
<label for = "button1">JSON node#1</label><br>
<input type="input" name="button1" id="button1">
<button type="submit">Submit</button>
</form>
<form method ="POST" action ="/jsonConfigure/check">
<label for = "button2">JSON node#2</label><br>
<input type="input" name="button2" id="button2">
<button type="submit">Submit</button>
</form>
<button onClick="location.href = '/';">Return</button>
</center>
</body>
</html>
)rawliteral";