@@ -251,7 +251,7 @@ const char HTTP_HEAD_STYLE3[] PROGMEM =
251
251
252
252
" </head>"
253
253
" <body>"
254
- " <div style='background:#%06x;text-align:left;display:inline-block;color:#%06x;min-width:340px;'>" // COLOR_BACKGROUND, COLOR_TEXT
254
+ " <div style='background:#%06x;text-align:left;display:inline-block;color:#%06x;min-width:340px;position:relative; '>" // COLOR_BACKGROUND, COLOR_TEXT
255
255
#ifdef FIRMWARE_MINIMAL
256
256
#ifdef FIRMWARE_SAFEBOOT
257
257
" <span style='text-align:center;color:#%06x;'><h3>" D_SAFEBOOT " </h3></span>" // COLOR_TEXT_WARNING
@@ -445,6 +445,18 @@ const char HTTP_END[] PROGMEM =
445
445
const char HTTP_DEVICE_CONTROL[] PROGMEM = " <td style='width:%d%%'><button id='o%d' onclick='la(\" &o=%d\" );'>%s%s</button></td>" ; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp))
446
446
const char HTTP_DEVICE_STATE[] PROGMEM = " <td style='width:%d%%;text-align:center;font-weight:%s;font-size:%dpx'>%s</td>" ;
447
447
448
+ const char HTTP_STATUS_STICKER[] PROGMEM =
449
+ " <span style='"
450
+ " margin:2px;"
451
+ " cursor:default;"
452
+ " padding:1px 2px;"
453
+ " border-color:#%06x;border-radius:5px;border-style:solid;border-width:1px;"
454
+ " ' "
455
+ " %s" // optional 'title' attributes
456
+ " >"
457
+ " %s"
458
+ " </span>" ;
459
+
448
460
enum ButtonTitle {
449
461
BUTTON_RESTART, BUTTON_RESET_CONFIGURATION,
450
462
BUTTON_MAIN, BUTTON_CONFIGURATION, BUTTON_INFORMATION, BUTTON_FIRMWARE_UPGRADE, BUTTON_MANAGEMENT,
@@ -1151,6 +1163,36 @@ void WSContentStop(void) {
1151
1163
WSContentEnd ();
1152
1164
}
1153
1165
1166
+ #ifdef USE_WEB_STATUS_LINE
1167
+ /* -------------------------------------------------------------------------------------------*/
1168
+ // Display a Sticker in the Status bar (upper right) with a name (MQTT, TlS, VPN)
1169
+ // and an optional tooltip text to indicate the duration of the connection (or -1 if none)
1170
+ //
1171
+ // Convert seconds to a string representing days, hours or minutes.
1172
+ // The string will contain the most coarse time only, rounded down (61m == 01h, 01h37m == 01h).
1173
+ void WSContentStatusSticker (const char *msg, int32_t seconds)
1174
+ {
1175
+ char title_attr[64 ] = " " ;
1176
+
1177
+ if (seconds > 0 ) {
1178
+ static const uint32_t conversions[4 ] = {24 * 3600 , 3600 , 60 , 1 };
1179
+ static const char units[4 ] = { ' d' , ' h' , ' m' , ' s' }; // day, hour, minute
1180
+
1181
+ char unit;
1182
+ int32_t time_unit = seconds;
1183
+ for (uint32_t i = 0 ; i < 4 ; ++i) {
1184
+ unit = units[i];
1185
+ if (time_unit >= conversions[i]) { // always pass even if 00m
1186
+ time_unit = seconds / conversions[i];
1187
+ break ;
1188
+ }
1189
+ }
1190
+ ext_snprintf_P (title_attr, sizeof (title_attr), PSTR (" title='Connected for %i%c'" ), time_unit, unit);
1191
+ }
1192
+ WSContentSend_P (HTTP_STATUS_STICKER, 0xAAAAAA , title_attr, msg);
1193
+ }
1194
+ #endif // USE_WEB_STATUS_LINE
1195
+
1154
1196
/* ********************************************************************************************/
1155
1197
1156
1198
void WebRestart (uint32_t type) {
@@ -1884,6 +1926,13 @@ bool HandleRootStatusRefresh(void) {
1884
1926
WSContentSend_P (PSTR (" \" >" ));
1885
1927
}
1886
1928
1929
+ #ifdef USE_WEB_STATUS_LINE
1930
+ // create a DIV for the upper status bar, positioned right-justified
1931
+ WSContentSend_P (PSTR (" <div style='font-size:9px;font-weight:bold;text-align:right;position:absolute;top:0;right:0;display:inline-flex;'>" ));
1932
+ XsnsXdrvCall (FUNC_WEB_STATUS);
1933
+ WSContentSend_P (PSTR (" </div>" ));
1934
+ #endif // USE_WEB_STATUS_LINE
1935
+
1887
1936
WSContentSend_P (PSTR (" {t}" )); // <table style='width:100%'>
1888
1937
WSContentSeparator (3 ); // Reset seperator to ignore previous outputs
1889
1938
if (Settings->web_time_end ) {
0 commit comments