|
|
|
@ -181,23 +181,21 @@ void AutoConnectRadioBasis::empty(const size_t reserve) { |
|
|
|
|
const String AutoConnectRadioBasis::toHTML(void) const { |
|
|
|
|
String html = String(""); |
|
|
|
|
|
|
|
|
|
if (enable) { |
|
|
|
|
if (label.length()) { |
|
|
|
|
html = label; |
|
|
|
|
if (order == AC_Vertical) |
|
|
|
|
html += String(F("<br>")); |
|
|
|
|
} |
|
|
|
|
uint8_t n = 0; |
|
|
|
|
for (const String value : _values) { |
|
|
|
|
n++; |
|
|
|
|
String id = name + "_" + String(n); |
|
|
|
|
html += String(F("<input type=\"radio\" name=\"")) + name + String(F("\" id=\"")) + id + String(F("\" value=\"")) + value + String("\""); |
|
|
|
|
if (n == checked - 1) |
|
|
|
|
html += String(F(" checked")); |
|
|
|
|
html += String(F("><label for=\"")) + id + String("\">") + value + String(F("</label>")); |
|
|
|
|
if (order == AC_Vertical) |
|
|
|
|
html += String(F("<br>")); |
|
|
|
|
} |
|
|
|
|
if (label.length()) { |
|
|
|
|
html = label; |
|
|
|
|
if (order == AC_Vertical) |
|
|
|
|
html += String(F("<br>")); |
|
|
|
|
} |
|
|
|
|
uint8_t n = 0; |
|
|
|
|
for (const String value : _values) { |
|
|
|
|
n++; |
|
|
|
|
String id = name + "_" + String(n); |
|
|
|
|
html += String(F("<input type=\"radio\" name=\"")) + name + String(F("\" id=\"")) + id + String(F("\" value=\"")) + value + String("\""); |
|
|
|
|
if (n == checked) |
|
|
|
|
html += String(F(" checked")); |
|
|
|
|
html += String(F("><label for=\"")) + id + String("\">") + value + String(F("</label>")); |
|
|
|
|
if (order == AC_Vertical) |
|
|
|
|
html += String(F("<br>")); |
|
|
|
|
} |
|
|
|
|
return html; |
|
|
|
|
} |
|
|
|
@ -205,7 +203,7 @@ const String AutoConnectRadioBasis::toHTML(void) const { |
|
|
|
|
/**
|
|
|
|
|
* Returns current selected value in the radio same group |
|
|
|
|
*/ |
|
|
|
|
const String& AutoConnectRadioBasis::value() const { |
|
|
|
|
const String& AutoConnectRadioBasis::value(void) const { |
|
|
|
|
static const String _nullString = String(); |
|
|
|
|
return checked ? _values.at(checked - 1) : _nullString; |
|
|
|
|
} |
|
|
|
@ -223,6 +221,19 @@ void AutoConnectSelectBasis::empty(const size_t reserve) { |
|
|
|
|
_options.reserve(reserve); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicate an entry with the specified value in the value's collection. |
|
|
|
|
* @param value The value to indicates in the collection. |
|
|
|
|
*/ |
|
|
|
|
void AutoConnectSelectBasis::select(const String& value) { |
|
|
|
|
for (std::size_t n = 0; n < _options.size(); n++) { |
|
|
|
|
if (at(n).equalsIgnoreCase(value)) { |
|
|
|
|
selected = n + 1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate an HTML <select> element with an <option> element. |
|
|
|
|
* The attribute value of the <option> element is given to the |
|
|
|
@ -234,17 +245,28 @@ void AutoConnectSelectBasis::empty(const size_t reserve) { |
|
|
|
|
const String AutoConnectSelectBasis::toHTML(void) const { |
|
|
|
|
String html = String(""); |
|
|
|
|
|
|
|
|
|
if (enable) { |
|
|
|
|
if (label.length()) |
|
|
|
|
html = String(F("<label for=\"")) + name + String("\">") + label + String(F("</label>")); |
|
|
|
|
html += String(F("<select name=\"")) + name + String(F("\" id=\"")) + name + String("\">"); |
|
|
|
|
for (const String option : _options) |
|
|
|
|
html += String(F("<option value=\"")) + option + "\">" + option + String(F("</option>")); |
|
|
|
|
html += String(F("</select>")); |
|
|
|
|
if (label.length()) |
|
|
|
|
html = String(F("<label for=\"")) + name + String("\">") + label + String(F("</label>")); |
|
|
|
|
html += String(F("<select name=\"")) + name + String(F("\" id=\"")) + name + String("\">"); |
|
|
|
|
uint8_t n = 1; |
|
|
|
|
for (const String option : _options) { |
|
|
|
|
html += String(F("<option value=\"")) + option + "\""; |
|
|
|
|
if (n++ == selected) |
|
|
|
|
html += String(F(" selected")); |
|
|
|
|
html += ">" + option + String(F("</option>")); |
|
|
|
|
} |
|
|
|
|
html += String(F("</select>")); |
|
|
|
|
return html; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns current selected value in the radio same group |
|
|
|
|
*/ |
|
|
|
|
const String& AutoConnectSelectBasis::value(void) const { |
|
|
|
|
static const String _nullString = String(); |
|
|
|
|
return selected ? _options.at(selected - 1) : _nullString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate an HTML <input type=button> element. This element is used |
|
|
|
|
* for form submission. An 'onclick' attribute calls fixed JavaScript |
|
|
|
|