From 336e074b4a9411be7e44349892673598daa634ff Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Tue, 18 Nov 2025 20:40:04 +0100 Subject: [PATCH] fix for 0byte size files, also made reading ledmaps more efficient when a ledmap is read from a file, it first parses the keys, putting the in front is more efficient as it will find them in the first 256 byte chunk. --- wled00/data/edit.htm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wled00/data/edit.htm b/wled00/data/edit.htm index f5ed204b..d295639f 100644 --- a/wled00/data/edit.htm +++ b/wled00/data/edit.htm @@ -264,7 +264,7 @@ function createTree(element, editor){ leaf.textContent=name; var span = cE("span"); span.style.cssText = "font-size: 14px; color: #aaa; margin-left: 8px;"; - span.textContent = Math.max(0.1, (size / 1024)).toFixed(1) + "KB"; // show size in KB, minimum 0.1 to not show 0KB for small files + span.textContent = (size > 0 ? Math.max(0.1, (size / 1024)).toFixed(1) : 0) + "KB"; // show size in KB, minimum 0.1 to not show 0KB for small files leaf.appendChild(span); leaf.onmouseover=function(){ leaf.style.background="#333"; }; leaf.onmouseout=function(){ leaf.style.background=""; }; @@ -377,13 +377,13 @@ function prettyLedmap(json){ rows.push(" " + obj.map.slice(i, i + width).map(pad).join(", ")); } - let pretty = "{\n \"map\": [\n" + rows.join(",\n") + "\n ]"; + let pretty = "{\n"; for (let k of Object.keys(obj)) { if (k !== "map") { - pretty += ",\n \"" + k + "\": " + JSON.stringify(obj[k]); + pretty += " \"" + k + "\": " + JSON.stringify(obj[k]) + ",\n"; // print all keys first (speeds up loading) } } - pretty += "\n}"; + pretty += " \"map\": [\n" + rows.join(",\n") + "\n ]\n}"; return pretty; } catch (e) { return json;