X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/6393226574761cd9c63651afa39015c77c87b68b..76f9bc71cd1c7e0e292249e024f8f1be9633b274:/src/main.js diff --git a/src/main.js b/src/main.js index 8445501..97c0002 100644 --- a/src/main.js +++ b/src/main.js @@ -1,44 +1,8 @@ +import { mount } from 'svelte'; import App from './App.svelte'; -import { refresh_page } from './lib/stores.js'; -let myhistory = []; - -const app = new App({ // eslint-disable-line no-unused-vars +const app = mount(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') && target.href) { - // target.href always contains the full absolute URL, inspect the raw value instead - var target_url = target.attributes.href.value; - - if (!is_relative_url(target_url)) return; - - e.preventDefault(); - e.stopPropagation(); - - window.history.pushState(myhistory, '', target_url); - - refresh_page(); - break; - } - } -}); +export default app;