summaryrefslogtreecommitdiff
path: root/public/static/geolocation.js
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-05-10 16:58:53 +0200
committerDaniel Friesel <derf@finalrewind.org>2016-05-10 16:58:53 +0200
commit562e05cfcfcd91b49f07ad48f7ba8533e2523670 (patch)
tree6d9aeb9b8212578ac5dc9cacc77ad4f6ff15415a /public/static/geolocation.js
parent3bb39e37e3594d14c9ff9bb3024db6cff665bd45 (diff)
_auto: show current request status
Diffstat (limited to 'public/static/geolocation.js')
-rw-r--r--public/static/geolocation.js9
1 files changed, 9 insertions, 0 deletions
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');
}
});