Remove the code that used the "expert mode" fields for geolocation

This commit is contained in:
mossroy 2014-03-25 16:18:38 +01:00
parent edec092256
commit 7ec7117ba8

View File

@ -580,75 +580,54 @@ define(function(require) {
$('#titleListHeaderMessage').hide(); $('#titleListHeaderMessage').hide();
$('#articleContent').empty(); $('#articleContent').empty();
if (localArchive !== null && localArchive._titleFile !== null) { if (localArchive !== null && localArchive._titleFile !== null) {
var longitude = $('#longitude').val(); var maxDistance = MAX_DISTANCE_ARTICLES_NEARBY;
var latitude = $('#latitude').val(); if (navigator.geolocation) {
var maxDistance = $('#maxDistance').val(); var geo_options = {
if (!maxDistance) { enableHighAccuracy: false,
maxDistance = MAX_DISTANCE_ARTICLES_NEARBY; maximumAge: 600000, // 10 minutes
} timeout: Infinity
if (!longitude || !latitude) { };
// If the user did not give any latitude/longitude, we try to use geolocation
if (navigator.geolocation) {
var geo_options = {
enableHighAccuracy: false,
maximumAge: 600000, // 10 minutes
timeout: Infinity
};
function geo_success(pos) { function geo_success(pos) {
var crd = pos.coords; var crd = pos.coords;
if ($('#geolocationProgress').is(":visible")) {
$('#geolocationProgress').html("Found your location : latitude=" + crd.latitude + ", longitude=" + crd.longitude
+ "<br/>Now looking for articles around this location...");
var rectangle = new geometry.rect( if ($('#geolocationProgress').is(":visible")) {
crd.latitude - maxDistance, $('#geolocationProgress').html("Found your location : latitude=" + crd.latitude + ", longitude=" + crd.longitude
crd.longitude - maxDistance, + "<br/>Now looking for articles around this location...");
maxDistance * 2,
maxDistance * 2);
localArchive.getTitlesInCoords(rectangle, MAX_SEARCH_RESULT_SIZE, populateListOfTitles); var rectangle = new geometry.rect(
} crd.latitude - maxDistance,
else { crd.longitude - maxDistance,
// If the geolocationProgress div is not visible, it's because it has been canceled maxDistance * 2,
// So we simply ignore the result maxDistance * 2);
}
};
function geo_error(err) { localArchive.getTitlesInCoords(rectangle, MAX_SEARCH_RESULT_SIZE, populateListOfTitles);
if ($('#geolocationProgress').is(":visible")) { }
alert("Unable to geolocate your device : " + err.code + " : " + err.message); else {
$('#geolocationProgress').hide(); // If the geolocationProgress div is not visible, it's because it has been canceled
$('#searchingForTitles').hide(); // So we simply ignore the result
} }
else { };
// If the geolocationProgress div is not visible, it's because it has been canceled
// So we simply ignore the result function geo_error(err) {
} if ($('#geolocationProgress').is(":visible")) {
}; alert("Unable to geolocate your device : " + err.code + " : " + err.message);
$('#geolocationProgress').hide();
$('#geolocationProgress').html("Trying to geolocate your device..."); $('#searchingForTitles').hide();
$('#geolocationProgress').show(); }
navigator.geolocation.getCurrentPosition(geo_success, geo_error, geo_options); else {
} // If the geolocationProgress div is not visible, it's because it has been canceled
else { // So we simply ignore the result
alert("Geolocation is not supported (or disabled) on your device, or on your browser"); }
$('#searchingForTitles').hide(); };
}
$('#geolocationProgress').html("Trying to geolocate your device...");
$('#geolocationProgress').show();
navigator.geolocation.getCurrentPosition(geo_success, geo_error, geo_options);
} }
else { else {
// The user gave a latitude/longitude : let's use it to find articles around that location alert("Geolocation is not supported (or disabled) on your device, or on your browser");
var rectangle = new geometry.rect( $('#searchingForTitles').hide();
latitude - maxDistance,
longitude - maxDistance,
maxDistance * 2,
maxDistance * 2);
$('#geolocationProgress').html("Looking for articles around the location you gave...");
$('#geolocationProgress').show();
localArchive.getTitlesInCoords(rectangle, MAX_SEARCH_RESULT_SIZE, populateListOfTitles);
} }
} else { } else {