Improved code readability

pull/41/head
Hieromon Ikasamo 6 years ago
parent 48c6ea8b4e
commit c428a33aa9
  1. 1
      src/AutoConnect.cpp
  2. 1
      src/AutoConnect.h
  3. 5
      src/AutoConnectDefs.h
  4. 37
      src/AutoConnectPage.cpp

@ -706,7 +706,6 @@ String AutoConnect::_induceConnect(PageArgument& args) {
// Turn on the trigger to start WiFi.begin().
_rfConnect = true;
_menuTitle = String(F(AUTOCONNECT_CONNECTING_TITLE));
// Since v0.9.7, the redirect method changed from a 302 response to the
// meta tag with refresh attribute.

@ -336,7 +336,6 @@ class AutoConnect {
String _token_UPTIME(PageArgument& args);
String _token_BOOTURI(PageArgument& args);
String _token_CURRENT_SSID(PageArgument& args);
String _token_RESULT_URI(PageArgument& args);
#if defined(ARDUINO_ARCH_ESP8266)
friend class ESP8266WebServer;

@ -76,11 +76,6 @@
#define AUTOCONNECT_MENU_TITLE "AutoConnect"
#endif // !AUTOCONNECT_MENU_TITLE
// AutoConnect title for during a connection attempting
#ifndef AUTOCONNECT_CONNECTING_TITLE
#define AUTOCONNECT_CONNECTING_TITLE "Connecting"
#endif // !AUTOCONNECT_CONNECTING_TITLE
// URIs of AutoConnect menu collection
#define AUTOCONNECT_URI_CONFIG AUTOCONNECT_URI "/config"
#define AUTOCONNECT_URI_CONNECT AUTOCONNECT_URI "/connect"

@ -3,7 +3,7 @@
* @file AutoConnectPage.h
* @author hieromon@gmail.com
* @version 0.9.7
* @date 2018-11-17
* @date 2019-01-23
* @copyright MIT license.
*/
@ -291,18 +291,18 @@ const char AutoConnect::_CSS_SPINNER[] PROGMEM = {
"animation:sk-bounce 2.0s infinite ease-in-out;"
"}"
".double-bounce2{"
"-webkit-animation-delay: -1.0s;"
"animation-delay: -1.0s;"
"-webkit-animation-delay:-1.0s;"
"animation-delay:-1.0s;"
"}"
"@-webkit-keyframes sk-bounce{"
"0%, 100% {-webkit-transform:scale(0.0)}"
"50% {-webkit-transform:scale(1.0)}"
"0%, 100%{-webkit-transform:scale(0.0)}"
"50%{-webkit-transform:scale(1.0)}"
"}"
"@keyframes sk-bounce{"
"0%, 100% {"
"0%,100%{"
"transform:scale(0.0);"
"-webkit-transform:scale(0.0);"
"} 50% {"
"}50%{"
"transform:scale(1.0);"
"-webkit-transform:scale(1.0);"
"}"
@ -503,7 +503,7 @@ const char AutoConnect::_ELM_HTML_HEAD[] PROGMEM = {
"<!DOCTYPE html>"
"<html>"
"<head>"
"<meta charset=\"UTF-8\" name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
"<meta charset=\"UTF-8\" name=\"viewport\" content=\"width=device-width,initial-scale=1\">"
};
/**< LuxBar menu element. */
@ -550,7 +550,7 @@ const char AutoConnect::_PAGE_404[] PROGMEM = {
/**< The page that started the reset. */
const char AutoConnect::_PAGE_RESETTING[] PROGMEM = {
"{{HEAD}}"
"<meta http-equiv=\"refresh\" content=\"{{UPTIME}};URL={{BOOTURI}}\">"
"<meta http-equiv=\"refresh\" content=\"{{UPTIME}};url={{BOOTURI}}\">"
"<title>AutoConnect resetting</title>"
"</head>"
"<body>"
@ -711,7 +711,7 @@ const char AutoConnect::_PAGE_OPENCREDT[] PROGMEM = {
const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = {
"{{REQ}}"
"{{HEAD}}"
"<meta http-equiv=\"refresh\" content=\"0;url=http://{{URI_RESULT}}\">"
"<meta http-equiv=\"refresh\" content=\"0;url=" AUTOCONNECT_URI_RESULT "\">"
"<title>AutoConnect connecting</title>"
"<style type=\"text/css\">"
"{{CSS_BASE}}"
@ -719,9 +719,9 @@ const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = {
"{{CSS_LUXBAR}}"
"</style>"
"<script type=\"text/javascript\">"
"setTimeout(\"link()\"," AUTOCONNECT_RESPONSEREQUEST_TIMEOUT " );"
"setTimeout(\"link()\"," AUTOCONNECT_RESPONSEREQUEST_TIMEOUT ");"
"function link(){"
"location.href='http://{{URI_RESULT}}';"
"location.href='" AUTOCONNECT_URI_RESULT "';"
"</script>"
"</head>"
"<body style=\"padding-top:58px;\">"
@ -732,6 +732,8 @@ const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = {
"<div style=\"position:absolute;left:-100%;right:-100%;text-align:center;margin:10px auto;font-weight:bold;color:#4169e1;\">{{CUR_SSID}}</div>"
"<div class=\"double-bounce1\"></div>"
"<div class=\"double-bounce2\"></div>"
"</div>"
"</div>"
"</body>"
"</html>"
};
@ -832,8 +834,8 @@ const char AutoConnect::_PAGE_DISCONN[] PROGMEM = {
"<body style=\"padding-top:58px;\">"
"<div class=\"container\">"
"{{MENU_PRE}}"
"{{MENU_AUX}}"
"{{MENU_POST}}"
"</div>"
"</body>"
"</html>"
};
@ -1172,11 +1174,6 @@ String AutoConnect::_token_CURRENT_SSID(PageArgument& args) {
return String(reinterpret_cast<char*>(_credential.ssid));
}
String AutoConnect::_token_RESULT_URI(PageArgument& args) {
AC_UNUSED(args);
return _webServer->client().localIP().toString() + String(AUTOCONNECT_URI_RESULT);
}
/**
* This function dynamically build up the response pages that conform to
* the requested URI. A PageBuilder instance is stored in _rensponsePage
@ -1239,10 +1236,10 @@ PageElement* AutoConnect::_setupPage(String uri) {
else if (uri == String(AUTOCONNECT_URI_CONNECT)) {
// Setup /auto/connect
_menuTitle = FPSTR("Connecting");
elm->setMold(_PAGE_CONNECTING);
elm->addToken(String(FPSTR("REQ")), std::bind(&AutoConnect::_induceConnect, this, std::placeholders::_1));
elm->addToken(String(FPSTR("HEAD")), std::bind(&AutoConnect::_token_HEAD, this, std::placeholders::_1));
elm->addToken(String(FPSTR("URI_RESULT")), std::bind(&AutoConnect::_token_RESULT_URI, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_SPINNER")), std::bind(&AutoConnect::_token_CSS_SPINNER, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_LUXBAR")), std::bind(&AutoConnect::_token_CSS_LUXBAR, this, std::placeholders::_1));
@ -1274,7 +1271,6 @@ PageElement* AutoConnect::_setupPage(String uri) {
elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_LUXBAR")), std::bind(&AutoConnect::_token_CSS_LUXBAR, this, std::placeholders::_1));
elm->addToken(String(FPSTR("MENU_PRE")), std::bind(&AutoConnect::_token_MENU_PRE, this, std::placeholders::_1));
elm->addToken(String(FPSTR("MENU_AUX")), std::bind(&AutoConnect::_token_MENU_AUX, this, std::placeholders::_1));
elm->addToken(String(FPSTR("MENU_POST")), std::bind(&AutoConnect::_token_MENU_POST, this, std::placeholders::_1));
}
else if (uri == String(AUTOCONNECT_URI_RESET)) {
@ -1315,6 +1311,7 @@ PageElement* AutoConnect::_setupPage(String uri) {
else if (uri == String(AUTOCONNECT_URI_FAIL)) {
// Setup /auto/fail
_menuTitle = FPSTR("Failed");
elm->setMold(_PAGE_FAIL);
elm->addToken(String(FPSTR("HEAD")), std::bind(&AutoConnect::_token_HEAD, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1));

Loading…
Cancel
Save