-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPage_Root.h
85 lines (71 loc) · 2.44 KB
/
Page_Root.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
#ifndef PAGE_ROOT_H
#define PAGE_ROOT_H
//
// The EXAMPLE PAGE
//
const char PAGE_root[] PROGMEM = R"=====(
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<h1>Index ESP8266</h1>
<div id="mydynamicdata">Here comes the Dynamic Data in </div> <!-- added a DIV, where the dynamic data goes to -->
<script>
window.onload = function ()
{
load("style.css","css", function()
{
load("microajax.js","js", function()
{
setValues("/admin/filldynamicdata"); //-- this function calls the function on the ESP
});
});
}
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>
)=====";
#endif
void filldynamicdata()
{
String values ="";
values += "mydynamicdata|" + (String) + "This is filled by AJAX. Millis since start: " + (String) millis() + "|div\n"; // Build a string, like this: ID|VALUE|TYPE
server.send ( 200, "text/plain", values);
}
void processRoot()
{
if (server.args() > 0 ) // Are there any POST/GET Fields ?
{
for ( uint8_t i = 0; i < server.args(); i++ ) { // Iterate through the fields
if (server.argName(i) == "firstname")
{
// Your processing for the transmitted form-variable
String fName = server.arg(i);
}
}
}
server.send ( 200, "text/html", PAGE_root );
}
/*
const char PAGE_Root[] PROGMEM = R"=====(
<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="microajax.js"></script>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<link rel="stylesheet" href="style.css" type="text/css" />
It work's!
</body>
</html>
)=====";
void sendRootPage()
{
if (server.args() > 0 ) // Are there any POST/GET Fields ?
{
for ( uint8_t i = 0; i < server.args(); i++ ) { // Iterate through the fields
}
}
server.send ( 200, "text/html", PAGE_Root );
}
*/