const lineaSelect = document.getElementById('linea'); const modelloSelect = document.getElementById('modello'); let allresults = []; //Reperire modelli e numeri linea const urlRoutes = 'https://setaapi.serverissimo.freeddns.org/routenumberslist'; //const urlRoutes = 'http://localhost:5001/stoplist'; const urlModels = 'https://setaapi.serverissimo.freeddns.org/busmodels'; //const urlModels = 'http://localhost:5001/stoplist'; //Fetch routes and models and fill the select options fetch(urlRoutes) .then(response => { if (!response.ok) throw new Error("Errore nel caricamento dei dati."); return response.json(); }) .then(data => { allresults = data; console.log(allresults); allresults.forEach(route => { const option = document.createElement('option'); option.value = route; option.textContent = route; lineaSelect.appendChild(option); }); }) .catch(error => console.error('Errore nel caricamento dei dati:', error)); fetch(urlModels) .then(response => { if (!response.ok) throw new Error("Errore nel caricamento dei dati."); return response.json(); }) .then(data => { allresults = data; allresults.forEach(route => { const option = document.createElement('option'); option.value = route; option.textContent = route; modelloSelect.appendChild(option); }); }) .catch(error => console.error('Errore nel caricamento dei dati:', error)); caricadati(); function caricadati(){ const urlList="https://setaapi.serverissimo.freeddns.org/busesinservice"; fetch(urlList) .then(response => { if (!response.ok) throw new Error("Errore nel caricamento dei dati."); return response.json(); }) .then(data => { item = data.features; }) .then(data => { const container = document.getElementById('tabella-container'); container.innerHTML = ''; // Creo tabella const table = document.createElement('table'); // Intestazione const thead = document.createElement('thead'); thead.innerHTML = `