[WebUI] Cleanup code formatting task values

This commit is contained in:
TD-er committed 2026-09-06 16:36:11 +02:00
1 parent e83c23e8b2
commit 24884cdc7f
5 files changed
+19 -16

No files matched your search

+14 -11
View File
@@ -129,10 +129,10 @@ void TaskValuesWriterHelper::writeCustom(
#endif
}
valueNumber = varNr;
_isLast = isLast;
valName = label;
value = val;
attribute = attr;
_isLast = isLast;
valName = label;
value = val;
attribute = attr;
write();
}
@@ -178,7 +178,7 @@ void TaskValuesWriterHelper::writeDerivedTaskValues()
if (!it->second.isEmpty()) {
valueNumber = varNr;
value = it->second;
value = it->second;
// FIXME TD-er: Why these differences between JSON and Web?
if (event->kvWriter)
@@ -228,14 +228,14 @@ void TaskValuesWriterHelper::pluginWebformShowValue()
{
if (!validDeviceIndex(deviceIndex)) { return; }
if ((valueNumber == 0) && _monoSpaced) {
if ((valueNumber == 0) && _preformatted) {
addHtml(F("<pre>")); // To keep spaces etc. in the shown output
}
if (valueNumber > 0) {
addHtmlDiv(F("div_br"));
}
String value_tmp(_monoSpaced ? value : stripQuotes(value));
String value_tmp(_preformatted ? value : stripQuotes(value));
#if FEATURE_STRING_VARIABLES
@@ -246,12 +246,15 @@ void TaskValuesWriterHelper::pluginWebformShowValue()
#endif // if FEATURE_STRING_VARIABLES
addHtmlDiv(F("div_l"), valName, format_ID(ID_type::ValueName), attribute);
addHtmlDiv(F("div_r"), value_tmp, format_ID(ID_type::Value));
if (_isLast && _monoSpaced) {
if (!value_tmp.isEmpty() || !_preformatted) {
addHtmlDiv(F("div_r"), value_tmp, format_ID(ID_type::Value));
}
if (_isLast && _preformatted) {
addHtml(F("</pre>")); // To keep spaces etc. in the shown output
_monoSpaced = false;
_isLast = false;
_preformatted = false;
_isLast = false;
}
}
+2 -2
View File
@@ -34,7 +34,7 @@ struct TaskValuesWriterHelper {
void setWriteRegularTaskValuesFirst() { _writeRegularTaskValuesFirst = true; }
void setMonoSpaced() { _monoSpaced = true; }
void setPreformatted() { _preformatted = true; }
void write();
@@ -85,7 +85,7 @@ public:
deviceIndex_t deviceIndex = INVALID_DEVICE_INDEX;
bool _writeRegularTaskValuesFirst{};
bool _monoSpaced{};
bool _preformatted{};
bool _isLast{};
};
+1 -1
View File
@@ -336,7 +336,7 @@ bool P023_data_struct::web_show_values(struct EventStruct *event) {
constexpr uint8_t nrLines = NR_ELEMENTS(currentLines);
for (uint8_t i = 0; i < nrLines; ++i) {
const bool isLast = i == (nrLines - 1);
data.setMonoSpaced();
data.setPreformatted();
data.writeCustom(i, currentLines[i], EMPTY_STRING, F("style='font-size:75%;'"), isLast);
}
return true; // Don't show anything else
+1 -1
View File
@@ -2554,7 +2554,7 @@ bool P036_data_struct::web_show_values(struct EventStruct *event) {
const uint8_t nrLines = ScrollingPages.linesPerFrameDef;
for (uint8_t i = 0; i < nrLines; ++i) {
const bool isLast = i == (nrLines - 1);
data.setMonoSpaced();
data.setPreformatted();
data.writeCustom(i, currentLines[i], EMPTY_STRING, F("style='font-size:75%;'"), isLast);
}
return true; // Don't show anything else
+1 -1
View File
@@ -619,7 +619,7 @@ void handle_json_stream_task_value_data(TaskValuesWriterHelper*data)
nrDecimals = 255;
}
const KeyValueStruct::Format format = data->_monoSpaced
const KeyValueStruct::Format format = data->_preformatted
? KeyValueStruct::Format::PreFormatted
: KeyValueStruct::Format::Default;