mirror of
https://github.com/Daniongithub/ER-TPL.git
synced 2025-10-02 17:50:49 +00:00
Fixes
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
function loadJSON(file, callback) {
|
||||
fetch(file)
|
||||
.then(response => response.json())
|
||||
.then(data => callback(data))
|
||||
.catch(error => console.error('Errore nel caricare il file JSON:', error));
|
||||
}
|
||||
|
||||
function populateSearchResults(results, selectedOption) {
|
||||
const searchResultsContainer = document.getElementById('searchResults');
|
||||
searchResultsContainer.innerHTML = '';
|
||||
@@ -57,25 +50,23 @@ document.getElementById('bacino').addEventListener('change', function(event) {
|
||||
const selectedOption = event.target.value;
|
||||
currentSelectedOption = selectedOption;
|
||||
|
||||
let file = '';
|
||||
switch (selectedOption) {
|
||||
case 'ra':
|
||||
file = 'js/fermate-ra.json';
|
||||
break;
|
||||
case 'rn':
|
||||
file = 'js/fermate-rn.json';
|
||||
break;
|
||||
case 'fc':
|
||||
file = 'js/fermate-fc.json';
|
||||
break;
|
||||
default:
|
||||
allOptions = [];
|
||||
document.getElementById('searchResults').innerHTML = '';
|
||||
return;
|
||||
if (!selectedOption) {
|
||||
allOptions = [];
|
||||
document.getElementById('searchResults').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
loadJSON(file, (data) => {
|
||||
allOptions = data;
|
||||
populateSearchResults(allOptions, currentSelectedOption);
|
||||
});
|
||||
});
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
resultsContainer.innerHTML = '<p>Caricamento lista fermate in corso...</p>';
|
||||
|
||||
fetch(`https://api.vichingo455.freeddns.org/start-fermatebus/bacino?selectedOption=${selectedOption}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
allOptions = data;
|
||||
populateSearchResults(allOptions, selectedOption);
|
||||
})
|
||||
.catch(err => {
|
||||
resultsContainer.innerHTML = '<p>Errore nel caricamento delle fermate.</p>';
|
||||
console.error('Errore:', err);
|
||||
});
|
||||
});
|
@@ -3,19 +3,21 @@ const palina = params.get('palina');
|
||||
const targetID = params.get('targetID');
|
||||
const selectedOption = params.get('selectedOption');
|
||||
|
||||
const urlBackend = `https://api.vichingo455.freeddns.org/start-fermatebus.json/?param=${targetID}¶m2=${selectedOption}&palina=${palina}`;
|
||||
//const urlBackend = `http://localhost:3005/?param=${targetID}¶m2=${selectedOption}&palina=${palina}`;
|
||||
const urlBackend = `https://api.vichingo455.freeddns.org/start-fermatebus/fermata?param=${targetID}¶m2=${selectedOption}&palina=${palina}`;
|
||||
//const urlBackend = `http://localhost:3005/fermata?param=${targetID}¶m2=${selectedOption}&palina=${palina}`;
|
||||
function caricadati(){
|
||||
fetch(urlBackend)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const fermata_span = document.getElementById('fermata-span');
|
||||
fermata_span.innerHTML = `"${data[0].fermata}"`;
|
||||
if (data[0] && data[0].fermata !== undefined) {
|
||||
fermata_span.innerHTML = `"${data[0].fermata}"`;
|
||||
}
|
||||
const container = document.getElementById('tabella-container');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (!data || data.length === 0) {
|
||||
container.textContent = 'Nessun dato trovato.';
|
||||
container.innerHTML = '<h3>Nessuna linea in arrivo.</h3>';
|
||||
return;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user