From: marc tobias Date: Mon, 10 Aug 2020 12:42:34 +0000 (+0200) Subject: redirect to API URL when parameter &debug=1 in URL X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/bd60ecbb7e649f42071eadae874815b890f19da4 redirect to API URL when parameter &debug=1 in URL --- diff --git a/dist/assets/js/nominatim-ui.js b/dist/assets/js/nominatim-ui.js index 43f71c2..d16de70 100644 --- a/dist/assets/js/nominatim-ui.js +++ b/dist/assets/js/nominatim-ui.js @@ -80,7 +80,7 @@ function map_viewbox_as_string() { // 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); @@ -93,6 +93,11 @@ function fetch_from_api(endpoint_name, params, callback) { 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); } @@ -581,6 +586,11 @@ function search_page_load() { 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, @@ -645,6 +655,11 @@ function search_page_load() { 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'), @@ -757,9 +772,9 @@ jQuery(document).ready(function () { 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'); diff --git a/src/assets/js/base.js b/src/assets/js/base.js index 4ff6b23..0a5b2c8 100644 --- a/src/assets/js/base.js +++ b/src/assets/js/base.js @@ -80,7 +80,7 @@ function map_viewbox_as_string() { // 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); @@ -93,6 +93,11 @@ function fetch_from_api(endpoint_name, params, callback) { 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); } diff --git a/src/assets/js/searchpage.js b/src/assets/js/searchpage.js index 0aeab64..914d864 100755 --- a/src/assets/js/searchpage.js +++ b/src/assets/js/searchpage.js @@ -321,6 +321,11 @@ function search_page_load() { 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, @@ -385,6 +390,11 @@ function search_page_load() { 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'),