diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2016-05-10 12:45:11 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2016-05-10 12:45:11 +0200 | 
| commit | 94a2fca1ddd44fd23f9863e8deccee9cb05fce7c (patch) | |
| tree | 163b7e54c58e849f796104c9180aab63186d2ab4 | |
| parent | 6c37dec8ed54a987acb6665fb6525a39fc6ca5da (diff) | |
a little bit of error handling
| -rw-r--r-- | public/static/geolocation.js | 14 | ||||
| -rw-r--r-- | templates/layouts/default.html.ep | 3 | 
2 files changed, 15 insertions, 2 deletions
| diff --git a/public/static/geolocation.js b/public/static/geolocation.js index 78b0691..63c08e8 100644 --- a/public/static/geolocation.js +++ b/public/static/geolocation.js @@ -22,8 +22,20 @@ $(document).ready(function() {  		$.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult);  	}; +	var processError = function(error) { +		if (error.code == error.PERMISSION_DENIED) { +			$('div.candidatelist').text('Geolocation request denied'); +		} else if (error.code == error.POSITION_UNAVAILABLE) { +			$('div.candidatelist').text('Geolocation not available'); +		} else if (error.code == error.TIMEOUT) { +			$('div.candidatelist').text('Geolocation timeout'); +		} else { +			$('div.candidatelist').text('Unknown error'); +		} +	}; +  	if (navigator.geolocation) { -		navigator.geolocation.getCurrentPosition(processLocation); +		navigator.geolocation.getCurrentPosition(processLocation, processError);  	} else {  		$('div.candidatelist').text('Geolocation is not supported by your browser');  	} diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index f57ceab..8979106 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -63,7 +63,8 @@ on 2015-01-02 at 07:00 CET.</div>  Alle Angaben ohne Gewähr.  </p>  <p class="geolink"> -<a href="<%= url_for('_auto')->to_abs->scheme('https') %>">Nahe gelegene Bahnhöfe suchen</a> +<a href="<%= url_for('_auto')->to_abs->scheme('https') %>">Bahnhöfe im Umfeld suchen</a> +(experimentell)  </p>  % } | 
