Add files
This commit is contained in:
parent
e21c425246
commit
22656f2ad9
|
@ -0,0 +1,121 @@
|
||||||
|
:root {
|
||||||
|
--primary-color: #afafaf;
|
||||||
|
--accent-color: #0074d9;
|
||||||
|
--bg-color: #2e2d2d;
|
||||||
|
--white: #ffffff;
|
||||||
|
--light-gray: #848991;
|
||||||
|
--border-color: #727070;
|
||||||
|
--text-color: #ffffff;
|
||||||
|
--black: #000000;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: #282828;
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
font-family: Titillium Web;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-result {
|
||||||
|
border: 2px solid white;
|
||||||
|
border-radius: 8px;
|
||||||
|
width: 15%;
|
||||||
|
margin: auto;
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
margin-top: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-radius: 8px;
|
||||||
|
width: 85%;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
background-color: lightslategray;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 2px solid #444;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background-color: dimgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bus-card-red {
|
||||||
|
background-color: rgb(241, 120, 120) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
font-size: 67%;
|
||||||
|
background-color: #333;
|
||||||
|
height: auto;
|
||||||
|
padding: 0px 0px;
|
||||||
|
align-items: start;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul {
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
text-align: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav.index {
|
||||||
|
display: flex;
|
||||||
|
min-height: 51px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li {
|
||||||
|
margin-left: 20px;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li a {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.search-result {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#bacino,
|
||||||
|
#searchBar {
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,72 @@
|
||||||
|
function populateSearchResults(results, selectedOption) {
|
||||||
|
const searchResultsContainer = document.getElementById('searchResults');
|
||||||
|
searchResultsContainer.innerHTML = '';
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
searchResultsContainer.innerHTML = '<p>Nessun risultato trovato</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
results.forEach(item => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.className = 'search-result';
|
||||||
|
div.innerHTML = `
|
||||||
|
<div>
|
||||||
|
<h3>${item.nome}</h3>
|
||||||
|
<p>Palina: ${item.palina}, Target ID: ${item.targetID}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
div.addEventListener('click', () => {
|
||||||
|
const url = `fermata.html?palina=${encodeURIComponent(item.palina)}&targetID=${encodeURIComponent(item.targetID)}&selectedOption=${encodeURIComponent(selectedOption)}`;
|
||||||
|
window.location.href = url;
|
||||||
|
});
|
||||||
|
|
||||||
|
searchResultsContainer.appendChild(div);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterOptions(query, data) {
|
||||||
|
const q = query.toLowerCase();
|
||||||
|
return data.filter(item =>
|
||||||
|
(item.nome || '').toLowerCase().includes(q) ||
|
||||||
|
(item.palina || '').toLowerCase().includes(q) ||
|
||||||
|
(item.targetID || '').toLowerCase().includes(q)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let allOptions = [];
|
||||||
|
let currentSelectedOption = '';
|
||||||
|
|
||||||
|
const searchBar = document.getElementById('searchBar');
|
||||||
|
searchBar.addEventListener('input', function() {
|
||||||
|
const query = searchBar.value;
|
||||||
|
const filteredOptions = filterOptions(query, allOptions);
|
||||||
|
populateSearchResults(filteredOptions, currentSelectedOption);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('bacino').addEventListener('change', function(event) {
|
||||||
|
const selectedOption = event.target.value;
|
||||||
|
currentSelectedOption = selectedOption;
|
||||||
|
|
||||||
|
if (!selectedOption) {
|
||||||
|
allOptions = [];
|
||||||
|
document.getElementById('searchResults').innerHTML = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultsContainer = document.getElementById('searchResults');
|
||||||
|
resultsContainer.innerHTML = '<p>Caricamento lista fermate in corso...</p>';
|
||||||
|
|
||||||
|
fetch(`http://localhost:3005/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);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,70 @@
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
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/w?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');
|
||||||
|
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.innerHTML = '<h3>Nessuna linea in arrivo.</h3>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creo tabella
|
||||||
|
const table = document.createElement('table');
|
||||||
|
|
||||||
|
// Intestazione
|
||||||
|
const thead = document.createElement('thead');
|
||||||
|
thead.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<th>Linea</th>
|
||||||
|
<th>Destinazione</th>
|
||||||
|
<th>Orario</th>
|
||||||
|
<th>Stato attuale</th>
|
||||||
|
<th>Veicolo</th>
|
||||||
|
<th>Soppressa</th>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
table.appendChild(thead);
|
||||||
|
|
||||||
|
// Corpo tabella
|
||||||
|
const tbody = document.createElement('tbody');
|
||||||
|
data.slice(1).forEach(item => {
|
||||||
|
const tr = document.createElement('tr');
|
||||||
|
if (item.soppressa) {
|
||||||
|
tr.classList.add('bus-card-red');
|
||||||
|
}
|
||||||
|
tr.innerHTML = `
|
||||||
|
<td>${item.linea}</td>
|
||||||
|
<td>${item.destinazione}</td>
|
||||||
|
<td>${item.orario}</td>
|
||||||
|
<td>${item.stato}</td>
|
||||||
|
<td>${item.mezzo}</td>
|
||||||
|
<td>${item.soppressa ? 'Sì' : 'No'}</td>
|
||||||
|
`;
|
||||||
|
tbody.appendChild(tr);
|
||||||
|
});
|
||||||
|
table.appendChild(tbody);
|
||||||
|
|
||||||
|
container.appendChild(table);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('Errore nel caricamento dati:', err);
|
||||||
|
document.getElementById('tabella-container').textContent = 'Errore nel caricamento dati.';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
caricadati();
|
||||||
|
|
||||||
|
setInterval(caricadati, 60000);
|
Loading…
Reference in New Issue