Spostamento servizi seta

This commit is contained in:
Leocraft1
2025-11-02 14:30:43 +01:00
parent 8fea308e79
commit 9f6f009d1c
32 changed files with 131 additions and 131 deletions

View File

@@ -0,0 +1,76 @@
const params = new URLSearchParams(window.location.search);
const id = params.get('routecode');
const num = params.get('routenum');
const codiceSpan = document.getElementById('codice-span');
const destSpan = document.getElementById('destinazione-span');
const pNav = document.getElementById('percorso-nav');
//Displays route code
codiceSpan.textContent = id;
//Nav per tornare indietro
pNav.innerHTML = `
<ul>
<li><a href="/index.html"><h1 style="font-size: 100%;font-weight: 500;">Home</h1></a></li>
<li><a href="/seta_modena/servizi/percorsi/index.html"><h1 style="font-size: 100%;font-weight: 500;">Selettore linea</h1></a></li>
<li><a href="/seta_modena/servizi/percorsi/rcodes.html?routenum=${num}"><h1 style="font-size: 100%;font-weight: 500;">Selettore percorso</h1></a></li>
</ul>
`;
const urlBackend = `https://setaapi.serverissimo.freeddns.org/routestops/${id}`;
//const urlBackend = `http://localhost:5001/arrivals/${codice}`;
function caricadati(){
var item=[];
fetch(urlBackend)
.then(response => {
if (!response.ok) throw new Error("Errore di risposta nel caricamento dei dati, probabilmente il server API è offline.");
return response.json();
})
.then(data => {
item = data;
})
.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 = `
<tr>
<th class="linea" style="text-align:center;">Nome:</th>
<th class="linea" style="text-align:center;">Codice:</th>
</tr>
`;
table.appendChild(thead);
// Corpo tabella
const tbody = document.createElement('tbody');
item.forEach(item => {
const element = item;
var tr = document.createElement('tr');
tr.innerHTML = `
<tr>
<td class="uguale"><a href="/seta_servizi/cercaorario/fermata.html?code=${item.code}&name=${item.desc}" class="bianco">${item.desc}</a></td>
<td class="uguale"><a href="/seta_servizi/cercaorario/fermata.html?code=${item.code}&name=${item.desc}" class="bianco">${item.code}</a></td>
</tr>
`;
tbody.appendChild(tr);
if(element.islast==true){
destSpan.innerHTML=element.desc.toUpperCase();
}
});
table.appendChild(tbody);
container.appendChild(table);
})
.catch(err => {
if(item.error=="Percorso non trovato"){
document.getElementById('tabella-container').textContent = "Percorso non trovato.";
}else{
console.error('Errore nel caricamento dati:', err);
document.getElementById('tabella-container').textContent = "Errore nella sintassi dei dati ricevuti.";
}
});
}
caricadati();