Files
ER-TPL/seta_modena/servizi/cercaorario/js/notizielinea.js
2025-11-04 18:14:49 +01:00

36 lines
1.3 KiB
JavaScript

const params = new URLSearchParams(window.location.search);
const num = params.get('routenum');
const newsContainer = document.getElementById('notizie-container');
const lineaSpan = document.getElementById('linea-span');
//Urls
const url = "https://setaapi.serverissimo.freeddns.org/routeproblems/"+num;
//Display numero linea
lineaSpan.textContent=num;
//Spawn product card
fetch(url)
.then(response => {
if (!response.ok) throw new Error("Errore nel caricamento dei dati.");
return response.json();
})
.then(data => {
newsContainer.innerHTML='';
data.problems.forEach(element => {
var div = document.createElement("div");
div.setAttribute("class","news-card");
var p = document.createElement('p');
var h3 = document.createElement('h3');
var a = document.createElement('a');
const link = "/seta_modena/menu/notizia.html?link="+element.link;
a.setAttribute("href",link);
a.setAttribute("class","bianco");
p.innerHTML=element.date;
h3.innerHTML=element.title;
a.appendChild(p);
a.appendChild(h3);
div.appendChild(a);
newsContainer.appendChild(div);
});
})