Aggiunto input manuale codice fermate cercaorario seta

This commit is contained in:
Leocraft1 2025-07-26 18:52:06 +02:00
parent e856d4a361
commit 811ed04e23
4 changed files with 78 additions and 8 deletions

View File

@ -124,10 +124,18 @@ a {
font-size: 16px;
border-radius: 6px;
border: 1px solid var(--border-color);
width: 20vw;
}
#stopCodeBar {
padding: 10px;
font-size: 16px;
border-radius: 6px;
border: 1px solid var(--border-color);
width: 20vw;
}
footer {
position: fixed;
position: relative;
bottom: 0;
left: 0;
width: 100%;

View File

@ -12,15 +12,18 @@
</head>
<body>
<header>
<nav>
<nav style="display: flex;">
<ul>
<li><a href="/seta_menu/cercaorario/index.html"><h1 style="font-size: 100%;font-weight: 500;">Torna indietro</h1></a></li>
</ul>
<ul style="flex:1;justify-content: right;">
<li><a href=""><h1 style="font-size: 100%;font-weight: 500;">Aggiorna</h1></a></li>
</ul>
</nav>
</header>
<h2>Informazioni fermata <span id="fermata-span"></span></h2>
<div id="tabella-container">Caricamento dati...</div>
<footer>
<footer class="relative">
<div>
<p>Copyright (C) 2025 ER-TPL Team - <a href="https://ertpl.pages.dev" target="_blank">ertpl.pages.dev</a> - code by Il Dani & SetaModenaFanpage <a href="about:blank" target="_blank">Codice Sorgente (Inserire link)</a></p>
</div>

View File

@ -14,7 +14,7 @@
<header>
<nav>
<ul>
<li><h1 class="warning">ATTENZIONE! Il servizio è ancora in fase di sviluppo e mancano le fermate di ritorno (codici 4000 in su), inoltre le corse vengono al momento duplicate, riferirsi sempre, se disponibile, a quella in tempo reale.</h1></li>
<li><h1 class="warning">ATTENZIONE! Il servizio è ancora in fase di sviluppo e le fermate potrebbero essere non corrette, mancano i ritorni, inoltre le corse vengono al momento duplicate, riferirsi sempre, se disponibile, a quella in tempo reale.</h1></li>
</ul>
<ul>
<li><a href="/index.html"><h1 style="font-size: 100%;font-weight: 500;">Home</h1></a></li>
@ -35,8 +35,13 @@
<div>
<input type="text" id="searchBar" placeholder="Cerca una fermata...">
</div>
<h3 style="margin: 16px;">Oppure:</h3>
<div>
<input type="text" id="stopCodeBar" placeholder="Inserisci un codice fermata...">
</div>
<p id="warning-mo">Attenzione! Se la palina non riporta MO all'inizio del codice, il MO NON va inserito!</p>
<div id="searchResults"></div>
<footer id="footer">
<footer>
<div>
<p>Copyright (C) 2025 ER-TPL Team - <a href="https://ertpl.pages.dev" target="_blank">ertpl.pages.dev</a> - code by Il Dani & SetaModenaFanpage <a href="about:blank" target="_blank">Codice Sorgente (Inserire link)</a> - I loghi SETA Spa sono marchi registrati e sono inseriti in questo sito solo a scopo di illustrazione.</p>
</div>

View File

@ -1,8 +1,10 @@
const searchBar = document.getElementById('searchBar');
const stopCodeBar = document.getElementById('stopCodeBar');
const resultsContainer = document.getElementById('searchResults');
let allresults = [];
window.onbeforeunload=searchBar.value="";
window.onbeforeunload=stopCodeBar.value="";
const url = 'https://setaapi.serverissimo.freeddns.org/stoplist';
fetch(url)
@ -16,8 +18,6 @@ fetch(url)
.catch(error => console.error('Errore nel caricamento dei dati:', error));
searchBar.addEventListener('input', () => {
const footer=document.getElementById('footer');
footer.innerHTML='';
const searchTerm = searchBar.value.toLowerCase();
const filtered = allresults.filter(item =>
item.fermata.toLowerCase().includes(searchTerm)
@ -25,6 +25,60 @@ searchBar.addEventListener('input', () => {
renderresults(filtered);
});
stopCodeBar.addEventListener('input', () => {
var code=stopCodeBar.value.toUpperCase();
code="MO"+code;
//renderresultscode(filtered);
const searchResultsContainer = document.getElementById('searchResults');
const warning=document.getElementById('warning-mo');
warning.innerHTML='';
searchResultsContainer.innerHTML = '';
const div = document.createElement('div');
div.className = 'search-result';
div.innerHTML = `
<div>
<h3>${code}</h3>
<p>Codice fermata: ${code}</p>
</div>
`;
div.addEventListener('click', () => {
const url = `fermata.html?code=${encodeURIComponent(code)}&name=${encodeURIComponent(code)}`;
parent.location=url;
});
searchResultsContainer.appendChild(div);
if (stopCodeBar.value == '') {
resultsContainer.innerHTML='';
warning.innerHTML = `
Attenzione! Se la palina non riporta MO all'inizio del codice, il MO viene inserito in automatico!
`;
return;
}
});
function renderresultscode(results) {
const searchResultsContainer = document.getElementById('searchResults');
searchResultsContainer.innerHTML = '';
const div = document.createElement('div');
div.className = 'search-result';
div.innerHTML = `
<div>
<h3>${results.fermata}</h3>
<p>Codice fermata: ${results.valore}</p>
</div>
`;
div.addEventListener('click', () => {
const url = `fermata.html?code=${encodeURIComponent(item.valore)}&name=${encodeURIComponent(item.fermata)}`;
parent.location=url;
});
searchResultsContainer.appendChild(div);
}
function renderresults(results) {
const searchResultsContainer = document.getElementById('searchResults');
searchResultsContainer.innerHTML = '';
@ -46,7 +100,7 @@ function renderresults(results) {
div.addEventListener('click', () => {
const url = `fermata.html?code=${encodeURIComponent(item.valore)}&name=${encodeURIComponent(item.fermata)}`;
window.open(url, '_blank');
parent.location=url;
});
searchResultsContainer.appendChild(div);