neue json Struktur

This commit is contained in:
chk
2026-06-14 14:05:28 +02:00
parent 30db5750a5
commit 4c70d7be8f

View File

@@ -152,6 +152,22 @@
console.log("FShow content received, length", content.length); console.log("FShow content received, length", content.length);
const el = document.querySelector("textarea#GCodeWindow.editor-look"); const el = document.querySelector("textarea#GCodeWindow.editor-look");
if (el) el.value = content; if (el) el.value = content;
} else if (data.startsWith("{")) {
try {
const json = JSON.parse(data);
if (json.programId === "log" && Array.isArray(json.lines)) {
console.log("FShow JSON received, lines:", json.lines.length, "cursor:", json.cursor);
const el = document.getElementById("GCodeWindow");
if (el) {
el.value = json.lines.join("\n");
// Scroll to cursor line
const lineHeight = el.scrollHeight / json.lines.length;
el.scrollTop = Math.max(0, (json.cursor - 5)) * lineHeight;
}
}
} catch (e) {
console.log("DATA:", Date.now() - startTime, data);
}
} else { } else {
console.log("DATA:", Date.now() - startTime, data); console.log("DATA:", Date.now() - startTime, data);
} }