From 0a3e9e4b6357db73c9fb22cd3bfcd694aa61f2ae Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Fri, 19 Apr 2019 17:48:17 +0900 Subject: [PATCH 1/2] Add enable attribute --- src/AutoConnectElementBasis.h | 5 +- src/AutoConnectElementBasisImpl.h | 127 ++++++++++++++++-------------- 2 files changed, 73 insertions(+), 59 deletions(-) diff --git a/src/AutoConnectElementBasis.h b/src/AutoConnectElementBasis.h index 5eac66f..04f4bd8 100644 --- a/src/AutoConnectElementBasis.h +++ b/src/AutoConnectElementBasis.h @@ -46,11 +46,11 @@ typedef enum { */ class AutoConnectElementBasis { public: - explicit AutoConnectElementBasis(const char* name = "", const char* value = "") : name(String(name)), value(String(value)) { + explicit AutoConnectElementBasis(const char* name = "", const char* value = "") : name(String(name)), value(String(value)), enable(true) { _type = AC_Element; } virtual ~AutoConnectElementBasis() {} - virtual const String toHTML(void) const { return value; } + virtual const String toHTML(void) const { return enable ? value : String(""); } ACElement_t typeOf(void) const { return _type; } #ifndef AUTOCONNECT_USE_JSON template @@ -59,6 +59,7 @@ class AutoConnectElementBasis { String name; /**< Element name */ String value; /**< Element value */ + bool enable; /**< Enabling the element */ protected: ACElement_t _type; /**< Element type identifier */ diff --git a/src/AutoConnectElementBasisImpl.h b/src/AutoConnectElementBasisImpl.h index 2524017..56a5ca9 100644 --- a/src/AutoConnectElementBasisImpl.h +++ b/src/AutoConnectElementBasisImpl.h @@ -25,7 +25,7 @@ * @return An HTML string. */ const String AutoConnectButtonBasis::toHTML(void) const { - return String(F("")); + return enable ? String(F("")) : String(""); } /** @@ -37,14 +37,16 @@ const String AutoConnectButtonBasis::toHTML(void) const { * @return An HTML string. */ const String AutoConnectCheckboxBasis::toHTML(void) const { - String html; + String html = String(""); - html = String(F("