@ -36,6 +36,7 @@ const char AutoConnectAux::_PAGE_AUX[] PROGMEM = {
" {{CSS_INPUT_BUTTON}} "
" {{CSS_INPUT_TEXT}} "
" {{CSS_LUXBAR}} "
" {{AUX_CSS}} "
" </style> "
" </head> "
" <body style= \" padding-top:58px; \" > "
@ -409,8 +410,14 @@ const String AutoConnectAux::_insertElement(PageArgument& args) {
}
// Generate HTML for all AutoConnectElements contained in the page.
for ( AutoConnectElement & addon : _addonElm )
body + = addon . toHTML ( ) ;
for ( AutoConnectElement & addon : _addonElm ) {
// Since the style sheet has already drained at the time of the
// _insertElement function call, it skips the call to the HTML
// generator by each element.
if ( addon . typeOf ( ) ! = AC_Style )
// Invoke an HTML generator by each element
body + = addon . toHTML ( ) ;
}
// Call user handler after HTML generation.
if ( _handler ) {
@ -422,6 +429,21 @@ const String AutoConnectAux::_insertElement(PageArgument& args) {
return body ;
}
/**
* Insert user defined CSS code to AutoConnectAux page .
* @ param args A reference of PageArgument but unused .
* @ return HTML string that should be inserted .
*/
const String AutoConnectAux : : _insertStyle ( PageArgument & args ) {
String css = String ( " " ) ;
for ( AutoConnectElement & elm : _addonElm ) {
if ( elm . typeOf ( ) = = AC_Style )
css + = elm . toHTML ( ) ;
}
return css ;
}
/**
* Generate an auxiliary page assembled with the AutoConnectElement .
* This function is the core procedure of AutoConnectAux , and uses
@ -455,6 +477,7 @@ PageElement* AutoConnectAux::_setupPage(const String& uri) {
elm - > addToken ( String ( FPSTR ( " CSS_INPUT_BUTTON " ) ) , std : : bind ( & AutoConnect : : _token_CSS_INPUT_BUTTON , mother , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " CSS_INPUT_TEXT " ) ) , std : : bind ( & AutoConnect : : _token_CSS_INPUT_TEXT , mother , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " CSS_LUXBAR " ) ) , std : : bind ( & AutoConnect : : _token_CSS_LUXBAR , mother , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " AUX_CSS " ) ) , std : : bind ( & AutoConnectAux : : _insertStyle , this , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " MENU_PRE " ) ) , std : : bind ( & AutoConnect : : _token_MENU_PRE , mother , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " MENU_AUX " ) ) , std : : bind ( & AutoConnect : : _token_MENU_AUX , mother , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " MENU_POST " ) ) , std : : bind ( & AutoConnect : : _token_MENU_POST , mother , std : : placeholders : : _1 ) ) ;
@ -618,6 +641,10 @@ AutoConnectElement* AutoConnectAux::_createElement(const JsonObject& json) {
AutoConnectSelect * cert_elm = new AutoConnectSelect ;
return reinterpret_cast < AutoConnectElement * > ( cert_elm ) ;
}
case AC_Style : {
AutoConnectStyle * cert_elm = new AutoConnectStyle ;
return reinterpret_cast < AutoConnectElement * > ( cert_elm ) ;
}
case AC_Submit : {
AutoConnectSubmit * cert_elm = new AutoConnectSubmit ;
return reinterpret_cast < AutoConnectElement * > ( cert_elm ) ;
@ -892,6 +919,7 @@ ACElement_t AutoConnectAux::_asElementType(const String& type) {
{ AUTOCONNECT_JSON_TYPE_ACINPUT , AC_Input } ,
{ AUTOCONNECT_JSON_TYPE_ACRADIO , AC_Radio } ,
{ AUTOCONNECT_JSON_TYPE_ACSELECT , AC_Select } ,
{ AUTOCONNECT_JSON_TYPE_ACSTYLE , AC_Style } ,
{ AUTOCONNECT_JSON_TYPE_ACSUBMIT , AC_Submit } ,
{ AUTOCONNECT_JSON_TYPE_ACTEXT , AC_Text }
} ;