@ -43,7 +43,7 @@ const char AutoConnectAux::_PAGE_AUX[] PROGMEM = {
" {{MENU_AUX}} "
" {{MENU_POST}} "
" <div class= \" base-panel \" ><div class= \" aux-page \" > "
" <form id='_aux' method= \" post \" onsubmit= \" return false; \" > "
" <form id='_aux' method= \" post \" onsubmit= \" return false; \" {{ENC_TYPE}} >"
" <ul class= \" noorder \" > "
" {{AUX_ELEMENT}} "
" </ul> "
@ -263,6 +263,23 @@ const String AutoConnectAux::_indicateUri(PageArgument& args) {
return lastUri ;
}
/**
* Modifying the form of attribute depending on the type of ` input ` tag
* contained . If the custom web page contains ` input type = file ` then
* allows multipart as ENCTYPE attribute .
* @ param args A reference of PageArgument but unused .
* @ return HTML string that should be inserted .
*/
const String AutoConnectAux : : _indicateEncType ( PageArgument & args ) {
AC_UNUSED ( args ) ;
String encType = String ( " " ) ;
for ( AutoConnectElement & elm : _addonElm )
if ( elm . typeOf ( ) = = AC_File ) {
return String ( F ( " enctype='multipart/form-data' " ) ) ;
}
return AutoConnect : : _emptyString ;
}
/**
* Insert the token handler of PageBuilder . This handler inserts HTML
* elements generated by the whole AutoConnectElements to the auxiliary page .
@ -328,6 +345,7 @@ PageElement* AutoConnectAux::_setupPage(const String& uri) {
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 ) ) ;
elm - > addToken ( String ( FPSTR ( " AUX_URI " ) ) , std : : bind ( & AutoConnectAux : : _indicateUri , this , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " ENC_TYPE " ) ) , std : : bind ( & AutoConnectAux : : _indicateEncType , this , std : : placeholders : : _1 ) ) ;
elm - > addToken ( String ( FPSTR ( " AUX_ELEMENT " ) ) , std : : bind ( & AutoConnectAux : : _insertElement , this , std : : placeholders : : _1 ) ) ;
}
}
@ -411,6 +429,23 @@ AutoConnectCheckboxBasis& AutoConnectAux::getElement(const String& name) {
return reinterpret_cast < AutoConnectCheckboxBasis & > ( _nullElement ( ) ) ;
}
/**
* Get AutoConnectFileBasis element .
* @ param name An element name .
* @ return A reference of AutoConnectFile class .
*/
template < >
AutoConnectFileBasis & AutoConnectAux : : getElement ( const String & name ) {
AutoConnectElement * elm = getElement ( name ) ;
if ( elm ) {
if ( elm - > typeOf ( ) = = AC_Input )
return * ( reinterpret_cast < AutoConnectFileBasis * > ( elm ) ) ;
else
AC_DBG ( " Element<%s> type mismatch<%d> \n " , name . c_str ( ) , elm - > typeOf ( ) ) ;
}
return reinterpret_cast < AutoConnectFileBasis & > ( _nullElement ( ) ) ;
}
/**
* Get AutoConnectInputBasis element .
* @ param name An element name .
@ -546,6 +581,23 @@ AutoConnectCheckboxJson& AutoConnectAux::getElement(const String& name) {
return reinterpret_cast < AutoConnectCheckboxJson & > ( _nullElement ( ) ) ;
}
/**
* Get AutoConnectFile element .
* @ param name An element name .
* @ return A reference of AutoConnectFile class .
*/
template < >
AutoConnectFileJson & AutoConnectAux : : getElement ( const String & name ) {
AutoConnectElement * elm = getElement ( name ) ;
if ( elm ) {
if ( elm - > typeOf ( ) = = AC_File )
return * ( reinterpret_cast < AutoConnectFileJson * > ( elm ) ) ;
else
AC_DBG ( " Element<%s> type mismatch<%d> \n " , name . c_str ( ) , elm - > typeOf ( ) ) ;
}
return reinterpret_cast < AutoConnectFileJson & > ( _nullElement ( ) ) ;
}
/**
* Get AutoConnectInputJson element .
* @ param name An element name .
@ -730,6 +782,10 @@ AutoConnectElement* AutoConnectAux::_createElement(const JsonObject& json) {
AutoConnectCheckbox * cert_elm = new AutoConnectCheckbox ;
return reinterpret_cast < AutoConnectElement * > ( cert_elm ) ;
}
case AC_File : {
AutoConnectFile * cert_elm = new AutoConnectFile ;
return reinterpret_cast < AutoConnectElement * > ( cert_elm ) ;
}
case AC_Input : {
AutoConnectInput * cert_elm = new AutoConnectInput ;
return reinterpret_cast < AutoConnectElement * > ( cert_elm ) ;
@ -977,6 +1033,7 @@ ACElement_t AutoConnectAux::_asElementType(const String& type) {
{ AUTOCONNECT_JSON_TYPE_ACBUTTON , AC_Button } ,
{ AUTOCONNECT_JSON_TYPE_ACCHECKBOX , AC_Checkbox } ,
{ AUTOCONNECT_JSON_TYPE_ACELEMENT , AC_Element } ,
{ AUTOCONNECT_JSON_TYPE_ACFILE , AC_File } ,
{ AUTOCONNECT_JSON_TYPE_ACINPUT , AC_Input } ,
{ AUTOCONNECT_JSON_TYPE_ACRADIO , AC_Radio } ,
{ AUTOCONNECT_JSON_TYPE_ACSELECT , AC_Select } ,