1
|
$(document).ready(function(){function i(){return $("div.geolocation div.progress")}function e(e){var n=$("div.geolocation").data("backend");$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude,backend:n},t)}function n(e){e.code==e.PERMISSION_DENIED?a("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?a("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?a("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):a("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}const a=function(e,n,a){var t=$(document.createElement("div")),n=(t.attr("class","error"),t.text(n),$(document.createElement("strong")));n.text(e+" "),t.prepend(n),$("div.geolocation").append(t),i().remove()},t=function(e){if(e.error)a("Backend-Fehler:",e.error,null);else if(0==e.candidates.length)a("Keine Bahnhöfe in 70km Umkreis gefunden","",null);else{const r=$(document.createElement("p"));$.each(e.candidates,function(e,n){let a;var t,i,o;(a=n.dbris?(i=n.eva,o=n.name,t=n.dbris,n.distance.toFixed(1),$('<a class="tablerow" href="/s/'+i+"?dbris="+t+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+o+"</span></a>")):n.efa?(i=n.eva,t=n.name,o=n.efa,n.distance.toFixed(1),$('<a class="tablerow" href="/s/'+i+"?efa="+o+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+t+"</span></a>")):n.hafas?(i=n.eva,o=n.name,t=n.hafas,n.distance.toFixed(1),$('<a class="tablerow" href="/s/'+i+"?hafas="+t+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+o+"</span></a>")):n.motis?({id:i,name:t,motis:o}=n,$('<a class="tablerow" href="/s/'+i+"?motis="+o+'"><span><i class="material-icons" aria-hidden="true">directions</i>'+t+"</span></a>")):(i=n.eva,o=n.name,n.distance.toFixed(1),$('<a class="tablerow" href="/s/'+i+'"><span><i class="material-icons" aria-hidden="true">train</i>'+o+"</span></a>"))).click(function(){$("nav .preloader-wrapper").addClass("active")}),r.append(a)}),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,n)}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):a("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});
|