X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/c597ebf61d244dda966f8cc06799d897172fce84..2b99d15fd5b90978a089243cb22dd6ec1f139b0f:/src/main.js diff --git a/src/main.js b/src/main.js index a8269c6..3b17bed 100644 --- a/src/main.js +++ b/src/main.js @@ -1,43 +1,5 @@ import App from './App.svelte'; -import { refresh_page } from './lib/stores.js'; - -let myhistory = []; const app = new App({ // eslint-disable-line no-unused-vars target: document.body }); - - -function is_relative_url(url) { - if (!url) return false; - if (url.indexOf('?') === 0) return true; - if (url.indexOf('/') === 0) return true; - if (url.indexOf('#') === 0) return false; - if (url.match(/^http/)) return false; - if (!url.match(/\.html/)) return true; - - return false; -} - - -// load page after click on relative URL -document.addEventListener('click', function (e) { - - // loop parent nodes from the target to the delegation node - for (var target = e.target; target && target !== this; target = target.parentNode) { - if (target.matches('a')) { - - var target_url = target.href; - - if (!is_relative_url(target_url)) return; - - e.preventDefault(); - e.stopPropagation(); - - window.history.pushState(myhistory, '', target_url); - - refresh_page(); - break; - } - } -});