//---------------------------------------------------------
void handle_cfg() {
String savecfg;
String cfg;
if (server.args() > 0) {
for ( uint8_t i = 0; i < server.args(); i++ ) {if (server.argName(i) == "plain"){cfg = server.arg(i);}}
Serialprintln("запись cfg");
File myFile =
SPIFFS.open(filecfg, "w");
if (myFile) {myFile.print(cfg);
myFile.close();
delay(1000);
WiFi.disconnect();
delay(1000);
ESP.restart();
}
}
File dataFile =
SPIFFS.open(filecfg, "r");
String t = "\
<!DOCTYPE HTML>\
<html>\
<head>\
<meta charset='utf-8'>\
<meta name='viewport' content='width=device-width,minimum-scale=1,maximum-scale=1,initial-scale=1,user-scalable=no'>\
<meta name='format-detection' content='telephone=no'>\
<meta name='mobile-web-app-capable' content='yes'><meta name='referrer' content='origin'/>\
<title>"+appname+"</title>\
<script>\
function \
set_cfg(f){\
server = '?savecfg=';\
request = new XMLHttpRequest();\
request.open('POST', server, true);\
request.send(f.ncfg.value);\
alert('cfg записан');\
}\
</script>\
</head>\
<style>body {width:360px; padding:0px; margin:0px; background-color: #000000; font-family: Courier; Color: #FFFFFF; font-size: 10px;}</style>\
<body>\
<table width:300px;><tr width:300px><td>\
<form action='handler.php'>\
<textarea width:300px; rows=\"40\" cols=\"50\" name=\"ncfg\">" + String(dataFile.readString()) + "</textarea>\
<input type=\"button\"value=\"Назад\"onclick=\"location.href='http://"+IP+"'\"/>\
<input type=\"button\"value=\"Сохранить\"onclick=\"set_cfg(this.form)\">\
</form>\
</td></tr></table></body></html>";
server.send ( 200, "text/html", t);
}