From 74cf33bfb3c4b8fe562b48b22d1668a0b75b919c Mon Sep 17 00:00:00 2001 From: marc tobias Date: Tue, 7 Jul 2020 13:48:27 +0200 Subject: [PATCH] fix more-results link --- dist/assets/js/nominatim-ui.js | 16 +++++++++++++--- src/assets/js/controller.js | 14 ++++++++++++-- src/assets/js/searchpage.js | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dist/assets/js/nominatim-ui.js b/dist/assets/js/nominatim-ui.js index faf6902..1b148a8 100644 --- a/dist/assets/js/nominatim-ui.js +++ b/dist/assets/js/nominatim-ui.js @@ -671,7 +671,7 @@ function search_page_load() { if (aResults.length >= 10) { var aExcludePlaceIds = []; if (search_params.has('exclude_place_ids')) { - aExcludePlaceIds.search_params.get('exclude_place_ids').split(','); + aExcludePlaceIds = search_params.get('exclude_place_ids').split(','); } for (var i = 0; i < aResults.length; i += 1) { aExcludePlaceIds.push(aResults[i].place_id); @@ -770,6 +770,16 @@ jQuery(document).ready(function () { } } + function is_relative_url(url) { + if (!url) return false; + if (url.indexOf('?') === 0) return true; + if (url.indexOf('/') === 0) return true; + if (url.match(/^http/)) return false; + if (!url.match(/\.html/)) return true; + + return false; + } + parse_url_and_load_page(); // load page after form submit @@ -784,10 +794,10 @@ jQuery(document).ready(function () { // load page after click on relative URL $(document).on('click', 'a', function (e) { var target_url = $(this).attr('href'); - if (target_url && target_url.match(/^http/)) return; - if (target_url && !target_url.match(/\.html/)) return; + if (!is_relative_url(target_url)) return; e.preventDefault(); + e.stopPropagation(); window.history.pushState(myhistory, '', target_url); diff --git a/src/assets/js/controller.js b/src/assets/js/controller.js index 3c122ee..4070d09 100644 --- a/src/assets/js/controller.js +++ b/src/assets/js/controller.js @@ -18,6 +18,16 @@ jQuery(document).ready(function () { } } + function is_relative_url(url) { + if (!url) return false; + if (url.indexOf('?') === 0) return true; + if (url.indexOf('/') === 0) return true; + if (url.match(/^http/)) return false; + if (!url.match(/\.html/)) return true; + + return false; + } + parse_url_and_load_page(); // load page after form submit @@ -32,10 +42,10 @@ jQuery(document).ready(function () { // load page after click on relative URL $(document).on('click', 'a', function (e) { var target_url = $(this).attr('href'); - if (target_url && target_url.match(/^http/)) return; - if (target_url && !target_url.match(/\.html/)) return; + if (!is_relative_url(target_url)) return; e.preventDefault(); + e.stopPropagation(); window.history.pushState(myhistory, '', target_url); diff --git a/src/assets/js/searchpage.js b/src/assets/js/searchpage.js index be9c20a..f53dfd4 100755 --- a/src/assets/js/searchpage.js +++ b/src/assets/js/searchpage.js @@ -411,7 +411,7 @@ function search_page_load() { if (aResults.length >= 10) { var aExcludePlaceIds = []; if (search_params.has('exclude_place_ids')) { - aExcludePlaceIds.search_params.get('exclude_place_ids').split(','); + aExcludePlaceIds = search_params.get('exclude_place_ids').split(','); } for (var i = 0; i < aResults.length; i += 1) { aExcludePlaceIds.push(aResults[i].place_id); -- 2.39.5