// PAGE HELPERS
// *********************************************************
-function fetch_from_api(endpoint_name, params, callback) {
+function generate_full_api_url(endpoint_name, params) {
//
// `&a=&b=&c=1` => '&c=1'
var param_names = Object.keys(params);
var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?'
+ $.param(params);
+ return api_url;
+}
+
+function fetch_from_api(endpoint_name, params, callback) {
+ var api_url = generate_full_api_url(endpoint_name, params);
if (endpoint_name !== 'status') {
$('#api-request-link').attr('href', api_url);
}
format: 'jsonv2'
};
+ if (search_params.get('debug') === '1') {
+ window.location.href = generate_full_api_url('reverse', api_request_params);
+ return;
+ }
+
context = {
// aPlace: aPlace,
fLat: api_request_params.lat,
format: 'jsonv2'
};
+ if (search_params.get('debug') === '1') {
+ window.location.href = generate_full_api_url('search', api_request_params);
+ return;
+ }
+
context = {
sQuery: api_request_params.q,
sViewBox: search_params.get('viewbox'),
function parse_url_and_load_page() {
// 'search', 'reverse', 'details'
- var pagename = window.location.pathname.replace('.html', '').replace(/.+\//, '');
+ var pagename = window.location.pathname.replace('.html', '').replace(/^.*\//, '');
- if (pagename === '') pagename = 'search'
+ if (pagename === '') pagename = 'search';
$('body').attr('id', pagename + '-page');
// PAGE HELPERS
// *********************************************************
-function fetch_from_api(endpoint_name, params, callback) {
+function generate_full_api_url(endpoint_name, params) {
//
// `&a=&b=&c=1` => '&c=1'
var param_names = Object.keys(params);
var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?'
+ $.param(params);
+ return api_url;
+}
+
+function fetch_from_api(endpoint_name, params, callback) {
+ var api_url = generate_full_api_url(endpoint_name, params);
if (endpoint_name !== 'status') {
$('#api-request-link').attr('href', api_url);
}
format: 'jsonv2'
};
+ if (search_params.get('debug') === '1') {
+ window.location.href = generate_full_api_url('reverse', api_request_params);
+ return;
+ }
+
context = {
// aPlace: aPlace,
fLat: api_request_params.lat,
format: 'jsonv2'
};
+ if (search_params.get('debug') === '1') {
+ window.location.href = generate_full_api_url('search', api_request_params);
+ return;
+ }
+
context = {
sQuery: api_request_params.q,
sViewBox: search_params.get('viewbox'),