Vehicle-${i+1}
${bike.model}
${bike.Variant}
`; } }); // Update model row const modelRow = document.getElementById('modelRow'); modelRow.innerHTML = ''; let hasAnyModel = false; compareBikes.forEach((bike, i) => { const box = document.createElement('div'); box.className = 'model-box'; box.innerHTML = bike ? `${bike.model}${bike.Variant || ''}` : '—'; modelRow.appendChild(box); if (bike) hasAnyModel = true; }); modelRow.style.display = hasAnyModel ? 'flex' : 'none'; updateCompareSheet(false); } document.addEventListener('click', function (e) { if (e.target.classList.contains('select-bike-btn')) { selectedSlot = parseInt(e.target.closest('.bike-card').dataset.slot); document.getElementById('bikeSelectModal').style.display = 'flex'; document.getElementById('bikeSearchInput').value = ''; document.getElementById('searchResults').innerHTML = ''; } if (e.target.id === 'closeModal') { document.getElementById('bikeSelectModal').style.display = 'none'; } if (e.target.classList.contains('remove-bike-btn')) { const slot = parseInt(e.target.dataset.slot); compareBikes[slot] = null; renderCards(); } }); document.getElementById('bikeSearchInput').addEventListener('input', function () { const term = this.value.trim(); const resultBox = document.getElementById('searchResults'); if (term.length < 2) { resultBox.innerHTML = ''; return; } fetch(`${ajaxUrl}?action=live_bike_search&term=${encodeURIComponent(term)}&type=${encodeURIComponent(type)}`) .then(res => res.json()) .then(data => { resultBox.innerHTML = ''; if (!data || data.length === 0) { resultBox.innerHTML = '
${bike.model}
${bike.Variant || 'N/A'}, ${bike.Price || 'N/A'}
${bike.Variant || 'N/A'}, ${bike.Price || 'N/A'}
