From 562e05cfcfcd91b49f07ad48f7ba8533e2523670 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 10 May 2016 16:58:53 +0200 Subject: _auto: show current request status --- public/static/default.css | 5 +++++ public/static/geolocation.js | 9 +++++++++ templates/geolocation.html.ep | 1 + 3 files changed, 15 insertions(+) diff --git a/public/static/default.css b/public/static/default.css index 222c9da..e0bb6a4 100644 --- a/public/static/default.css +++ b/public/static/default.css @@ -404,6 +404,11 @@ div.displaysingle div.info { color: #0000ff; } +div.candidatestatus { + text-align: center; + color: #999999; +} + div.candidatelist a { display: block; text-decoration: none; diff --git a/public/static/geolocation.js b/public/static/geolocation.js index 1d37c96..ccf0325 100644 --- a/public/static/geolocation.js +++ b/public/static/geolocation.js @@ -1,5 +1,10 @@ $(document).ready(function() { + var removeStatus = function() { + $('div.candidatestatus').remove(); + }; + var processResult = function(data) { + removeStatus(); if (data.error) { $('div.candidatelist').text(data.error); } else if (data.candidates.length == 0) { @@ -22,9 +27,11 @@ $(document).ready(function() { var processLocation = function(loc) { $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult); + $('div.candidatestatus').text('Suche Bahnhöfe…'); }; var processError = function(error) { + removeStatus(); if (error.code == error.PERMISSION_DENIED) { $('div.candidatelist').text('Geolocation request denied'); } else if (error.code == error.POSITION_UNAVAILABLE) { @@ -38,7 +45,9 @@ $(document).ready(function() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(processLocation, processError); + $('div.candidatestatus').text('Position wird bestimmt…'); } else { + removeStatus(); $('div.candidatelist').text('Geolocation is not supported by your browser'); } }); diff --git a/templates/geolocation.html.ep b/templates/geolocation.html.ep index a0667db..66e456a 100644 --- a/templates/geolocation.html.ep +++ b/templates/geolocation.html.ep @@ -1,2 +1,3 @@
Nächstgelegene Stationen:
+
Bitte warten…
-- cgit v1.2.3