-
Notifications
You must be signed in to change notification settings - Fork 4
/
Page_ntp.h
111 lines (96 loc) · 4.25 KB
/
Page_ntp.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
const char PAGE_ntp[] PROGMEM = R"=====(
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<a href="/" class="btn btn--s"><</a> <strong>NTP Settings</strong>
<hr>
<form action="" method="get">
<table border="0" cellspacing="0" cellpadding="3" >
<tr><td align="right">NTP Server:</td><td><input type="text" id="ntpserver" name="ntpserver" maxlength="172" value=""></td></tr>
<tr><td align="right">Update:</td><td><input type="text" id="update" name="update" size="3"maxlength="6" value=""> seconds (0=disable)</td></tr>
<tr><td align="right">Timezone:</td><td>
<select id="tz" name="tz">
<option value="-120">(GMT-12:00)</option>
<option value="-110">(GMT-11:00)</option>
<option value="-100">(GMT-10:00)</option>
<option value="-90">(GMT-09:00)</option>
<option value="-80">(GMT-08:00)</option>
<option value="-70">(GMT-07:00)</option>
<option value="-60">(GMT-06:00)</option>
<option value="-50">(GMT-05:00)</option>
<option value="-40">(GMT-04:00)</option>
<option value="-35">(GMT-03:30)</option>
<option value="-30">(GMT-03:00)</option>
<option value="-20">(GMT-02:00)</option>
<option value="-10">(GMT-01:00)</option>
<option value="0">(GMT+00:00)</option>
<option value="10">(GMT+01:00)</option>
<option value="20">(GMT+02:00)</option>
<option value="30">(GMT+03:00)</option>
<option value="35">(GMT+03:30)</option>
<option value="40">(GMT+04:00)</option>
<option value="45">(GMT+04:30)</option>
<option value="50">(GMT+05:00)</option>
<option value="55">(GMT+05:30)</option>
<option value="57">(GMT+05:45)</option>
<option value="60">(GMT+06:00)</option>
<option value="65">(GMT+06:30)</option>
<option value="70">(GMT+07:00)</option>
<option value="80">(GMT+08:00)</option>
<option value="90">(GMT+09:00)</option>
<option value="95">(GMT+09:30)</option>
<option value="100">(GMT+10:00)</option>
<option value="110">(GMT+11:00)</option>
<option value="120">(GMT+12:00)</option>
<option value="120">(GMT+12:00)</option>
<option value="130">(GMT+13:00)</option>
</select>
</td></tr>
<tr><td align="right">Daylight saving:</td><td><input type="checkbox" id="dst" name="dst"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" style="width:150px" class="btn btn--m btn--blue" value="Save"></td></tr>
</table>
</form>
<script>
window.onload = function ()
{
load("style.css","css", function()
{
load("microajax.js","js", function()
{
setValues("/admin/ntpfieldsvalues");
});
});
}
function load(e,t,n){if("js"==t){var a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}else if("css"==t){var a=document.createElement("link");a.href=e,a.rel="stylesheet",a.type="text/css",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}}
</script>
)=====";
void send_NTP_configuration_html()
{
if (_server.args() > 0 ) // Save Settings
{
_config.isDayLightSaving = false;
String temp = "";
for ( uint8_t i = 0; i < _server.args(); i++ ) {
if (_server.argName(i) == "ntpserver") _config.ntpServerName = urldecode( _server.arg(i));
if (_server.argName(i) == "update") _config.Update_Time_Via_NTP_Every = _server.arg(i).toInt();
if (_server.argName(i) == "tz") _config.timeZone = _server.arg(i).toInt();
if (_server.argName(i) == "dst") _config.isDayLightSaving = true;
}
WriteConfig();
getNTPtime(); // Update NTP time
}
_server.send_P ( 200, "text/html", PAGE_ntp);
//Serial.println(__FUNCTION__);
}
void send_ntp_configuration_values_html()
{
String values ="";
values += "ntpserver|" + (String) _config.ntpServerName + "|input\n";
values += "update|" + (String) _config.Update_Time_Via_NTP_Every + "|input\n";
values += "tz|" + (String) _config.timeZone + "|input\n";
values += "dst|" + (String) (_config.isDayLightSaving ? "checked" : "") + "|chk\n";
_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
_server.sendHeader("Pragma", "no-cache");
_server.sendHeader("Expires", "-1");
_server.send ( 200, "text/plain", values);
//Serial.println(__FUNCTION__);
}