Modifiche dir di file+ fix js ricerca

This commit is contained in:
Leocraft1
2025-04-11 10:32:39 +00:00
parent 87a4069424
commit 8f19e373ed
91 changed files with 586 additions and 564 deletions

65
scripts/bus.json Normal file
View File

@@ -0,0 +1,65 @@
[
{
"matricola": "10108",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10108",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
},
{
"matricola": "10109",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10109",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
},
{
"matricola": "10110",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10110",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
},
{
"matricola": "10111",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10111",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
},
{
"matricola": "10112",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10112",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
},
{
"matricola": "10113",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10113",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
},
{
"matricola": "10114",
"compagnia": "START Romagna",
"settore" : "Extraurbano",
"modello" : "Scania De Simon IL.3",
"link": "startravenna_bus/extraurbano/desimon.html#10114",
"linkmodello": "startravenna_bus/extraurbano/desimon.html",
"linksettore": "start_menu/start_menu/startextra.html"
}
]

23
scripts/ertpl.js Normal file
View File

@@ -0,0 +1,23 @@
/*
The function(s) below are used to fall back to the second (not for importance) server if the first is not available
Swaps both links and images sources
aid = identifier for the anchor (a tag)
imgid = identifier for the image (img tag)
path = path for the image starting from the root, for example /Dani/10225.jpg
*/
function changeUrlToFallback(aid,imgid,path) {
try {
document.getElementById(imgid).src = "http://serverissimo.freeddns.org:30081/apps/files_sharing/publicpreview/ffdqobqRg2ezKXt?file=" + path + "&x=1920&y=1080&a=true";
} catch {}
try {
document.getElementById(aid).href = "http://serverissimo.freeddns.org:30081/apps/files_sharing/publicpreview/ffdqobqRg2ezKXt?file=" + path + "&x=1920&y=1080&a=true";
} catch {}
}
function changeUrlToFallbackNoTrue(aid,imgid,path) {
try {
document.getElementById(imgid).src = "http://serverissimo.freeddns.org:30081/apps/files_sharing/publicpreview/ffdqobqRg2ezKXt?file=" + path + "&x=1920&y=1080";
} catch {}
try {
document.getElementById(aid).href = "http://serverissimo.freeddns.org:30081/apps/files_sharing/publicpreview/ffdqobqRg2ezKXt?file=" + path + "&x=1920&y=1080";
} catch {}
}

54
scripts/search.js Normal file
View File

@@ -0,0 +1,54 @@
const searchBar = document.getElementById('searchBar');
const productsContainer = document.getElementById('bus-container');
let allProducts = [];
const url = '/scripts/bus.json'; // cambia con il tuo URL
window.onbeforeunload=searchBar.value="";
fetch(url)
.then(response => {
if (!response.ok) throw new Error("Errore nel caricamento dei dati.");
return response.json();
})
.then(data => {
allProducts = data;
//renderProducts(allProducts);
})
.catch(error => console.error('Errore nel caricamento dei dati:', error));
searchBar.addEventListener('input', () => {
if (searchBar.value == '') {
productsContainer.innerHTML = '';
return;
}
const searchTerm = searchBar.value.toLowerCase();
const filtered = allProducts.filter(bus =>
bus.matricola.toLowerCase().includes(searchTerm)
);
renderProducts(filtered);
});
searchBar.addEventListener('click', () => {
if (searchBar.value == '') {
productsContainer.innerHTML = '';
return;
}
const searchTerm = searchBar.value.toLowerCase();
const filtered = allProducts.filter(bus =>
bus.matricola.toLowerCase().includes(searchTerm)
);
renderProducts(filtered);
});
function renderProducts(products) {
productsContainer.innerHTML = '';
products.forEach(bus => {
const div = document.createElement('div');
div.className = 'product-card';
div.innerHTML = `
<a href="${bus.link}"><h3>${bus.matricola}</h3></a>
<a href="${bus.linksettore}"><p>${bus.compagnia} - ${bus.settore}</p></a>
<a href="${bus.linkmodello}"><p>${bus.modello}</p></a>
`;
productsContainer.appendChild(div);
});
}