diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-20 18:49:43 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-20 18:49:43 +0200 |
commit | da34ec2e4a6fb5534c8d0f103a29cf8ba361b774 (patch) | |
tree | 312e5eea78f91e671431c3b60ef1e0630ba6bdbc /public/static/js | |
parent | af778e68d90de820535111517270eb7896e5f2cc (diff) |
geolocation.js: It's an accident that this ever worked to begin with
Diffstat (limited to 'public/static/js')
-rw-r--r-- | public/static/js/geolocation.js | 28 | ||||
-rw-r--r-- | public/static/js/geolocation.min.js | 2 |
2 files changed, 21 insertions, 9 deletions
diff --git a/public/static/js/geolocation.js b/public/static/js/geolocation.js index f3bacd1..877bd59 100644 --- a/public/static/js/geolocation.js +++ b/public/static/js/geolocation.js @@ -26,7 +26,7 @@ $(document).ready(function() { const parts = stop.split(';'); const [ eva, name, dbris, efa, hafas, motis ] = parts; - const node = $('<a class="tablerow" href="/s/' + (eva||0) + '?dbris=' + (dbris||0) + '&efa=' + (efa||0) + '&hafas=' + (hafas||0) + '&motis=' + (motis||0) + '"><span><i class="material-icons" aria-hidden="true">' + (!(dbris||efa||motis) ? 'train' : 'directions') + '</i>' + name + '</span></a>'); + const node = $('<a class="tablerow" href="/s/' + eva + '?dbris=' + (dbris||0) + '&efa=' + (efa||0) + '&hafas=' + (hafas||0) + '&motis=' + (motis||0) + '"><span><i class="material-icons" aria-hidden="true">' + (!(dbris||efa||hafas||motis) ? 'train' : 'directions') + '</i>' + name + '</span></a>'); node.click(function() { $('nav .preloader-wrapper').addClass('active'); }); @@ -49,24 +49,36 @@ $(document).ready(function() { $.each(data.candidates, function(i, candidate) { let node; - if (candidate.motis !== undefined) { - const { id, name, motis } = candidate; - - node = $('<a class="tablerow" href="/s/' + id + '?motis=' + motis + '"><span><i class="material-icons" aria-hidden="true">train</i>' + name + '</span></a>'); - } else if (candidate.efa !== undefined) { + if (candidate.dbris) { + const eva = candidate.eva, + name = candidate.name, + dbris = candidate.dbris, + distance = candidate.distance.toFixed(1); + node = $('<a class="tablerow" href="/s/' + id + '?dbris=' + dbris + '"><span><i class="material-icons" aria-hidden="true">directions</i>' + name + '</span></a>'); + } else if (candidate.efa) { const eva = candidate.eva, name = candidate.name, efa = candidate.efa, distance = candidate.distance.toFixed(1); node = $('<a class="tablerow" href="/s/' + eva + '?efa=' + efa + '"><span><i class="material-icons" aria-hidden="true">directions</i>' + name + '</span></a>'); - } else { + } else if (candidate.hafas) { const eva = candidate.eva, name = candidate.name, hafas = candidate.hafas, distance = candidate.distance.toFixed(1); - node = $('<a class="tablerow" href="/s/' + eva + '?hafas=' + hafas + '"><span><i class="material-icons" aria-hidden="true">' + (hafas == '0' ? 'train' : 'directions') + '</i>' + name + '</span></a>'); + node = $('<a class="tablerow" href="/s/' + eva + '?hafas=' + hafas + '"><span><i class="material-icons" aria-hidden="true">directions</i>' + name + '</span></a>'); + } else if (candidate.motis) { + const { id, name, motis } = candidate; + + node = $('<a class="tablerow" href="/s/' + id + '?motis=' + motis + '"><span><i class="material-icons" aria-hidden="true">directions</i>' + name + '</span></a>'); + } else { + const eva = candidate.eva, + name = candidate.name, + distance = candidate.distance.toFixed(1); + + node = $('<a class="tablerow" href="/s/' + eva + '"><span><i class="material-icons" aria-hidden="true">train</i>' + name + '</span></a>'); } node.click(function() { diff --git a/public/static/js/geolocation.min.js b/public/static/js/geolocation.min.js index 4bf5584..4ec9dc7 100644 --- a/public/static/js/geolocation.min.js +++ b/public/static/js/geolocation.min.js @@ -1 +1 @@ -$(document).ready(function(){function i(){return $("div.geolocation div.progress")}function e(e){var t=$("div.geolocation").data("backend");$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude,backend:t},a)}function t(e){e.code==e.PERMISSION_DENIED?n("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):e.code==e.POSITION_UNAVAILABLE?n("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?n("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):n("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}const n=function(e,t,n){var a=$(document.createElement("div")),t=(a.attr("class","error"),a.text(t),$(document.createElement("strong"))),e=(t.text(e+" "),a.prepend(t),$("div.geolocation").append(a),$("div.geolocation").data("recent"));if(e){t=e.split("|");const c=$(document.createElement("p"));$.each(t,function(e,t){var[t,n,a,i,o,r]=t.split(";"),t=$('<a class="tablerow" href="/s/'+(t||0)+"?dbris="+(a||0)+"&efa="+(i||0)+"&hafas="+(o||0)+"&motis="+(r||0)+'"><span><i class="material-icons" aria-hidden="true">'+(a||i||r?"directions":"train")+"</i>"+n+"</span></a>");t.click(function(){$("nav .preloader-wrapper").addClass("active")}),c.append(t)}),$("p.geolocationhint").text("Letzte Ziele:"),i().replaceWith(c)}else i().remove()},a=function(e){if(e.error)n("Backend-Fehler:",e.error,null);else if(0==e.candidates.length)n("Keine Bahnhöfe in 70km Umkreis gefunden","",null);else{const r=$(document.createElement("p"));$.each(e.candidates,function(e,t){let n;var a,i,o;(n=void 0!==t.motis?({id:a,name:i,motis:o}=t,$('<a class="tablerow" href="/s/'+a+"?motis="+o+'"><span><i class="material-icons" aria-hidden="true">train</i>'+i+"</span></a>")):void 0!==t.efa?(a=t.eva,o=t.name,i=t.efa,t.distance.toFixed(1),$('<a class="tablerow" href="/s/'+a+"?efa="+i+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+o+"</span></a>")):(a=t.eva,i=t.name,o=t.hafas,t.distance.toFixed(1),$('<a class="tablerow" href="/s/'+a+"?hafas="+o+'"><span><i class="material-icons" aria-hidden="true">'+("0"==o?"train":"directions")+"</i>"+i+"</span></a>"))).click(function(){$("nav .preloader-wrapper").addClass("active")}),r.append(n)}),i().replaceWith(r)}},o=$("div.geolocation > .request");o.data("recent");function r(){o.replaceWith($('<p class="geolocationhint">Stationen in der Umgebung:</p><div class="progress"><div class="indeterminate"></div></div>')),navigator.geolocation.getCurrentPosition(e,t)}o.length&&(navigator.geolocation?navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(function(e){"prompt"===e.state?o.on("click",r):r()}):o.on("click",r):n("Standortanfragen werden von diesem Browser nicht unterstützt","",null))}); +$(document).ready(function(){function i(){return $("div.geolocation div.progress")}function e(e){var a=$("div.geolocation").data("backend");$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude,backend:a},t)}function a(e){e.code==e.PERMISSION_DENIED?n("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):e.code==e.POSITION_UNAVAILABLE?n("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?n("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):n("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}const n=function(e,a,n){var t=$(document.createElement("div")),a=(t.attr("class","error"),t.text(a),$(document.createElement("strong"))),e=(a.text(e+" "),t.prepend(a),$("div.geolocation").append(t),$("div.geolocation").data("recent"));if(e){a=e.split("|");const s=$(document.createElement("p"));$.each(a,function(e,a){var[a,n,t,i,o,r]=a.split(";"),a=$('<a class="tablerow" href="/s/'+a+"?dbris="+(t||0)+"&efa="+(i||0)+"&hafas="+(o||0)+"&motis="+(r||0)+'"><span><i class="material-icons" aria-hidden="true">'+(t||i||o||r?"directions":"train")+"</i>"+n+"</span></a>");a.click(function(){$("nav .preloader-wrapper").addClass("active")}),s.append(a)}),$("p.geolocationhint").text("Letzte Ziele:"),i().replaceWith(s)}else i().remove()},t=function(e){if(e.error)n("Backend-Fehler:",e.error,null);else if(0==e.candidates.length)n("Keine Bahnhöfe in 70km Umkreis gefunden","",null);else{const c=$(document.createElement("p"));$.each(e.candidates,function(e,a){let n;if(a.dbris){a.eva;var t=a.name,i=a.dbris;a.distance.toFixed(1);n=$('<a class="tablerow" href="/s/'+id+"?dbris="+i+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+t+"</span></a>")}else if(a.efa){var i=a.eva,t=a.name,o=a.efa;a.distance.toFixed(1);n=$('<a class="tablerow" href="/s/'+i+"?efa="+o+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+t+"</span></a>")}else if(a.hafas){i=a.eva,o=a.name,t=a.hafas;a.distance.toFixed(1);n=$('<a class="tablerow" href="/s/'+i+"?hafas="+t+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+o+"</span></a>")}else if(a.motis){const{id,name:r,motis:s}=a;n=$('<a class="tablerow" href="/s/'+id+"?motis="+s+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+r+"</span></a>")}else{i=a.eva,t=a.name;a.distance.toFixed(1);n=$('<a class="tablerow" href="/s/'+i+'"><span><i class="material-icons" aria-hidden="true">train</i>'+t+"</span></a>")}n.click(function(){$("nav .preloader-wrapper").addClass("active")}),c.append(n)}),i().replaceWith(c)}},o=$("div.geolocation > .request");o.data("recent");function r(){o.replaceWith($('<p class="geolocationhint">Stationen in der Umgebung:</p><div class="progress"><div class="indeterminate"></div></div>')),navigator.geolocation.getCurrentPosition(e,a)}o.length&&(navigator.geolocation?navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(function(e){"prompt"===e.state?o.on("click",r):r()}):o.on("click",r):n("Standortanfragen werden von diesem Browser nicht unterstützt","",null))}); |