blob: 78b0691a6a72a6989f7acbeb48ad18818169d148 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
$(document).ready(function() {
var processResult = function(data) {
if (data.error) {
$('div.candidatelist').text(data.error);
} else {
$.each(data.candidates, function(i, candidate) {
var ds100 = candidate[0][0],
name = candidate[0][1],
distance = candidate[1];
distance = distance.toFixed(1);
var stationlink = $(document.createElement('a'));
stationlink.attr('href', ds100);
stationlink.text(name);
$('div.candidatelist').append(stationlink);
});
}
};
var processLocation = function(loc) {
$.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult);
};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(processLocation);
} else {
$('div.candidatelist').text('Geolocation is not supported by your browser');
}
});
|