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); + } } }