const params = new URLSearchParams(window.location.search); const palina = params.get('palina'); const targetID = params.get('targetID'); const selectedOption = params.get('selectedOption'); console.log(palina, targetID, selectedOption); // Esempio URL backend che ritorna JSON { linea, destinazione, veicolo, soppressa } const urlBackend = `https://api.vichingo455.freeddns.org/start-fermatebus.json/?param=${targetID}¶m2=${selectedOption}&palina=${palina}`; function caricadati(){ fetch(urlBackend) .then(res => res.json()) .then(data => { const container = document.getElementById('tabella-container'); container.innerHTML = ''; if (!data || data.length === 0) { container.textContent = 'Nessun dato trovato.'; return; } // Creo tabella const table = document.createElement('table'); // Intestazione const thead = document.createElement('thead'); thead.innerHTML = ` Linea Destinazione Veicolo Soppressa `; table.appendChild(thead); // Corpo tabella const tbody = document.createElement('tbody'); data.forEach(item => { const tr = document.createElement('tr'); if (item.soppressa) { tr.classList.add('bus-card-red'); } tr.innerHTML = ` ${item.linea} ${item.destinazione} ${item.mezzo} ${item.soppressa ? 'Sì' : 'No'} `; tbody.appendChild(tr); }); table.appendChild(tbody); container.appendChild(table); }) .catch(err => { console.error('Errore nel caricamento dati:', err); document.getElementById('tabella-container').textContent = 'Errore nel caricamento dati.'; }); } caricadati(); setInterval(caricadati, 60000);