summaryrefslogtreecommitdiff
path: root/public/static/geolocation.js
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-05-10 18:56:39 +0200
committerDaniel Friesel <derf@finalrewind.org>2016-05-10 18:56:39 +0200
commit7c62efcbdce785f77f48e56ce7876a496e6cce89 (patch)
treefbfb855e4924f871ad8c976e77a86b16c12fd6d0 /public/static/geolocation.js
parent7cbad918566f55749b1f931bbb89114909fc4869 (diff)
geolocation: proper error messages & formatting
Diffstat (limited to 'public/static/geolocation.js')
-rw-r--r--public/static/geolocation.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/public/static/geolocation.js b/public/static/geolocation.js
index ccf0325..6e5fdb5 100644
--- a/public/static/geolocation.js
+++ b/public/static/geolocation.js
@@ -2,13 +2,19 @@ $(document).ready(function() {
var removeStatus = function() {
$('div.candidatestatus').remove();
};
+ var showError = function(str) {
+ var errnode = $(document.createElement('span'));
+ errnode.attr('class', 'error');
+ errnode.text(str);
+ $('div.candidatelist').append(errnode);
+ };
var processResult = function(data) {
removeStatus();
if (data.error) {
- $('div.candidatelist').text(data.error);
+ showError(data.error);
} else if (data.candidates.length == 0) {
- $('div.candidatelist').text("Keine Bahnhöfe in 70km Umkreis gefunden");
+ showError('Keine Bahnhöfe in 70km Umkreis gefunden');
} else {
$.each(data.candidates, function(i, candidate) {
@@ -33,13 +39,13 @@ $(document).ready(function() {
var processError = function(error) {
removeStatus();
if (error.code == error.PERMISSION_DENIED) {
- $('div.candidatelist').text('Geolocation request denied');
+ showError('Standortanfrage abglehnt. Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.');
} else if (error.code == error.POSITION_UNAVAILABLE) {
- $('div.candidatelist').text('Geolocation not available');
+ showError('Standort konnte nicht ermittelt werden (Service nicht verfügbar)');
} else if (error.code == error.TIMEOUT) {
- $('div.candidatelist').text('Geolocation timeout');
+ showError('Standort konnte nicht ermittelt werden (Timeout)');
} else {
- $('div.candidatelist').text('Unknown error');
+ showError('Standort konnte nicht ermittelt werden (unbekannter Fehler)');
}
};
@@ -48,6 +54,6 @@ $(document).ready(function() {
$('div.candidatestatus').text('Position wird bestimmt…');
} else {
removeStatus();
- $('div.candidatelist').text('Geolocation is not supported by your browser');
+ showError('Standortanfragen werden von diesem Browser nicht unterstützt');
}
});