X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/73f37fb6fece8f3ea1b7847110cf1397f4081245..13014639687c0607d0a617ffebc68d9d529a69da:/src/assets/js/base.js?ds=sidebyside diff --git a/src/assets/js/base.js b/src/assets/js/base.js index 0a5b2c8..39d1f13 100644 --- a/src/assets/js/base.js +++ b/src/assets/js/base.js @@ -96,18 +96,36 @@ function generate_full_api_url(endpoint_name, params) { return api_url; } -function fetch_from_api(endpoint_name, params, callback) { +function update_last_updated(endpoint_name, params) { + if (endpoint_name === 'status') return; + var api_url = generate_full_api_url(endpoint_name, params); - if (endpoint_name !== 'status') { - $('#api-request-link').attr('href', api_url); + $('#last-updated').show(); + + $('#api-request a').attr('href', api_url); + $('#api-request').show(); + + if (endpoint_name === 'search' || endpoint_name === 'reverse') { + $('#api-request-debug a').attr('href', api_url + '&debug=1'); + $('#api-request-debug').show(); + } else { + $('#api-request-debug').hide(); } +} + +function fetch_from_api(endpoint_name, params, callback) { + var api_url = generate_full_api_url(endpoint_name, params); $.get(api_url, function (data) { + if (endpoint_name !== 'status') { + update_last_updated(endpoint_name, params); + } callback(data); }); } function update_data_date() { fetch_from_api('status', { format: 'json' }, function (data) { + $('#last-updated').show(); $('#data-date').text(data.data_updated); }); } @@ -139,6 +157,8 @@ function hide_error() { jQuery(document).ready(function () { hide_error(); + $('#last-updated').hide(); + $(document).ajaxStart(function () { $('#loading').fadeIn('fast'); }).ajaxComplete(function () {