Skip to content

Commit 5934655

Browse files
committed
Update UI: Use json/info instead of xml.cpp
Alas the AI's attempt at dynamic content was flawed: the JS function was being removed by cdata.js in favor of a s.js call. Rather than patch up the old UI, convert to using the info struct for everything.
1 parent 0bdc328 commit 5934655

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

tools/cdata.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,6 @@ const char PAGE_dmxmap[] PROGMEM = R"=====()=====";
388388
name: "PAGE_update",
389389
method: "gzip",
390390
filter: "html-minify",
391-
mangle: (str) =>
392-
str
393-
.replace(
394-
/function GetV().*\<\/script\>/gms,
395-
"</script><script src=\"/settings/s.js?p=9\"></script>"
396-
)
397391
},
398392
{
399393
file: "welcome.htm",

wled00/data/update.htm

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222
fetch('/json/info')
2323
.then(response => response.json())
2424
.then(data => {
25-
if (data.release) {
26-
var releaseSpan = document.querySelector('.release-name');
27-
if (releaseSpan) {
28-
releaseSpan.textContent = data.release;
29-
}
25+
document.querySelector('.installed-version').textContent = `${data.brand} ${data.ver} (${data.vid})`;
26+
document.querySelector('.release-name').textContent = data.release;
27+
// TODO - assemble update URL
28+
// TODO - can this be done at build time?
29+
if (data.arch == "esp8266") {
30+
toggle('rev');
3031
}
3132
})
3233
.catch(error => {
3334
console.log('Could not fetch device info:', error);
3435
// Fallback to compiled-in value if API call fails
35-
var releaseSpan = document.querySelector('.release-name');
36-
if (releaseSpan && releaseSpan.textContent === 'Loading...') {
37-
releaseSpan.textContent = 'Unknown';
38-
}
36+
document.querySelector('.installed-version').textContent = 'Unknown';
37+
document.querySelector('.release-name').textContent = 'Unknown';
3938
});
4039
}
4140
</script>
@@ -47,7 +46,7 @@
4746
<body onload="GetV()">
4847
<h2>WLED Software Update</h2>
4948
<form method='POST' action='./update' id='upd' enctype='multipart/form-data' onsubmit="toggle('upd')">
50-
Installed version: <span class="sip">WLED ##VERSION##</span><br>
49+
Installed version: <span class="sip installed-version">Loading...</span><br>
5150
Release: <span class="sip release-name">Loading...</span><br>
5251
Download the latest binary: <a href="https://github.com/wled-dev/WLED/releases" target="_blank"
5352
style="vertical-align: text-bottom; display: inline-flex;">

wled00/xml.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,16 +671,6 @@ void getSettingsJS(byte subPage, Print& settingsScript)
671671
UsermodManager::appendConfigData(settingsScript);
672672
}
673673

674-
if (subPage == SUBPAGE_UPDATE) // update
675-
{
676-
char tmp_buf[128];
677-
fillWLEDVersion(tmp_buf,sizeof(tmp_buf));
678-
printSetClassElementHTML(settingsScript,PSTR("sip"),0,tmp_buf);
679-
#ifndef ARDUINO_ARCH_ESP32
680-
settingsScript.print(F("toggle('rev');")); // hide revert button on ESP8266
681-
#endif
682-
}
683-
684674
if (subPage == SUBPAGE_2D) // 2D matrices
685675
{
686676
printSetFormValue(settingsScript,PSTR("SOMP"),strip.isMatrix);

0 commit comments

Comments
 (0)