diff --git a/src/AutoConnectDefs.h b/src/AutoConnectDefs.h
index bde08d6..cfe56f7 100644
--- a/src/AutoConnectDefs.h
+++ b/src/AutoConnectDefs.h
@@ -11,7 +11,7 @@
#define _AUTOCONNECTDEFS_H_
// Uncomment the following AC_DEBUG to enable debug output.
-#define AC_DEBUG
+// #define AC_DEBUG
// Debug output destination can be defined externally with AC_DEBUG_PORT
#ifndef AC_DEBUG_PORT
diff --git a/src/AutoConnectElementBasis.h b/src/AutoConnectElementBasis.h
index 77ccb0c..d84b8f0 100644
--- a/src/AutoConnectElementBasis.h
+++ b/src/AutoConnectElementBasis.h
@@ -109,6 +109,7 @@ class AutoConnectCheckboxBasis : virtual public AutoConnectElementBasis {
String label; /**< A label for a subsequent input box */
bool checked; /**< The element should be pre-selected */
+ bool labelFirst; /**< Output label before the checkbox */
};
/**
diff --git a/src/AutoConnectElementBasisImpl.h b/src/AutoConnectElementBasisImpl.h
index ac0ac86..37ff19e 100644
--- a/src/AutoConnectElementBasisImpl.h
+++ b/src/AutoConnectElementBasisImpl.h
@@ -62,12 +62,14 @@ const String AutoConnectCheckboxBasis::toHTML(void) const {
String html = String("");
if (enable) {
- html = String(F("")) + label + String(F(""));
+ html += String(F("");
+ html += String(F(" id=\"")) + name + String(F("\">"));
+ if (!labelFirst && label.length())
+ html+=String(F(""));
html = AutoConnectElementBasis::posterior(html);
}
return html;
diff --git a/src/AutoConnectElementJson.h b/src/AutoConnectElementJson.h
index c3d8ff8..92acdc8 100644
--- a/src/AutoConnectElementJson.h
+++ b/src/AutoConnectElementJson.h
@@ -24,6 +24,7 @@
#define AUTOCONNECT_JSON_KEY_OPTION "option"
#define AUTOCONNECT_JSON_KEY_PATTERN "pattern"
#define AUTOCONNECT_JSON_KEY_PLACEHOLDER "placeholder"
+#define AUTOCONNECT_JSON_KEY_LABELFIRST "labelfirst"
#define AUTOCONNECT_JSON_KEY_POSTERIOR "posterior"
#define AUTOCONNECT_JSON_KEY_SELECTED "selected"
#define AUTOCONNECT_JSON_KEY_STORE "store"
@@ -162,11 +163,12 @@ class AutoConnectButtonJson : public AutoConnectElementJson, public AutoConnectB
*/
class AutoConnectCheckboxJson : public AutoConnectElementJson, public AutoConnectCheckboxBasis {
public:
- explicit AutoConnectCheckboxJson(const char* name = "", const char* value = "", const char* label = "", const bool checked = false, const ACPosterior_t post = AC_Tag_BR) {
+ explicit AutoConnectCheckboxJson(const char* name = "", const char* value = "", const char* label = "", const bool checked = false, const bool labelFirst = false, const ACPosterior_t post = AC_Tag_BR) {
AutoConnectCheckboxBasis::name = String(name);
AutoConnectCheckboxBasis::value = String(value);
AutoConnectCheckboxBasis::label = String(label);
AutoConnectCheckboxBasis::checked = checked;
+ AutoConnectCheckboxBasis::labelFirst = String(labelFirst);
AutoConnectCheckboxBasis::post = post;
_defaultPost = AC_Tag_BR;
}
diff --git a/src/AutoConnectElementJsonImpl.h b/src/AutoConnectElementJsonImpl.h
index 2e06cbc..d45d041 100644
--- a/src/AutoConnectElementJsonImpl.h
+++ b/src/AutoConnectElementJsonImpl.h
@@ -139,7 +139,7 @@ void AutoConnectButtonJson::serialize(JsonObject& json) {
*/
size_t AutoConnectCheckboxJson::getObjectSize(void) const {
size_t size = AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2);
- size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_CHECKED);
+ size += sizeof(AUTOCONNECT_JSON_KEY_LABEL) + label.length() + 1 + sizeof(AUTOCONNECT_JSON_KEY_CHECKED) + sizeof(AUTOCONNECT_JSON_KEY_LABELFIRST);
return size;
}
@@ -157,6 +157,8 @@ bool AutoConnectCheckboxJson::loadMember(const JsonObject& json) {
label = json[F(AUTOCONNECT_JSON_KEY_LABEL)].as();
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_CHECKED)))
checked = json[F(AUTOCONNECT_JSON_KEY_CHECKED)].as();
+ if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABELFIRST)))
+ labelFirst = json[F(AUTOCONNECT_JSON_KEY_LABELFIRST)].as();
return true;
}
return false;
@@ -173,6 +175,7 @@ void AutoConnectCheckboxJson::serialize(JsonObject& json) {
json[F(AUTOCONNECT_JSON_KEY_VALUE)] = value;
json[F(AUTOCONNECT_JSON_KEY_LABEL)] = label;
json[F(AUTOCONNECT_JSON_KEY_CHECKED)] = checked;
+ json[F(AUTOCONNECT_JSON_KEY_LABELFIRST)] = labelFirst;
}
/**