From 3ee9f5e7496692f0786e3a69678a2f6ebd526d58 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 24 Dec 2025 12:52:23 +0000 Subject: [PATCH] Fix duplicate aircraft cards in console output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now updates existing cards instead of creating duplicates when receiving updates for the same ICAO. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- templates/index.html | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/templates/index.html b/templates/index.html index 5b98fa3..ccdb964 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7897,8 +7897,16 @@ const placeholder = output.querySelector('.placeholder'); if (placeholder) placeholder.remove(); - const card = document.createElement('div'); - card.className = 'aircraft-card'; + // Check if card for this ICAO already exists + let card = output.querySelector(`[data-icao="${aircraft.icao}"]`); + const isNew = !card; + + if (isNew) { + card = document.createElement('div'); + card.className = 'aircraft-card'; + card.setAttribute('data-icao', aircraft.icao); + } + card.innerHTML = `
✈️
@@ -7909,11 +7917,13 @@
Heading: ${aircraft.heading ? aircraft.heading + '°' : 'N/A'}
`; - output.insertBefore(card, output.firstChild); - // Limit cards - while (output.children.length > 50) { - output.removeChild(output.lastChild); + if (isNew) { + output.insertBefore(card, output.firstChild); + // Limit cards + while (output.children.length > 50) { + output.removeChild(output.lastChild); + } } }