diff --git a/index.html b/index.html
index 6556bc4..5d44f81 100644
--- a/index.html
+++ b/index.html
@@ -50,8 +50,9 @@
Ravenna:
+ Visualizzatore fermate : MEGA-UPDATE, il bacino di Ravenna possiede 4 filtri diversi, che poi verranno spiegati nelle info . I risultati vengono anche ordinati in base al criterio di ricerca.
Migliorie generali.
- Visualizzatore fermate : aggiunte informazioni e cambiato titolo scheda fermata.
+ Visualizzatore fermate: aggiunte informazioni e cambiato titolo scheda fermata.
Visualizzatore fermate: versione mobile migliorata, rimosso parametro "Soppressa" poichè ridondante con "Stato attuale" quando accade.
In arrivo: "37251-37258 MAN Lion's City 12E".
diff --git a/start_menu/servizi/start-fermatebus/css/style.css b/start_menu/servizi/start-fermatebus/css/style.css
index da7a086..fd2801e 100644
--- a/start_menu/servizi/start-fermatebus/css/style.css
+++ b/start_menu/servizi/start-fermatebus/css/style.css
@@ -3,7 +3,14 @@
display: block !important;
width: 95.5% !important;
}
-
+ #radios{
+ display: table !important;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ #radios div{
+ margin-top: 8px;
+ }
#tabella-container{
overflow-x: scroll;
}
@@ -30,6 +37,7 @@ input{
margin-top: 10px;
cursor: pointer;
display: inline-block;
+ padding: 2px;
}
table {
@@ -112,6 +120,10 @@ a {
border: 1px solid #727070;
}
+#bacino{
+ margin-top: 10px;
+}
+
footer {
position: relative;
bottom: 0;
@@ -134,7 +146,7 @@ footer {
display: flex;
justify-content: center ;
}
-form#radios div{
+div#radios div{
width: auto;
margin-left: 10px;
padding: 8px;
diff --git a/start_menu/servizi/start-fermatebus/index.html b/start_menu/servizi/start-fermatebus/index.html
index d1ad06f..9594aba 100644
--- a/start_menu/servizi/start-fermatebus/index.html
+++ b/start_menu/servizi/start-fermatebus/index.html
@@ -2,7 +2,7 @@
-
+
START Romagna - Visualizza fermata
@@ -23,14 +23,15 @@
Visualizzatore fermate START Romagna
Informazioni sul servizio
Bacino:
-
+
--Scegli un'opzione--
Ravenna
Rimini
Forlì-Cesena
-
+
Cerca fermata:
diff --git a/start_menu/servizi/start-fermatebus/js/cercafermata.js b/start_menu/servizi/start-fermatebus/js/cercafermata.js
index c7a4ac2..cb8dcfa 100644
--- a/start_menu/servizi/start-fermatebus/js/cercafermata.js
+++ b/start_menu/servizi/start-fermatebus/js/cercafermata.js
@@ -13,7 +13,7 @@ function populateSearchResults(results, selectedOption) {
div.innerHTML = `
${item.nome}
-
Palina: ${item.palina}, Target ID: ${item.targetID}
+
Fermata: ${item.palina}, Target ID: ${item.targetID}
`;
@@ -26,8 +26,8 @@ function populateSearchResults(results, selectedOption) {
});
}
-function getFermatadaBreve(codbreve){
- const middle = String(codbreve).padStart(4, "0");
+function getFermatadaBreve(codice){
+ const middle = String(codice).padStart(4, "0");
return `7${middle}0`;
}
@@ -40,6 +40,31 @@ function filterOptions(query, data) {
);
}
+function filtraTesto(query, data){
+ const q = query.toLowerCase();
+ return data
+ .filter(item => (item.nome || '').toLowerCase().includes(q))
+ .sort((a, b) => (a.nome || '').localeCompare(b.nome || ''));
+}
+
+function filtraLungo(query, data){
+ const q = query.toLowerCase();
+ return data
+ .filter(item => (item.palina || '').toLowerCase().includes(q))
+ .sort((a, b) => (a.palina || '').localeCompare(b.palina || ''));
+}
+
+function filtraBreve(query, data){
+ const cod = getFermatadaBreve(query);
+ return filtraLungo(cod, data);
+}
+
+function filtraTID(query, data){
+ const q = query.toLowerCase();
+ return data
+ .filter(item => (item.targetID || '').toLowerCase().includes(q))
+ .sort((a, b) => (a.targetID || '').localeCompare(b.targetID || ''));
+}
let allOptions = [];
let currentSelectedOption = '';
@@ -58,20 +83,37 @@ searchBar.addEventListener('input', function() {
if (currentSelectedOption !== "ra") {
filteredOptions = filterOptions(query, allOptions);
} else {
- //placeholder: qui metteremo il filtro dettagliato per "ra"
- filteredOptions = filterOptions(query, allOptions);
- //TODO: implementare filtro "ra" custom
+ if (document.getElementById('text').checked){
+ filteredOptions = filtraTesto(query, allOptions);
+ }
+ else if (document.getElementById('lungo').checked){
+ filteredOptions = filtraLungo(query, allOptions);
+ }
+ else if (document.getElementById('breve').checked){
+ filteredOptions = filtraBreve(query, allOptions);
+ }
+ else if(document.getElementById('tid').checked){
+ filteredOptions = filtraTID(query, allOptions);
+ }
}
-
populateSearchResults(filteredOptions, currentSelectedOption);
});
+const radios = document.querySelectorAll('#radios input[type="radio"]');
+radios.forEach(radio => {
+ radio.addEventListener('change', () => {
+ searchBar.value = '';
+ document.getElementById('searchResults').innerHTML = '';
+ });
+});
document.getElementById('bacino').addEventListener('change', function(event) {
const selectedOption = event.target.value;
currentSelectedOption = selectedOption;
- //const radiobuttons = document.getElementById('radios');
+ const urlFermate = `https://api.vichingo455.freeddns.org/fermateapi/bacino?selectedOption=${selectedOption}`;
+
+ const radiobuttons = document.getElementById('radios');
const ricerca = document.getElementById('ricerca');
ricerca.removeAttribute('style');
@@ -79,20 +121,22 @@ document.getElementById('bacino').addEventListener('change', function(event) {
if(selectedOption == "n"){
ricerca.setAttribute("style", "display: none;");
- //radiobuttons.setAttribute("style", "display: none;");
+ radiobuttons.setAttribute("style", "display: none;");
allOptions = [];
document.getElementById('searchResults').innerHTML = '';
return;
}
- /*else if(selectedOption == "ra"){
+ else if(selectedOption == "ra"){
radiobuttons.removeAttribute('style')
- }*/
+ }
if(selectedOption != "n"){
const resultsContainer = document.getElementById('searchResults');
resultsContainer.innerHTML = 'Caricamento lista fermate in corso...
';
-
- fetch(`https://api.vichingo455.freeddns.org/fermateapi/bacino?selectedOption=${selectedOption}`)
+ if(selectedOption != "ra"){
+ radiobuttons.setAttribute("style", "display: none;");
+ }
+ fetch(urlFermate)
.then(res => res.json())
.then(data => {
allOptions = data;