-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages.h
223 lines (222 loc) · 8.63 KB
/
pages.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
// the source of the web page we serve
char CONFIG_PAGE[] = R"(<html>
<head></head>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<style>
body {
font-family: apercu-pro, -apple-system, system-ui, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
padding: 1em;
line-height: 2em;
font-weight: 500;
}
td {
font-weight: 500;
min-height: 24px;
}
td:first-child {
text-align: right;
min-width: 100px;
padding-right: 10px;
}
h1 {
font-size: 1.5em;
font-weight: 700;
}
h2 {
font-size: 1.2em;
font-weight: 500;
margin-left: 5px;
}
input {
border: 1px solid rgb(196, 196, 196);
color: rgb(76, 76, 76);
width: 240px;
border-radius: 3px;
height: 40px;
margin: 3px 0px;
padding: 0px 14px;
}
input:focus {
border:1px solid black;
outline: none !important;
box-shadow: 0 0 10px #719ECE;
}
#config {
width:400px;
margin:0 auto;
}
.ok-button {
background-color: #0078e7;
color: #fff;
border-radius: 5px;
}
.red-button {
background-color: #e72e00;
color: #fff;
border-radius: 5px;
}
#led {
background-color: #%s;
border: 0px;
height: 10px;
width: 10px;
border-radius: 5px;
}
img {
float:right;
}
</style>
<body>
<div id='config'>
<h1> NAT Router Config <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAMAAAExAAIAAAARAAAATgAAAAAAAJOoAAAD6AAAk6gAAAPocGFpbnQubmV0IDQuMy4xMQAA/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxERExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAPABLAwEhAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8AtfHH4qaz4n8RXml6ZfzWmhW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YSC6VmjDkA4DEZwfXGfoa4Mwx9PA01UqdXY7cDgqmMm4Q6K57h+0B8PfDet6JdeJbiCWDVLaMfvrdgvmgcAOCCDj14PbOK+SmgUMRluDXkcM4upWwvJP7Oi9D1OIcLTpYnmj9rVieSvqaPJX1NfR8zPAsHkr6mjyV9TRzMLB5K+po8lfU0czCx6t+z14A8P+L9Zlk1xbmaO1G8QrIFSTno3GcfQivra3hit4I7e3iSKGNQiIi4VVAwAAOgr874mxdSrivZS+GO3zPvOHsNTp4b2i3lv8j/2Q=="
alt="T4ME2 logo" /> </h1>
<script>
if (window.location.search.substr(1) != '')
{
document.getElementById('config').display = 'none';
if (window.location.search.includes('reset'))
{
document.body.innerHTML ='<h1>NAT Router Config</h1>The device will be reset.<br/>The page will refresh soon automatically...';
setTimeout("location.href = '/'",10000);
}
else
{
document.body.innerHTML ='<h1>NAT Router Config</h1>The new settings have been sent to the device.<br/>The page will refresh soon automatically...';
setTimeout("location.href = '/'",3000);
}
}
</script>
<h2>AP Settings (the new network)</h2>
<form action='' method='GET'>
<table>
<tr>
<td>SSID</td>
<td><input type='text' name='ap_ssid' value='%s' placeholder='SSID of the new network'/></td>
</tr>
<tr>
<td>Password</td>
<td><input type='text' name='ap_password' value='%s' placeholder='Password of the new network'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' value='Set' class='ok-button'/></td>
</tr>
</table>
<small>
<i>Password </i>less than 8 chars = open<br />
</small>
</form>
<h2>STA Settings (uplink WiFi network) <button id="led"></button></h2>
<form action='' method='GET'>
<table>
<tr>
<td>SSID</td>
<td><input type='text' name='sta_ssid' value='%s' placeholder='SSID of existing network'/></td>
</tr>
<tr>
<td>Password</td>
<td><input type='text' name='sta_password' value='%s' placeholder='Password of existing network'/></td>
</tr>
<!--
<tr>
<td colspan='2'>WPA2 Enterprise settings. Leave blank for regular</td>
</tr>
<tr>
<td>Username</td>
<td><input type='text' name='ent_username' value='%s' placeholder='WPA2 Enterprise username'/></td>
</tr>
<tr>
<td>Identity</td>
<td><input type='text' name='ent_identity' value='%s' placeholder='WPA2 Enterprise identity'/></td>
</tr>
-->
<tr>
<td></td>
<td><input type='submit' value='Connect' class='ok-button'/></td>
</tr>
</table>
</form>
<h2>STA Static IP Settings</h2>
<form action='' method='GET'>
<table>
<tr>
<td>Static IP</td>
<td><input type='text' name='static_ip' value='%s'/></td>
</tr>
<tr>
<td>Subnet Mask</td>
<td><input type='text' name='subnet_mask' value='%s'/></td>
</tr>
<tr>
<td>Gateway</td>
<td><input type='text' name='gateway' value='%s'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' value='Connect' class='ok-button'/></td>
</tr>
</table>
<small>
<i>Leave it blank if you want to get an IP using DHCP</i>
</small>
</form>
<h2>Device Management</h2>
<form action='' method='GET'>
<table>
<tr>
<td>Device</td>
<td><input type='submit' name='reset' value='Reboot' class='red-button'/></td>
</tr>
</table>
</form>
<h2>Firmware upload</h2>
<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>
<table>
<tr>
<td>Firmware</td><td>
<input type='file' name='update'>
<input type='submit' value='Update' class='red-button'>
</td>
</tr>
</table>
</form>
<table>
<tr>
<td></td><td>
<div id='prg'>progress: </div>
</td>
</tr>
</table>
<script>
var form = document.querySelector('#upload_form');
var per = 0;
form.addEventListener('submit', (evt) => {
evt.preventDefault();
var xhr = new XMLHttpRequest();
var data = new FormData(form);
function updateProgress (evt) {
if (evt.lengthComputable) {
per = evt.loaded / evt.total;
document.querySelector('#prg').innerHTML = ('progress: ' + Math.round(per * 100) + '%%');
}
else document.querySelector('#prg').innerHTML = ('progress: ---');
};
function loadProgress (evt) {
if (evt.lengthComputable) {
per = evt.loaded / evt.total;
document.querySelector('#prg').innerHTML = ('progress: ' + Math.round(per * 100) + '%% '+ xhr.responseText);
if(xhr.responseText.includes("reboot")) setTimeout("location.href = '/'",5000);
}
else document.querySelector('#prg').innerHTML = ('progress: --- ' + xhr.responseText);
console.log(xhr.responseText);
};
xhr.upload.addEventListener('progress', updateProgress);
xhr.addEventListener('loadend', loadProgress);
xhr.open('POST', '/update');
xhr.send(data);
});
</script>
</div>
</body>
</html>
)";