summaryrefslogtreecommitdiff
path: root/public/static/js/geostop.min.js
blob: 98e710b8346ac1bf17826dba9bb98ec26fa83c0c (plain)
1
$(function(){function t(e){r(),e.error?o("Backend-Fehler:",e.error,null):0==e.candidates.length?o("Keine Bahnhöfe in 70km Umkreis gefunden","",null):$.each(e.candidates,function(e,t){var n=t.ds100,r=t.name,o=(o=t.distance).toFixed(1),t=$(document.createElement("a"));t.attr("href",n),t.text(r);r=$(document.createElement("div"));r.attr("class","distance"),r.text(o),t.append(r),$("div.candidatelist").append(t)})}var r=function(){$("div.candidatestatus").remove()},o=function(e,t,n){var r=$(document.createElement("div"));r.attr("class","error"),r.text(t);t=$(document.createElement("strong"));t.text(e),r.prepend(t),n&&((t=$(document.createElement("div"))).attr("class","errcode"),t.text(n),r.append(t)),$("div.candidatelist").append(r)};navigator.geolocation?(navigator.geolocation.getCurrentPosition(function(e){$.post("/_geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},t).fail(function(e,t,n){r(),o("Netzwerkfehler: ",t,n)}),$("div.candidatestatus").text("Suche Bahnhöfe…")},function(e){r(),e.code==e.PERMISSION_DENIED?o("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?o("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?o("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):o("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}),$("div.candidatestatus").text("Position wird bestimmt…")):(r(),o("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});