mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[UI] Add conditional compilation to Tooltip feature
This commit is contained in:
@@ -143,6 +143,9 @@ To create/register a plugin, you have to :
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_TOOLTIPS
|
||||
#define ENABLE_TOOLTIPS
|
||||
#endif // ENABLE_TOOLTIPS
|
||||
|
||||
/******************************************************************************\
|
||||
* Available options **********************************************************
|
||||
@@ -1563,6 +1566,9 @@ To create/register a plugin, you have to :
|
||||
#ifdef USE_RTTTL
|
||||
#undef USE_RTTTL
|
||||
#endif
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
#undef ENABLE_TOOLTIPS
|
||||
#endif
|
||||
#ifdef USES_BLYNK
|
||||
#undef USES_BLYNK
|
||||
#endif
|
||||
|
||||
+140
-47
@@ -33,23 +33,34 @@ void addSelector(const String& id,
|
||||
addSelector(id, optionCount, options, indices, attr, selectedIndex, reloadonchange, enabled, F("wide"));
|
||||
}
|
||||
|
||||
void addSelector(const String& id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
boolean reloadonchange,
|
||||
bool enabled,
|
||||
const String& classname,
|
||||
const String& title)
|
||||
void addSelector(const String & id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
boolean reloadonchange,
|
||||
bool enabled,
|
||||
const String& classname
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
// FIXME TD-er Change boolean to disabled
|
||||
if (reloadonchange)
|
||||
{
|
||||
addSelector_Head_reloadOnChange(id, classname, !enabled, title);
|
||||
addSelector_Head_reloadOnChange(id, classname, !enabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
} else {
|
||||
do_addSelector_Head(id, classname, F(""), !enabled, title);
|
||||
do_addSelector_Head(id, classname, F(""), !enabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
addSelector_options(optionCount, options, indices, attr, selectedIndex);
|
||||
addSelector_Foot();
|
||||
@@ -78,30 +89,58 @@ void addSelector_options(int optionCount, const String options[], const int indi
|
||||
}
|
||||
|
||||
void addSelector_Head(const String& id) {
|
||||
do_addSelector_Head(id, F("wide"), F(""), false, F(""));
|
||||
do_addSelector_Head(id, F("wide"), F(""), false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, F("")
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addSelector_Head_reloadOnChange(const String& id) {
|
||||
addSelector_Head_reloadOnChange(id, F("wide"), false);
|
||||
}
|
||||
|
||||
void addSelector_Head_reloadOnChange(const String& id, const String& classname, bool disabled, const String& title) {
|
||||
do_addSelector_Head(id, classname, F("return dept_onchange(frmselect)"), disabled, title);
|
||||
void addSelector_Head_reloadOnChange(const String& id, const String& classname, bool disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
) {
|
||||
do_addSelector_Head(id, classname, F("return dept_onchange(frmselect)"), disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addSelector_Head_reloadOnChange(const String& id, const String& classname, const String& onChangeCall, bool disabled, const String& title) {
|
||||
do_addSelector_Head(id, classname, onChangeCall, disabled, title);
|
||||
void addSelector_Head_reloadOnChange(const String& id, const String& classname, const String& onChangeCall, bool disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif
|
||||
) {
|
||||
do_addSelector_Head(id, classname, onChangeCall, disabled
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void do_addSelector_Head(const String& id, const String& classname, const String& onChangeCall, const bool& disabled, const String& title)
|
||||
void do_addSelector_Head(const String& id, const String& classname, const String& onChangeCall, const bool& disabled
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addHtml(F("<select "));
|
||||
addHtmlAttribute(F("class"), classname);
|
||||
addHtmlAttribute(F("name"), id);
|
||||
addHtmlAttribute(F("id"), id);
|
||||
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
addHtmlAttribute(F("title"), title);
|
||||
}
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (disabled) {
|
||||
addDisabled();
|
||||
@@ -259,7 +298,11 @@ void addFormSubHeader(const String& header)
|
||||
// ********************************************************************************
|
||||
// Add a checkbox
|
||||
// ********************************************************************************
|
||||
void addCheckBox(const String& id, boolean checked, bool disabled, const String& title)
|
||||
void addCheckBox(const String& id, boolean checked, bool disabled
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addHtml(F("<label class='container'> "));
|
||||
addHtml(F("<input "));
|
||||
@@ -276,24 +319,39 @@ void addCheckBox(const String& id, boolean checked, bool disabled, const String&
|
||||
|
||||
if (disabled) { addDisabled(); }
|
||||
addHtml('\'');
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
addHtmlAttribute(F("title"), title);
|
||||
}
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
addHtml(F("></span></label>"));
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// Add a numeric box
|
||||
// ********************************************************************************
|
||||
void addNumericBox(const String& id, int value, int min, int max, const String& classname, const String& title)
|
||||
void addNumericBox(const String& id, int value, int min, int max
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, const String& classname, const String& title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addHtml(F("<input "));
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
addHtmlAttribute(F("class"), classname);
|
||||
# else // ifdef ENABLE_TOOLTIPS
|
||||
addHtmlAttribute(F("class"), F("widenumber"));
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
addHtmlAttribute(F("type"), F("number"));
|
||||
addHtmlAttribute(F("name"), id);
|
||||
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
addHtmlAttribute(F("title"), title);
|
||||
}
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (value < min) {
|
||||
value = min;
|
||||
@@ -316,12 +374,19 @@ void addNumericBox(const String& id, int value, int min, int max, const String&
|
||||
addHtml('>');
|
||||
}
|
||||
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
void addNumericBox(const String& id, int value, int min, int max)
|
||||
{
|
||||
addNumericBox(id, value, min, max, F("widenumber"));
|
||||
}
|
||||
|
||||
void addFloatNumberBox(const String& id, float value, float min, float max, byte nrDecimals, float stepsize, const String& title)
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
|
||||
void addFloatNumberBox(const String& id, float value, float min, float max, byte nrDecimals, float stepsize
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
String html;
|
||||
|
||||
@@ -335,8 +400,10 @@ void addFloatNumberBox(const String& id, float value, float min, float max, byte
|
||||
html += F(" max=");
|
||||
html += String(max, nrDecimals);
|
||||
html += F(" step=");
|
||||
|
||||
if (stepsize <= 0.0f) {
|
||||
html += F("0.");
|
||||
|
||||
for (byte i = 1; i < nrDecimals; ++i) {
|
||||
html += '0';
|
||||
}
|
||||
@@ -347,11 +414,15 @@ void addFloatNumberBox(const String& id, float value, float min, float max, byte
|
||||
|
||||
html += F(" style='width:7em;' value=");
|
||||
html += String(value, nrDecimals);
|
||||
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
html += F("title='");
|
||||
html += title;
|
||||
html += F("' ");
|
||||
}
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
html += '>';
|
||||
|
||||
addHtml(html);
|
||||
@@ -364,14 +435,17 @@ void addTextBox(const String& id, const String& value, int maxlength, bool read
|
||||
addTextBox(id, value, maxlength, readonly, required, pattern, F("wide"));
|
||||
}
|
||||
|
||||
void addTextBox(const String& id,
|
||||
const String& value,
|
||||
int maxlength,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String& pattern,
|
||||
const String& classname,
|
||||
const String& title)
|
||||
void addTextBox(const String & id,
|
||||
const String & value,
|
||||
int maxlength,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String & pattern,
|
||||
const String& classname
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addHtml(F("<input "));
|
||||
addHtmlAttribute(F("class"), classname);
|
||||
@@ -391,16 +465,30 @@ void addTextBox(const String& id,
|
||||
if (pattern.length() > 0) {
|
||||
addHtmlAttribute(F("pattern"), pattern);
|
||||
}
|
||||
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
addHtmlAttribute(F("title"), title);
|
||||
addHtmlAttribute(F("title"), title);
|
||||
}
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
addHtml('>');
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// Add Textarea
|
||||
// ********************************************************************************
|
||||
void addTextArea(const String& id, const String& value, int maxlength, int rows, int columns, bool readonly, bool required, const String& title)
|
||||
void addTextArea(const String & id,
|
||||
const String & value,
|
||||
int maxlength,
|
||||
int rows,
|
||||
int columns,
|
||||
bool readonly,
|
||||
bool required
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addHtml(F("<textarea "));
|
||||
addHtmlAttribute(F("class"), F("wide"));
|
||||
@@ -417,9 +505,13 @@ void addTextArea(const String& id, const String& value, int maxlength, int rows,
|
||||
if (required) {
|
||||
addHtml(F(" required "));
|
||||
}
|
||||
|
||||
# ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
addHtmlAttribute(F("title"), title);
|
||||
addHtmlAttribute(F("title"), title);
|
||||
}
|
||||
# endif // ifdef ENABLE_TOOLTIPS
|
||||
addHtml('>');
|
||||
addHtml(value);
|
||||
addHtml(F("</textarea>"));
|
||||
@@ -432,13 +524,14 @@ void addTextArea(const String& id, const String& value, int maxlength, int rows,
|
||||
// adds a Help Button with points to the the given Wiki Subpage
|
||||
// If url starts with "RTD", it will be considered as a Read-the-docs link
|
||||
void addHelpButton(const String& url) {
|
||||
#ifndef WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
|
||||
# ifndef WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
|
||||
|
||||
if (url.startsWith("RTD")) {
|
||||
addRTDHelpButton(url.substring(3));
|
||||
} else {
|
||||
addHelpButton(url, false);
|
||||
}
|
||||
#endif
|
||||
# endif // ifndef WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
|
||||
}
|
||||
|
||||
void addRTDHelpButton(const String& url)
|
||||
@@ -448,12 +541,12 @@ void addRTDHelpButton(const String& url)
|
||||
|
||||
void addHelpButton(const String& url, bool isRTD)
|
||||
{
|
||||
#ifndef WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
|
||||
# ifndef WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
|
||||
addHtmlLink(
|
||||
F("button help"),
|
||||
makeDocLink(url, isRTD),
|
||||
isRTD ? F("ℹ") : F("❔"));
|
||||
#endif
|
||||
# endif // ifndef WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
|
||||
}
|
||||
|
||||
void addRTDPluginButton(pluginID_t taskDeviceNumber) {
|
||||
@@ -496,11 +589,11 @@ String makeDocLink(const String& url, bool isRTD) {
|
||||
|
||||
void addPinSelect(boolean forI2C, const String& id, int choice)
|
||||
{
|
||||
#ifdef ESP32
|
||||
# define NR_ITEMS_PIN_DROPDOWN 35 // 34 GPIO + 1
|
||||
#else // ifdef ESP32
|
||||
# define NR_ITEMS_PIN_DROPDOWN 14 // 13 GPIO + 1
|
||||
#endif // ifdef ESP32
|
||||
# ifdef ESP32
|
||||
# define NR_ITEMS_PIN_DROPDOWN 35 // 34 GPIO + 1
|
||||
# else // ifdef ESP32
|
||||
# define NR_ITEMS_PIN_DROPDOWN 14 // 13 GPIO + 1
|
||||
# endif // ifdef ESP32
|
||||
|
||||
String *gpio_labels = new String[NR_ITEMS_PIN_DROPDOWN];
|
||||
int *gpio_numbers = new int[NR_ITEMS_PIN_DROPDOWN];
|
||||
@@ -523,10 +616,10 @@ void addPinSelect(boolean forI2C, const String& id, int choice)
|
||||
renderHTMLForPinSelect(gpio_labels, gpio_numbers, forI2C, id, choice, NR_ITEMS_PIN_DROPDOWN);
|
||||
delete[] gpio_numbers;
|
||||
delete[] gpio_labels;
|
||||
#undef NR_ITEMS_PIN_DROPDOWN
|
||||
# undef NR_ITEMS_PIN_DROPDOWN
|
||||
}
|
||||
|
||||
#ifdef ESP32
|
||||
# ifdef ESP32
|
||||
void addADC_PinSelect(bool touchOnly, const String& id, int choice)
|
||||
{
|
||||
int NR_ITEMS_PIN_DROPDOWN = touchOnly ? 10 : 19;
|
||||
@@ -572,7 +665,7 @@ void addADC_PinSelect(bool touchOnly, const String& id, int choice)
|
||||
delete[] gpio_labels;
|
||||
}
|
||||
|
||||
#endif // ifdef ESP32
|
||||
# endif // ifdef ESP32
|
||||
|
||||
|
||||
// ********************************************************************************
|
||||
@@ -596,7 +689,7 @@ void renderHTMLForPinSelect(String options[], int optionValues[], boolean forI2C
|
||||
}
|
||||
|
||||
if (Settings.InitSPI != 0) {
|
||||
#ifdef ESP32
|
||||
# ifdef ESP32
|
||||
|
||||
switch (Settings.InitSPI)
|
||||
{
|
||||
@@ -607,9 +700,9 @@ void renderHTMLForPinSelect(String options[], int optionValues[], boolean forI2C
|
||||
disabled = (optionValues[x] == 14 || optionValues[x] == 12 || optionValues[x] == 13);
|
||||
break;
|
||||
}
|
||||
#else // #ifdef ESP32
|
||||
# else // #ifdef ESP32
|
||||
disabled = (optionValues[x] == 14 || optionValues[x] == 12 || optionValues[x] == 13);
|
||||
#endif // ifdef ESP32
|
||||
# endif // ifdef ESP32
|
||||
}
|
||||
}
|
||||
addSelector_Item(options[x],
|
||||
|
||||
+51
-16
@@ -31,8 +31,12 @@ void addSelector(const String& id,
|
||||
int selectedIndex,
|
||||
boolean reloadonchange,
|
||||
bool enabled,
|
||||
const String& classname,
|
||||
const String& title = "");
|
||||
const String& classname
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addSelector_options(int optionCount,
|
||||
const String options[],
|
||||
@@ -46,20 +50,32 @@ void addSelector_Head_reloadOnChange(const String& id);
|
||||
|
||||
void addSelector_Head_reloadOnChange(const String& id,
|
||||
const String& classname,
|
||||
bool disabled,
|
||||
const String& title = "");
|
||||
bool disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addSelector_Head_reloadOnChange(const String& id,
|
||||
const String& classname,
|
||||
const String& onChangeCall,
|
||||
bool disabled,
|
||||
const String& title = "");
|
||||
bool disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void do_addSelector_Head(const String& id,
|
||||
const String& classname,
|
||||
const String& onChangeCall,
|
||||
const bool & disabled,
|
||||
const String& title = "");
|
||||
const bool& disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addSelector_Item(const String& option,
|
||||
int index,
|
||||
@@ -110,18 +126,25 @@ void addFormSubHeader(const String& header);
|
||||
// ********************************************************************************
|
||||
void addCheckBox(const String& id,
|
||||
boolean checked,
|
||||
bool disabled = false,
|
||||
const String& title = "");
|
||||
bool disabled = false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add a numeric box
|
||||
// ********************************************************************************
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
void addNumericBox(const String& id,
|
||||
int value,
|
||||
int min,
|
||||
int max,
|
||||
const String& classname,
|
||||
const String& title = "");
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
|
||||
void addNumericBox(const String& id,
|
||||
int value,
|
||||
int min,
|
||||
@@ -132,8 +155,12 @@ void addFloatNumberBox(const String& id,
|
||||
float min,
|
||||
float max,
|
||||
byte nrDecimals = 6,
|
||||
float stepsize = 0.0f,
|
||||
const String& title = "");
|
||||
float stepsize = 0.0f
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add Textbox
|
||||
@@ -150,8 +177,12 @@ void addTextBox(const String& id,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String& pattern,
|
||||
const String& classname,
|
||||
const String& title = "");
|
||||
const String& classname
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add Textarea
|
||||
@@ -162,8 +193,12 @@ void addTextArea(const String& id,
|
||||
int rows,
|
||||
int columns,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String& title = "");
|
||||
bool required
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add Help Buttons
|
||||
|
||||
@@ -44,18 +44,42 @@ void addFormNote(const String& text, const String& id)
|
||||
// Add a checkbox Form
|
||||
// ********************************************************************************
|
||||
|
||||
void addFormCheckBox_disabled(const String& label, const String& id, boolean checked, const String& title) {
|
||||
addFormCheckBox(label, id, checked, true, title);
|
||||
void addFormCheckBox_disabled(const String& label, const String& id, boolean checked
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
) {
|
||||
addFormCheckBox(label, id, checked, true
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormCheckBox(const String& label, const String& id, boolean checked, bool disabled, const String& title)
|
||||
void addFormCheckBox(const String& label, const String& id, boolean checked, bool disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
addCheckBox(id, checked, disabled, title);
|
||||
addCheckBox(id, checked, disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormCheckBox(LabelType::Enum label, boolean checked, bool disabled, const String& title) {
|
||||
addFormCheckBox(getLabel(label), getInternalLabel(label), checked, disabled, title);
|
||||
void addFormCheckBox(LabelType::Enum label, boolean checked, bool disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
) {
|
||||
addFormCheckBox(getLabel(label), getInternalLabel(label), checked, disabled
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormCheckBox_disabled(LabelType::Enum label, boolean checked) {
|
||||
@@ -65,25 +89,64 @@ void addFormCheckBox_disabled(LabelType::Enum label, boolean checked) {
|
||||
// ********************************************************************************
|
||||
// Add a Numeric Box form
|
||||
// ********************************************************************************
|
||||
void addFormNumericBox(LabelType::Enum label, int value, int min, int max, const String& title)
|
||||
void addFormNumericBox(LabelType::Enum label, int value, int min, int max
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addFormNumericBox(getLabel(label), getInternalLabel(label), value, min, max, title);
|
||||
addFormNumericBox(getLabel(label), getInternalLabel(label), value, min, max
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormNumericBox(const String& label, const String& id, int value, int min, int max, const String& title)
|
||||
void addFormNumericBox(const String& label, const String& id, int value, int min, int max
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
addNumericBox(id, value, min, max, F("widenumber"), title);
|
||||
addNumericBox(id, value, min, max
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, F("widenumber"), title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, byte nrDecimals, float stepsize, const String& title) {
|
||||
addFormFloatNumberBox(getLabel(label), getInternalLabel(label), value, min, max, nrDecimals, stepsize, title);
|
||||
void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, byte nrDecimals, float stepsize
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
) {
|
||||
addFormFloatNumberBox(getLabel(label), getInternalLabel(label), value, min, max, nrDecimals, stepsize
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, byte nrDecimals, float stepsize, const String& title)
|
||||
void addFormFloatNumberBox(const String& label,
|
||||
const String& id,
|
||||
float value,
|
||||
float min,
|
||||
float max,
|
||||
byte nrDecimals,
|
||||
float stepsize
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
addFloatNumberBox(id, value, min, max, nrDecimals, stepsize, title);
|
||||
addFloatNumberBox(id, value, min, max, nrDecimals, stepsize
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
@@ -98,38 +161,56 @@ void addTaskSelectBox(const String& label, const String& id, taskIndex_t choice)
|
||||
// ********************************************************************************
|
||||
// Add a Text Box form
|
||||
// ********************************************************************************
|
||||
void addFormTextBox(const String& label,
|
||||
const String& id,
|
||||
const String& value,
|
||||
int maxlength,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String& pattern,
|
||||
const String& title)
|
||||
void addFormTextBox(const String & label,
|
||||
const String & id,
|
||||
const String & value,
|
||||
int maxlength,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String& pattern
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
addTextBox(id, value, maxlength, readonly, required, pattern, F("wide"), title);
|
||||
addTextBox(id, value, maxlength, readonly, required, pattern, F("wide")
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormTextArea(const String& label,
|
||||
const String& id,
|
||||
const String& value,
|
||||
int maxlength,
|
||||
int rows,
|
||||
int columns,
|
||||
bool readonly,
|
||||
bool required,
|
||||
const String& title)
|
||||
void addFormTextArea(const String & label,
|
||||
const String & id,
|
||||
const String & value,
|
||||
int maxlength,
|
||||
int rows,
|
||||
int columns,
|
||||
bool readonly,
|
||||
bool required
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
addTextArea(id, value, maxlength, rows, columns, readonly, required, title);
|
||||
addTextArea(id, value, maxlength, rows, columns, readonly, required
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// Add a Password Box form
|
||||
// ********************************************************************************
|
||||
|
||||
void addFormPasswordBox(const String& label, const String& id, const String& password, int maxlength, const String& title)
|
||||
void addFormPasswordBox(const String& label, const String& id, const String& password, int maxlength
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
|
||||
@@ -138,10 +219,14 @@ void addFormPasswordBox(const String& label, const String& id, const String& pas
|
||||
addHtmlAttribute(F("type"), F("password"));
|
||||
addHtmlAttribute(F("name"), id);
|
||||
addHtmlAttribute(F("maxlength"), maxlength);
|
||||
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
|
||||
if (title.length() > 0) {
|
||||
addHtmlAttribute(F("title"), title);
|
||||
addHtmlAttribute(F("title"), title);
|
||||
}
|
||||
addHtmlAttribute(F("value"), (password.length() == 0) ? F("") : F("*****"));
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
addHtmlAttribute(F("value"), (password.length() == 0) ? F("") : F("*****"));
|
||||
addHtml('>');
|
||||
}
|
||||
|
||||
@@ -194,10 +279,18 @@ void addFormPinSelectI2C(const String& label, const String& id, int choice)
|
||||
addPinSelect(true, id, choice);
|
||||
}
|
||||
|
||||
void addFormSelectorI2C(const String& id, int addressCount, const int addresses[], int selectedIndex, const String& title)
|
||||
void addFormSelectorI2C(const String& id, int addressCount, const int addresses[], int selectedIndex
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(F("I2C Address"), id);
|
||||
do_addSelector_Head(id, "", "", false, title);
|
||||
do_addSelector_Head(id, "", "", false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
for (byte x = 0; x < addressCount; x++)
|
||||
{
|
||||
@@ -211,15 +304,22 @@ void addFormSelectorI2C(const String& id, int addressCount, const int addresses[
|
||||
addSelector_Foot();
|
||||
}
|
||||
|
||||
void addFormSelector(const String& label,
|
||||
const String& id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
int selectedIndex,
|
||||
const String& title)
|
||||
void addFormSelector(const String & label,
|
||||
const String & id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
int selectedIndex
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addFormSelector(label, id, optionCount, options, indices, NULL, selectedIndex, false, title);
|
||||
addFormSelector(label, id, optionCount, options, indices, NULL, selectedIndex, false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormSelector(const String& label,
|
||||
@@ -233,32 +333,46 @@ void addFormSelector(const String& label,
|
||||
addFormSelector(label, id, optionCount, options, indices, NULL, selectedIndex, reloadonchange);
|
||||
}
|
||||
|
||||
void addFormSelector(const String& label,
|
||||
const String& id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
boolean reloadonchange,
|
||||
const String& title)
|
||||
void addFormSelector(const String & label,
|
||||
const String & id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
boolean reloadonchange
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
addSelector(id, optionCount, options, indices, attr, selectedIndex, reloadonchange, true, F("wide"), title);
|
||||
addSelector(id, optionCount, options, indices, attr, selectedIndex, reloadonchange, true, F("wide")
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
}
|
||||
|
||||
void addFormSelector_script(const String& label,
|
||||
const String& id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
const String& onChangeCall,
|
||||
const String& title)
|
||||
void addFormSelector_script(const String & label,
|
||||
const String & id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
const String& onChangeCall
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, const String& title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
do_addSelector_Head(id, "", onChangeCall, false, title);
|
||||
do_addSelector_Head(id, "", onChangeCall, false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, title
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
addSelector_options(optionCount, options, indices, attr, selectedIndex);
|
||||
addSelector_Foot();
|
||||
}
|
||||
@@ -341,7 +455,8 @@ int getFormItemInt(const String& key, int defaultValue) {
|
||||
|
||||
bool getCheckWebserverArg_int(const String& key, int& value) {
|
||||
const String valueStr = web_server.arg(key);
|
||||
if (valueStr.length() == 0) return false;
|
||||
|
||||
if (valueStr.length() == 0) { return false; }
|
||||
return validIntFromString(valueStr, value);
|
||||
}
|
||||
|
||||
@@ -380,7 +495,8 @@ int getFormItemInt(const String& id)
|
||||
float getFormItemFloat(const String& id)
|
||||
{
|
||||
const String val = web_server.arg(id);
|
||||
float res = 0.0;
|
||||
float res = 0.0;
|
||||
|
||||
if (val.length() > 0) {
|
||||
validFloatFromString(val, res);
|
||||
}
|
||||
|
||||
@@ -28,19 +28,31 @@ void addFormNote(const String& text,
|
||||
|
||||
void addFormCheckBox_disabled(const String& label,
|
||||
const String& id,
|
||||
boolean checked,
|
||||
const String& title = "");
|
||||
boolean checked
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addFormCheckBox(const String& label,
|
||||
const String& id,
|
||||
boolean checked,
|
||||
bool disabled = false,
|
||||
const String& title = "");
|
||||
bool disabled = false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addFormCheckBox(LabelType::Enum label,
|
||||
boolean checked,
|
||||
bool disabled = false,
|
||||
const String & title = "");
|
||||
bool disabled = false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String & title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addFormCheckBox_disabled(LabelType::Enum label,
|
||||
boolean checked);
|
||||
@@ -50,24 +62,36 @@ void addFormCheckBox_disabled(LabelType::Enum label,
|
||||
// ********************************************************************************
|
||||
void addFormNumericBox(LabelType::Enum label,
|
||||
int value,
|
||||
int min = INT_MIN,
|
||||
int max = INT_MAX,
|
||||
const String & title = "");
|
||||
int min = INT_MIN,
|
||||
int max = INT_MAX
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String & title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addFormNumericBox(const String& label,
|
||||
const String& id,
|
||||
int value,
|
||||
int min = INT_MIN,
|
||||
int max = INT_MAX,
|
||||
const String& title = "");
|
||||
int min = INT_MIN,
|
||||
int max = INT_MAX
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addFormFloatNumberBox(LabelType::Enum label,
|
||||
float value,
|
||||
float min,
|
||||
float max,
|
||||
byte nrDecimals = 6,
|
||||
float stepsize = 0.0f,
|
||||
const String & title = "");
|
||||
float stepsize = 0.0f
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
void addFormFloatNumberBox(const String& label,
|
||||
const String& id,
|
||||
@@ -75,8 +99,12 @@ void addFormFloatNumberBox(const String& label,
|
||||
float min,
|
||||
float max,
|
||||
byte nrDecimals = 6,
|
||||
float stepsize = 0.0f,
|
||||
const String& title = "");
|
||||
float stepsize = 0.0f
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add a task selector form
|
||||
@@ -94,8 +122,12 @@ void addFormTextBox(const String& label,
|
||||
int maxlength,
|
||||
bool readonly = false,
|
||||
bool required = false,
|
||||
const String& pattern = "",
|
||||
const String& title = "");
|
||||
const String& pattern = ""
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
|
||||
void addFormTextArea(const String& label,
|
||||
@@ -105,8 +137,12 @@ void addFormTextArea(const String& label,
|
||||
int rows,
|
||||
int columns,
|
||||
bool readonly = false,
|
||||
bool required = false,
|
||||
const String& title = "");
|
||||
bool required = false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add a Password Box form
|
||||
@@ -115,8 +151,12 @@ void addFormTextArea(const String& label,
|
||||
void addFormPasswordBox(const String& label,
|
||||
const String& id,
|
||||
const String& password,
|
||||
int maxlength,
|
||||
const String& title = "");
|
||||
int maxlength
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
);
|
||||
|
||||
bool getFormPassword(const String& id,
|
||||
String & password);
|
||||
@@ -151,16 +191,24 @@ void addFormPinSelectI2C(const String& label,
|
||||
void addFormSelectorI2C(const String& id,
|
||||
int addressCount,
|
||||
const int addresses[],
|
||||
int selectedIndex,
|
||||
const String& title = "");
|
||||
int selectedIndex
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif
|
||||
);
|
||||
|
||||
void addFormSelector(const String& label,
|
||||
const String& id,
|
||||
int optionCount,
|
||||
const String options[],
|
||||
const int indices[],
|
||||
int selectedIndex,
|
||||
const String& title = "");
|
||||
int selectedIndex
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif
|
||||
);
|
||||
|
||||
void addFormSelector(const String& label,
|
||||
const String& id,
|
||||
@@ -177,8 +225,12 @@ void addFormSelector(const String& label,
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
boolean reloadonchange,
|
||||
const String& title = "");
|
||||
boolean reloadonchange
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif
|
||||
);
|
||||
|
||||
void addFormSelector_script(const String& label,
|
||||
const String& id,
|
||||
@@ -187,8 +239,12 @@ void addFormSelector_script(const String& label,
|
||||
const int indices[],
|
||||
const String attr[],
|
||||
int selectedIndex,
|
||||
const String& onChangeCall,
|
||||
const String& title = "");
|
||||
const String& onChangeCall
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
,
|
||||
const String& title = ""
|
||||
#endif
|
||||
);
|
||||
|
||||
// ********************************************************************************
|
||||
// Add a GPIO pin select dropdown list
|
||||
|
||||
Reference in New Issue
Block a user