+'use strict';
+
var map;
var last_click_latlng;
}
function map_link_to_osm() {
- return 'https://openstreetmap.org/#map=' + map.getZoom() + '/' + map.getCenter().lat + '/' + map.getCenter().lng;
+ var zoom = map.getZoom();
+ var lat = map.getCenter().lat;
+ var lng = map.getCenter().lng;
+ return 'https://openstreetmap.org/#map=' + zoom + '/' + lat + '/' + lng;
}
function map_viewbox_as_string() {
// *********************************************************
function fetch_from_api(endpoint_name, params, callback) {
- // `&a=&b=&c=1` => '&c='
- for (var k in params) {
- if (typeof (params[k]) === 'undefined' || params[k] === '' || params[k] === null) delete params[k];
+ //
+ // `&a=&b=&c=1` => '&c=1'
+ var param_names = Object.keys(params);
+ for (var i = 0; i < param_names.length; i += 1) {
+ var val = params[param_names[i]];
+ if (typeof (val) === 'undefined' || val === '' || val === null) {
+ delete params[param_names[i]];
+ }
}
- var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?' + $.param(params);
+ var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?'
+ + $.param(params);
if (endpoint_name !== 'status') {
$('#api-request-link').attr('href', api_url);
}
el.html(html);
}
+function update_html_title(title) {
+ var prefix = '';
+ if (title && title.length > 1) {
+ prefix = title + ' | ';
+ }
+ $('head title').text(prefix + 'OpenStreetMap Nominatim');
+}
+
function show_error(html) {
$('#error-overlay').html(html).show();
}
}
-$(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
+$(document).ajaxError(function (event, jqXHR, ajaxSettings/* , thrownError */) {
// console.log(thrownError);
// console.log(ajaxSettings);
- show_error('Error fetching results from <a href="' + ajaxSettings.url + '">' + ajaxSettings.url + '</a>');
+ var url = ajaxSettings.url;
+ show_error('Error fetching results from <a href="' + url + '">' + url + '</a>');
});