mirror of
https://github.com/Daniongithub/ER-TPL.git
synced 2025-12-06 13:52:03 +00:00
Cercaorario con problemi linea
This commit is contained in:
36
seta_modena/servizi/cercaorario/js/notizielinea.js
Normal file
36
seta_modena/servizi/cercaorario/js/notizielinea.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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);
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user