From a1d81718e11282964ff9e18e983b1d38b476258b Mon Sep 17 00:00:00 2001 From: Curry141 <135717077+Daniongithub@users.noreply.github.com> Date: Tue, 9 Sep 2025 17:51:42 +0200 Subject: [PATCH] Sync files from main repo, new version. --- css/style.css | 65 ++++++++++++++++++++++++-------- fermata.html | 6 ++- index.html | 32 +++++++++++++--- info.html | 40 ++++++++++++++++++++ js/cercafermata.js | 92 ++++++++++++++++++++++++++++++++++++++++++---- js/fermata.js | 13 ++++--- 6 files changed, 212 insertions(+), 36 deletions(-) create mode 100644 info.html diff --git a/css/style.css b/css/style.css index f10d18b..caa4c6a 100644 --- a/css/style.css +++ b/css/style.css @@ -1,19 +1,19 @@ -:root { - --primary-color: #afafaf; - --accent-color: #0074d9; - --bg-color: #2e2d2d; - --white: #ffffff; - --light-gray: #848991; - --border-color: #727070; - --text-color: #ffffff; - --black: #000000; -} - @media (max-width: 768px) { .search-result { 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; + } } body { @@ -23,6 +23,10 @@ body { font-family: Titillium Web; } +input{ + margin-top: 5px; +} + .search-result { border: 2px solid white; border-radius: 8px; @@ -33,11 +37,11 @@ body { margin-top: 10px; cursor: pointer; display: inline-block; + padding: 2px; } table { border-collapse: collapse; - border-radius: 8px; width: 85%; margin: auto; margin-top: 1rem; @@ -47,8 +51,7 @@ th { background-color: lightslategray; } -th, -td { +th, td { border: 2px solid #444; padding: 8px; text-align: left; @@ -59,7 +62,7 @@ tr:nth-child(even) { } .bus-card-red { - background-color: rgb(241, 120, 120) !important; + background-color: red !important; } header { @@ -114,7 +117,11 @@ a { padding: 10px; font-size: 16px; border-radius: 6px; - border: 1px solid var(--border-color); + border: 1px solid #727070; +} + +#bacino{ + margin-top: 10px; } footer { @@ -122,4 +129,30 @@ footer { bottom: 0; left: 0; width: 100%; +} + +.info{ + color: white; +} + +.lista li{ + list-style-type: disc; + list-style-position: inside; + margin-bottom: 10px; +} +#radios{ + margin-top: 15px; + margin-bottom: 15px; + display: flex; + justify-content: center; +} + +div#radios div{ + display: flex; + align-items: center; + width: auto; + margin-left: 8px; + padding: 8px; + border: 2px #404040 solid; + border-radius: 8px; } \ No newline at end of file diff --git a/fermata.html b/fermata.html index ab732d1..0bd849a 100644 --- a/fermata.html +++ b/fermata.html @@ -14,16 +14,18 @@

Informazioni fermata

Caricamento dati...
+

Attenzione: i dati qui visualizzati sono direttamente ottenuti da Start Romagna,
pertanto eventuali imprecisioni o errori non sono a carico nostro.

+

Versione API:

\ No newline at end of file diff --git a/index.html b/index.html index fc38722..9594aba 100644 --- a/index.html +++ b/index.html @@ -6,12 +6,12 @@ START Romagna - Visualizza fermata - + -
+

Visualizzatore fermate START Romagna

+ Informazioni sul servizio
- + -
+
-

Copyright (C) 2025 ER-TPL Team - ertpl.pages.dev - code by Il Dani Codice Sorgente
Start Romagna, Start e il logo Start Romagna sono marchi registrati e protetti da copyright da Start Romagna SpA. Vengono usati in questa pagina solo per riferimento.

+

Copyright © 2025 ER-TPL Team - ertpl.pages.dev - code by Il Dani codice sorgente
Start Romagna, Start e il logo Start Romagna sono marchi registrati e protetti da copyright da Start Romagna SpA. Vengono usati in questa pagina solo per riferimento.

diff --git a/info.html b/info.html new file mode 100644 index 0000000..d30aeae --- /dev/null +++ b/info.html @@ -0,0 +1,40 @@ + + + + + + START Romagna - Visualizza fermata + + + + + + + +
+ +
+

Note e informazioni sul visualizzatore fermate

+

Come leggere il codice fermata e inserirlo sul sito:

+

Questa sezione sarà scritta entro o poco oltre l'inizio del servizio scolastico

+

Note varie:

+ +
+
+

Copyright © 2025 ER-TPL Team - ertpl.pages.dev - code by Il Dani codice sorgente
Start Romagna, Start e il logo Start Romagna sono marchi registrati e protetti da copyright da Start Romagna SpA. Vengono usati in questa pagina solo per riferimento.

+
+
+ + \ No newline at end of file diff --git a/js/cercafermata.js b/js/cercafermata.js index 28d6005..cb8dcfa 100644 --- a/js/cercafermata.js +++ b/js/cercafermata.js @@ -13,19 +13,24 @@ function populateSearchResults(results, selectedOption) { div.innerHTML = `

${item.nome}

-

Palina: ${item.palina}, Target ID: ${item.targetID}

+

Fermata: ${item.palina}, Target ID: ${item.targetID}

`; div.addEventListener('click', () => { const url = `fermata.html?palina=${encodeURIComponent(item.palina)}&targetID=${encodeURIComponent(item.targetID)}&selectedOption=${encodeURIComponent(selectedOption)}`; - window.location.href = url; + window.open(url, "_blank"); }); searchResultsContainer.appendChild(div); }); } +function getFermatadaBreve(codice){ + const middle = String(codice).padStart(4, "0"); + return `7${middle}0`; +} + function filterOptions(query, data) { const q = query.toLowerCase(); return data.filter(item => @@ -35,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 = ''; @@ -46,20 +76,67 @@ searchBar.addEventListener('input', function() { populateSearchResults(filteredOptions, currentSelectedOption); }); +searchBar.addEventListener('input', function() { + const query = searchBar.value; + let filteredOptions; + + if (currentSelectedOption !== "ra") { + filteredOptions = filterOptions(query, allOptions); + } else { + 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; - if (!selectedOption) { + const urlFermate = `https://api.vichingo455.freeddns.org/fermateapi/bacino?selectedOption=${selectedOption}`; + + const radiobuttons = document.getElementById('radios'); + const ricerca = document.getElementById('ricerca'); + ricerca.removeAttribute('style'); + + document.getElementById('searchBar').value = ""; + + if(selectedOption == "n"){ + ricerca.setAttribute("style", "display: none;"); + radiobuttons.setAttribute("style", "display: none;"); allOptions = []; document.getElementById('searchResults').innerHTML = ''; return; } + else if(selectedOption == "ra"){ + radiobuttons.removeAttribute('style') + } - const resultsContainer = document.getElementById('searchResults'); - resultsContainer.innerHTML = '

Caricamento lista fermate in corso...

'; - - fetch(`http://localhost:3005/bacino?selectedOption=${selectedOption}`) + if(selectedOption != "n"){ + const resultsContainer = document.getElementById('searchResults'); + resultsContainer.innerHTML = '

Caricamento lista fermate in corso...

'; + if(selectedOption != "ra"){ + radiobuttons.setAttribute("style", "display: none;"); + } + fetch(urlFermate) .then(res => res.json()) .then(data => { allOptions = data; @@ -69,4 +146,5 @@ document.getElementById('bacino').addEventListener('change', function(event) { resultsContainer.innerHTML = '

Errore nel caricamento delle fermate.

'; console.error('Errore:', err); }); + } }); \ No newline at end of file diff --git a/js/fermata.js b/js/fermata.js index d5f4892..c263494 100644 --- a/js/fermata.js +++ b/js/fermata.js @@ -3,8 +3,7 @@ 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}`; +const urlBackend = `https://api.vichingo455.freeddns.org/fermateapi/fermata?param=${targetID}¶m2=${selectedOption}&palina=${palina}`; function caricadati(){ fetch(urlBackend) .then(res => res.json()) @@ -12,10 +11,15 @@ function caricadati(){ const fermata_span = document.getElementById('fermata-span'); if (data[0] && data[0].fermata !== undefined) { fermata_span.innerHTML = `"${data[0].fermata}"`; + document.title = `Fermata ${data[0].fermata}` } const container = document.getElementById('tabella-container'); container.innerHTML = ''; + fetch('https://api.vichingo455.freeddns.org/fermateapi/versione') + .then(res => res.text()) + .then(versione => document.getElementById("ver").innerHTML = versione); + if (!data || data.length === 0) { container.innerHTML = '

Nessuna linea in arrivo.

'; return; @@ -33,7 +37,6 @@ function caricadati(){ Orario Stato attuale Veicolo - Soppressa `; table.appendChild(thead); @@ -51,7 +54,6 @@ function caricadati(){ ${item.orario} ${item.stato} ${item.mezzo} - ${item.soppressa ? 'Sì' : 'No'} `; tbody.appendChild(tr); }); @@ -67,4 +69,5 @@ function caricadati(){ caricadati(); -setInterval(caricadati, 60000); \ No newline at end of file + +setInterval(caricadati, 60000);