- [AutoConnectText](#autoconnecttext): Style attributed text
## Layout on a custom Web page
The elements of the page created by AutoConnectElements are aligned vertically exclude the [AutoConnectRadio](#autoconnectradio). You can specify the direction to arrange the radio buttons as AutoConnectRadio vertically or horizontally. This basic layout depends on the CSS of the AutoConnect menu so you can not change drastically.
AutoConnect will not actively be involved in the layout of custom Web pages generated from AutoConnectElements. However, each element has [an attribute to arrange placement](#post) on a custom web page by horizontally or vertically.
## Custom CSS for a custom Web page
All custom Web page styles are limited to the built-in unique CSS embedded in the library code. Direct modification of the CSS affects AutoConnect behavior. You can use dedicated elements to relatively safely modify the style of your custom Web page.
The [AutoConnectStyle](#autoconnectstyle) will insert the raw CSS code into the style block in HTML of the custom Web page.
## Form and AutoConnectElements
@ -32,7 +38,7 @@ AutoConnectElement is a base class for other element classes and has common attr
@ -43,6 +49,29 @@ Each element has a name. The **name** is the String data type. You can identify
The **value** is the string which is a source to generate an HTML code. Characteristics of Value vary depending on the element. The value of AutoConnectElement is native HTML code. A string of value is output as HTML as it is.
### <iclass="fa fa-caret-right"></i> post
The **post** specifies a tag to add behind the HTML code generated from the element. Its purpose is to place elements on the custom Web page as intended by the user sketch.
AutoConnect will not actively be involved in the layout of custom Web pages generated from AutoConnectElements. Each element follows behind the previous one, with the exception of some elements. You can use the **post** value to arrange vertically or horizontal when the elements do not have the intended position on the custom Web Page specifying the following enumeration value as **ACPosterior_t** type for the **post**.
- **`AC_Tag_None`** : No generate additional tags.
- **`AC_Tag_BR`** : Add a `<br>` tag to the end of the element.
- **`AC_Tag_P`** : Include the element in the `<p> ~ </p>` tag.
The default interpretation of the post value is specific to each element.
AutoConnectElements | Default interpretation of the post value
----|----
AutoConnectElement | AC_Tag_None
AutoConnectButton | AC_Tag_None
AutoConnectCheckBox | AC_Tag_BR
AutoConnectFile | AC_Tag_BR
AutoConnectInput | AC_Tag_BR
AutoConnectRadio | AC_Tag_BR
AutoConnectSelect | AC_Tag_BR
AutoConnectSubmit | AC_Tag_None
AutoConnectText | AC_Tag_None
### <iclass="fa fa-caret-right"></i> type
The **type** indicates the type of the element and represented as the *ACElement_t* enumeration type in the sketch. Since AutoConnectElement also acts as a variant of other elements, it can be applied to handle elements collectively. At that time, the type can be referred to by the [**typeOf()**](apielements.md#typeof) function. The following example changes the font color of all [AutoConnectText](#autoconnecttext) elements of a custom Web page to gray.
@ -68,6 +97,7 @@ The enumerators for *ACElement_t* are as follows:
- AutoConnectInput: **AC_Input**
- AutoConnectRadio: **AC_Radio**
- AutoConnectSelect: **AC_Select**
- AutoConnectStyle: **AC_Style**
- AutoConnectSubmit: **AC_Submit**
- AutoConnectText: **AC_Text**
- Uninitialized element: **AC_Unknown**
@ -100,7 +130,7 @@ AutoConnectButton generates an HTML `#!html <button type="button">` tag and loca
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_None`.
## AutoConnectCheckbox
AutoConnectCheckbox generates an HTML `#!html <input type="checkbox">` tag and a `#!html <label>` tag. It places horizontally on a custom Web page by default.
@ -143,7 +177,7 @@ AutoConnectCheckbox generates an HTML `#!html <input type="checkbox">` tag and a
@ -163,9 +197,20 @@ Only <i class="far fa-square"></i> will be displayed if a label is not specified
A checked is a Boolean value and indicates the checked status of the checkbox. The value of the checked checkbox element is packed in the query string and sent.
The position of the label belonging to the checkbox can be specified around the element. The labelPosition specifies the position of the label to generate with **ACPostion_t** enumeration value. The default value is `AC_Behind`.
- **`AC_Infront`** : Place a label in front of the check box.
- **`AC_Behind`** : Place a label behind the check box.
### <iclass="fa fa-caret-right"></i> post
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_BR`.
## AutoConnectFile
AutoConnectFile generates asn HTML `#!html <input type="file">` tag and a `#!html <label>` tag. AutoConnectFile enables file upload from the client through the web browser to ESP8266/ESP32 module. You can select the flash in the module, external SD device or any output destination as the storage of the uploaded file.
AutoConnectFile generates an HTML `#!html <input type="file">` tag and a `#!html <label>` tag. AutoConnectFile enables file upload from the client through the web browser to ESP8266/ESP32 module. You can select the flash in the module, external SD device or any output destination as the storage of the uploaded file.
@ -201,6 +246,10 @@ Specifies the destination to save the uploaded file. The destination can be spec
!!! note "Built-in uploader is ready."
AutoConnect already equips the built-in uploader for saving to the SPIFFS as AC_File_FS and the external SD as AC_File_SD. It is already implemented inside AutoConnect and will store uploaded file automatically.
### <iclass="fa fa-caret-right"></i> post
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_BR`.
## AutoConnectInput
AutoConnectInput generates an HTML `#!html <input type="text">` tag and a `#!html <label>` tag. It can also have a placeholder. The value of the input box is passed to the destination in the query string and can be retrieved programmatically. You can also update from the sketches.
@ -213,7 +262,7 @@ AutoConnectInput generates an HTML `#!html <input type="text">` tag and a `#!htm
@ -247,6 +296,10 @@ A `pattern` specifies a [regular expression](https://www.w3schools.com/js/js_reg
A placeholder is an option string. Specification of a placeholder will generate a `placeholder` attribute for the input tag.
### <iclass="fa fa-caret-right"></i> post
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_BR`.
## AutoConnectRadio
AutoConnectRadio generates few HTML `#!html <input type="radio">` tags as grouped and the same number of `#!html <label>` tags. AutoConnectRadio can keep the value of a radio button as a collection. The grouped values will be placed in the custom Web page to select only one exclusively.
@ -259,7 +312,7 @@ AutoConnectRadio generates few HTML `#!html <input type="radio">` tags as groupe
@ -287,6 +340,32 @@ A label will place in the left or the top according to the **order**.
A `checked` specifies the index number (1-based) of the **values** to be checked. If this parameter is not specified neither item is checked.
### <iclass="fa fa-caret-right"></i> post
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_BR`.
## AutoConnectStyle
AutoConnectStyle inserts the string given by the **value** into the style block of a custom Web page as it is raw.
!!! warning "The validity as CSS will not be checked"
AutoConnectStyle does not do syntax checking and semantic analysis of value. Insert the specified string into the style block of the custom Web page without processing it.
Therefore, specifying the wrong CSS will modulate the behavior of the custom Web page.
It is the `name` of the AutoConnectStyle element and is useful only to access this element from the sketch. It does not affect the generated HTML code.
### <iclass="fa fa-caret-right"></i> value
The raw CSS code. It is not necessary to write `<style>``</style>` tags.
## AutoConnectSelect
AutoConnectSelect generates an HTML `#!html <select>` tag (drop-down list) and few `#!html <option>` tags.
@ -299,7 +378,7 @@ AutoConnectSelect generates an HTML `#!html <select>` tag (drop-down list) and f
@ -318,6 +397,10 @@ A `label` is an optional string. A label is always arranged on the left side of
A `selected` is an optional value. Specifies that an option should be pre-selected when the page loads.
### <iclass="fa fa-caret-right"></i> post
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_BR`.
## AutoConnectSubmit
AutoConnectSubmit generates an HTML `#!html <input type="button">` tag attached `#!html onclick` attribute. The native code of the `#!html onclick` attribute is the submission of the form with the **POST** method.
@ -330,7 +413,7 @@ AutoConnectSubmit generates an HTML `#!html <input type="button">` tag attached
@ -378,7 +465,11 @@ A `style` specifies the qualification style to give to the content and can use t
### <iclass="fa fa-caret-right"></i> format
A `format` is a pointer to a null-terminated multibyte string specifying how to interpret the value. It specifies the conversion format when outputting values. The format string conforms to C-style printf library functions, but depends on the espressif sdk implementation. The conversion specification is valid only in **%s** format. (Left and Right justification, width are also valid.)
A `format` is a pointer to a null-terminated multi byte string specifying how to interpret the value. It specifies the conversion format when outputting values. The format string conforms to C-style printf library functions, but depends on the Espressif's SDK implementation. The conversion specification is valid only in **%s** format. (Left and Right justification, width are also valid.)
### <iclass="fa fa-caret-right"></i> post
Specifies a tag to add behind the HTML code generated from the element. The default values is `AC_Tag_None`.
## How to coding for the elements
@ -388,23 +479,25 @@ Variables of each AutoConnetElement can be declared with macros. By using the ma
[^2]: The square brackets in the syntax are optional parameters, the stroke is a selection parameter, the bold fonts are literal.
Casts the reference to the AutoConnectElement the specified type.
<dlclass="apidl">
<dt>**Parameter**</dt>
<dd><spanclass="apidef">T</span><spanclass="apidesc">The element type. AutoConnectElements type such as [AutoConnectButton](apielements.md#autoconnectbutton), [AutoConnectCheckbox](apielements.md#autoconnectcheckbox), [AutoConnectFile](apielements.md#autoconnectfile), [AutoConnectInput](apielements.md#autoconnectinput), [AutoConnectRadio](apielements.md#autoconnectradio), [AutoConnectSelect](apielements.md#autoconnectselect), [AutoConnectSubmit](apielements.md#autoconnectsubmit), [AutoConnectText](apielements.md#autoconnecttext).</span></dd>
<dd><spanclass="apidef">T</span><spanclass="apidesc">The element type. AutoConnectElements type such as [AutoConnectButton](apielements.md#autoconnectbutton), [AutoConnectCheckbox](apielements.md#autoconnectcheckbox), [AutoConnectFile](apielements.md#autoconnectfile), [AutoConnectInput](apielements.md#autoconnectinput), [AutoConnectRadio](apielements.md#autoconnectradio), [AutoConnectSelect](apielements.md#autoconnectselect), [AutoConnectStyle](apielements.md#autoconnectstyle),[AutoConnectSubmit](apielements.md#autoconnectsubmit), [AutoConnectText](apielements.md#autoconnecttext).</span></dd>
<dt>**Return value**</dt>
<dd>A reference to the AutoConnectElement with actual type.</dd>
</dl>
@ -201,7 +243,7 @@ Casts the reference to the AutoConnectElement the specified type.
### <iclass="fa fa-code"></i> Constructor
```cpp
AutoConnectFile(const char* name = "", const char* value = "", const char* label = "", const ACFile_t store = AC_File_FS)
AutoConnectFile(const char* name = "", const char* value = "", const char* label = "", const ACFile_t store = AC_File_FS, const ACPosterior_t post = AC_Tag_BR)
```
<dlclass="apidl">
<dt>**Parameters**</dt>
@ -209,7 +251,7 @@ AutoConnectFile(const char* name = "", const char* value = "", const char* label
<dd><spanclass="apidef">value</span><spanclass="apidesc">File name to be upload.</span></dd>
- **`AC_Tag_None`** : No generate additional tags.
- **`AC_Tag_BR`** : Add a `<br>` tag to the end of the element.
- **`AC_Tag_P`** : Include the element in the `<p> ~ </p>` tag.
</span></dd>
</dl>
#### <iclass="fa fa-caret-right"></i> values
An array of String type for the radio button options. It is an initialization list can be used. The `#!html <input type="radio">` tags will be generated from each entry in the values.
@ -537,7 +620,7 @@ Returns current checked option of the radio buttons.
<dd><spanclass="apidef">options</span><spanclass="apidesc">An array of options of the select element. Specifies a [std::vector](https://en.cppreference.com/w/cpp/container/vector) object.</span></dd>
### <iclass="fa fa-code"></i> Public member functions
#### <iclass="fa fa-caret-right"></i> typeOf
```cpp
ACElement_t typeOf(void)
```
Returns type of AutoConnectElement.
<dlclass="apidl">
<dt>**Return value**</dt>
<dd>AC_Style</dd>
</dl>
## AutoConnectSubmit
### <iclass="fa fa-code"></i> Constructor
```cpp
AutoConnectSubmit(const char* name = "", const char* value ="", char* uri = "")
AutoConnectSubmit(const char* name = "", const char* value ="", char* uri = "", const ACPosterior_t post = AC_Tag_None)
```
<dlclass="apidl">
<dt>**Parameters**</dt>
<dd><spanclass="apidef">name</span><spanclass="apidesc">The element name.</span></dd>
<dd><spanclass="apidef">value</span><spanclass="apidesc">The name of the submit button as an HTML `#!html <input type="button">` tag, it will also be the label of the button.</span></dd>
- **`AC_Tag_None`** : No generate additional tags.
- **`AC_Tag_BR`** : Add a `<br>` tag to the end of the element.
- **`AC_Tag_P`** : Include the element in the `<p> ~ </p>` tag.
</span></dd>
</dl>
#### <iclass="fa fa-caret-right"></i> uri
Destination URI.
@ -738,7 +901,7 @@ Returns type of AutoConnectElement.
### <iclass="fa fa-code"></i> Constructor
```cpp
AutoConnectText(const char* name = "", const char* value = "", const char* style = "", const char* format = "")
AutoConnectText(const char* name = "", const char* value = "", const char* style = "", const char* format = "", const ACPosterior_t post = AC_Tag_None)
```
<dlclass="apidl">
<dt>**Parameters**</dt>
@ -746,6 +909,7 @@ AutoConnectText(const char* name = "", const char* value = "", const char* style
<dd><spanclass="apidef">value</span><spanclass="apidesc">String of content for the text element.</span></dd>
<dd><spanclass="apidef">style</span><spanclass="apidesc">A style code with CSS format that qualifiers the text.</span></dd>
<dd><spanclass="apidef">format</span><spanclass="apidesc">A pointer to a null-terminated multibyte string specifying how to interpret the value. It specifies the conversion format when outputting values. The format string conforms to C-style printf library functions</span></dd>
<dd><spanclass="apidef">post</span><spanclass="apidesc">Specifies the tag to be output afterward the element.</span></dd>
</dl>
### <iclass="fa fa-code"></i> Public member variables