diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-03-08 19:40:57 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-03-08 19:40:57 +0100 |
commit | 13d81d72ee7f63234dfffaa316edb62f6c90d90e (patch) | |
tree | ca44b666234bebab874c0867c2aef92e23d7d0cb /public/static | |
parent | a0040bceb6817d6e7ef0ac504b880c44da25cb7c (diff) |
show hint in case of geolocation error
Diffstat (limited to 'public/static')
-rw-r--r-- | public/static/js/geolocation.js | 9 | ||||
-rw-r--r-- | public/static/js/geolocation.min.js | 2 | ||||
l--------- | public/static/v2 | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/public/static/js/geolocation.js b/public/static/js/geolocation.js index caf2a2a..6e638e0 100644 --- a/public/static/js/geolocation.js +++ b/public/static/js/geolocation.js @@ -4,6 +4,15 @@ $(document).ready(function() { var showError = function(header, message, code) { prePlaceholder.remove(); placeholder.remove(); + var errnode = $(document.createElement('div')); + errnode.attr('class', 'error'); + errnode.text(message + '. Alternativ kannst du unter „travelynx.de/s/Name der Station“ einchecken.'); + + var headnode = $(document.createElement('strong')); + headnode.text(header); + errnode.prepend(headnode); + + $('div.geolocation').append(errnode); }; var processResult = function(data) { diff --git a/public/static/js/geolocation.min.js b/public/static/js/geolocation.min.js index 1bd2c77..6b4a790 100644 --- a/public/static/js/geolocation.min.js +++ b/public/static/js/geolocation.min.js @@ -1 +1 @@ -$(document).ready(function(){var a=$("p.geolocationhint"),n=$("div.geolocation div.progress"),t=function(e,t,o){a.remove(),n.remove()},o=function(e){e.error?t(0,e.error):0==e.candidates.length?t():(resultTable=$("<table><tbody></tbody></table>"),resultBody=resultTable.children(),$.each(e.candidates,function(e,t){var o=t.ds100,a=t.name,n=t.distance;n=n.toFixed(1);var r=$(document.createElement("a"));r.attr("href",o),r.text(a),resultBody.append('<tr><td><a href="/s/'+o+'">'+a+"</a></td></tr>")}),n.replaceWith(resultTable))};navigator.geolocation?navigator.geolocation.getCurrentPosition(function(e){$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},o)},function(e){e.code==e.PERMISSION_DENIED||e.code==e.POSITION_UNAVAILABLE||(e.code,e.TIMEOUT),t()}):t()}); +$(document).ready(function(){var e=$("p.geolocationhint"),t=$("div.geolocation div.progress"),n=function(n,r,o){e.remove(),t.remove();var a=$(document.createElement("div"));a.attr("class","error"),a.text(r+". Alternativ kannst du unter „travelynx.de/s/Name der Station“ einchecken.");var i=$(document.createElement("strong"));i.text(n),a.prepend(i),$("div.geolocation").append(a)},r=function(e){e.error?n("Backend-Fehler:",e.error):0==e.candidates.length?n("Keine Bahnhöfe in 70km Umkreis gefunden",""):(resultTable=$("<table><tbody></tbody></table>"),resultBody=resultTable.children(),$.each(e.candidates,function(e,t){var n=t.ds100,r=t.name,o=t.distance;o=o.toFixed(1);var a=$(document.createElement("a"));a.attr("href",n),a.text(r),resultBody.append('<tr><td><a href="/s/'+n+'">'+r+"</a></td></tr>")}),t.replaceWith(resultTable))},o=function(e){$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},r)},a=function(e){e.code==e.PERMISSION_DENIED?n("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert."):e.code==e.POSITION_UNAVAILABLE?n("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)"):e.code==e.TIMEOUT?n("Standort konnte nicht ermittelt werden","(Timeout)"):n("Standort konnte nicht ermittelt werden","(unbekannter Fehler)")};navigator.geolocation?navigator.geolocation.getCurrentPosition(o,a):n("Standortanfragen werden von diesem Browser nicht unterstützt","")}); diff --git a/public/static/v2 b/public/static/v2 new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/public/static/v2 @@ -0,0 +1 @@ +.
\ No newline at end of file |