robot.json display
This commit is contained in:
@@ -89,6 +89,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
// ── Robot.json + History ─────────────────────────────────────────────────
|
// ── Robot.json + History ─────────────────────────────────────────────────
|
||||||
|
|
||||||
let robotJsonActive = 'current';
|
let robotJsonActive = 'current';
|
||||||
|
let robotJsonLastSerialized = null;
|
||||||
|
|
||||||
function renderJsonTree(data, container) {
|
function renderJsonTree(data, container) {
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
@@ -123,9 +124,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
fetch(url)
|
fetch(url)
|
||||||
.then(res => res.ok ? res.json() : Promise.reject(res.status))
|
.then(res => res.ok ? res.json() : Promise.reject(res.status))
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
const serialized = JSON.stringify(data);
|
||||||
document.getElementById('robotJsonLabel').textContent =
|
document.getElementById('robotJsonLabel').textContent =
|
||||||
robotJsonActive === 'current' ? '(aktuell)' : `(${robotJsonActive})`;
|
robotJsonActive === 'current' ? '(aktuell)' : `(${robotJsonActive})`;
|
||||||
|
if (serialized !== robotJsonLastSerialized) {
|
||||||
|
robotJsonLastSerialized = serialized;
|
||||||
renderJsonTree(data, document.getElementById('robotJsonTree'));
|
renderJsonTree(data, document.getElementById('robotJsonTree'));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
document.getElementById('robotJsonTree').textContent = `Fehler: ${err}`;
|
document.getElementById('robotJsonTree').textContent = `Fehler: ${err}`;
|
||||||
@@ -134,6 +139,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
function setHistoryActive(ts) {
|
function setHistoryActive(ts) {
|
||||||
robotJsonActive = ts;
|
robotJsonActive = ts;
|
||||||
|
robotJsonLastSerialized = null; // Neuaufbau erzwingen beim Snapshot-Wechsel
|
||||||
updateRobotJson();
|
updateRobotJson();
|
||||||
document.querySelectorAll('#robotHistoryList li').forEach(l => {
|
document.querySelectorAll('#robotHistoryList li').forEach(l => {
|
||||||
l.classList.toggle('rh-active', l.dataset.ts === ts);
|
l.classList.toggle('rh-active', l.dataset.ts === ts);
|
||||||
|
|||||||
Reference in New Issue
Block a user