X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/0fda15db882f5e4019fd6ec8ae59b6fefd907104..f357bd32747fb38f00f59e65f74ae0dfcc4d5da6:/src/assets/js/searchpage.js diff --git a/src/assets/js/searchpage.js b/src/assets/js/searchpage.js index a315338..95d842d 100755 --- a/src/assets/js/searchpage.js +++ b/src/assets/js/searchpage.js @@ -292,12 +292,9 @@ function init_map_on_search_page(is_reverse_search, nominatim_results, request_l +function search_page_load() { -jQuery(document).ready(function () { - // - if (!$('#search-page,#reverse-page').length) { return; } - - var is_reverse_search = !!($('#reverse-page').length); + var is_reverse_search = window.location.pathname.match(/reverse/); var search_params = new URLSearchParams(window.location.search); @@ -342,6 +339,7 @@ jQuery(document).ready(function () { aPlace = null; } + context.bSearchRan = true; context.aPlace = aPlace; render_template($('main'), 'reversepage-template', context); @@ -409,21 +407,23 @@ jQuery(document).ready(function () { fetch_from_api('search', api_request_params, function (aResults) { + context.bSearchRan = true; context.aSearchResults = aResults; - if (aResults.length >= 10) { - var aExcludePlaceIds = []; - if (search_params.has('exclude_place_ids')) { - aExcludePlaceIds.search_params.get('exclude_place_ids').split(','); - } - for (var i = 0; i < aResults.length; i += 1) { - aExcludePlaceIds.push(aResults[i].place_id); - } - - var parsed_url = new URLSearchParams(window.location.search); - parsed_url.set('exclude_place_ids', aExcludePlaceIds.join(',')); - context.sMoreURL = '?' + parsed_url.toString(); + // lonvia wrote: https://github.com/osm-search/nominatim-ui/issues/24 + // I would suggest to remove the guessing and always show the link. Nominatim only returns + // one or two results when it believes the result to be a good enough match. + // if (aResults.length >= 10) { + var aExcludePlaceIds = []; + if (search_params.has('exclude_place_ids')) { + aExcludePlaceIds = search_params.get('exclude_place_ids').split(','); } + for (var i = 0; i < aResults.length; i += 1) { + aExcludePlaceIds.push(aResults[i].place_id); + } + var parsed_url = new URLSearchParams(window.location.search); + parsed_url.set('exclude_place_ids', aExcludePlaceIds.join(',')); + context.sMoreURL = '?' + parsed_url.toString(); render_template($('main'), 'searchpage-template', context); update_html_title('Result for ' + api_request_params.q); @@ -452,4 +452,6 @@ jQuery(document).ready(function () { ); } } -}); +} + +