Fix for empty WS reponse.

Scroll selected preset into view.
This commit is contained in:
Blaz Kristan 2021-03-20 13:11:10 +01:00
parent bfab2d405b
commit e539a36ae7
3 changed files with 835 additions and 826 deletions

View File

@ -215,8 +215,8 @@ function onLoad()
var mySocket = new WebSocket('ws://'+(loc?locip:window.location.hostname)+'/ws'); var mySocket = new WebSocket('ws://'+(loc?locip:window.location.hostname)+'/ws');
mySocket.onmessage = function(event) { mySocket.onmessage = function(event) {
var json = JSON.parse(event.data); var json = JSON.parse(event.data);
handleJson(json.state); //console.log(json);
updateUI(true); if (handleJson(json.state)) updateUI(true);
} }
} }
@ -493,7 +493,7 @@ function populatePresets(fromls)
if (expanded[i+100]) expand(i+100, true); if (expanded[i+100]) expand(i+100, true);
} }
} else { presetError(true); } } else { presetError(true); }
updatePA(); updatePA(true);
populateQL(); populateQL();
} }
@ -867,7 +867,7 @@ function updateLen(s)
d.getElementById(`seg${s}len`).innerHTML = out; d.getElementById(`seg${s}len`).innerHTML = out;
} }
function updatePA() function updatePA(scrollto=false)
{ {
var ps = d.getElementsByClassName("seg"); var ps = d.getElementsByClassName("seg");
for (let i = 0; i < ps.length; i++) { for (let i = 0; i < ps.length; i++) {
@ -879,8 +879,16 @@ function updatePA()
} }
if (currentPreset > 0) { if (currentPreset > 0) {
var acv = d.getElementById(`p${currentPreset}o`); var acv = d.getElementById(`p${currentPreset}o`);
if (acv && !expanded[currentPreset+100]) if (acv && !expanded[currentPreset+100]) {
acv.style.background = "var(--c-6)"; acv.style.background = "var(--c-6)";
if (scrollto) {
// scroll selected preset into view (on WS refresh)
acv.scrollIntoView({
behavior: 'smooth',
block: 'center',
});
}
}
acv = d.getElementById(`p${currentPreset}qlb`); acv = d.getElementById(`p${currentPreset}qlb`);
if (acv) acv.style.background = "var(--c-6)"; if (acv) acv.style.background = "var(--c-6)";
} }
@ -901,7 +909,7 @@ function updateUI(scrollto=false)
updateTrail(d.getElementById('sliderW')); updateTrail(d.getElementById('sliderW'));
if (isRgbw) d.getElementById('wwrap').style.display = "block"; if (isRgbw) d.getElementById('wwrap').style.display = "block";
updatePA(); updatePA(scrollto);
updateHex(); updateHex();
updateRgb(); updateRgb();
} }

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2103191 #define VERSION 2103201
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG