1 import App from './App.svelte';
2 import { refresh_page } from './lib/stores.js';
6 const app = new App({ // eslint-disable-line no-unused-vars
11 function is_relative_url(url) {
12 if (!url) return false;
13 if (url.indexOf('?') === 0) return true;
14 if (url.indexOf('/') === 0) return true;
15 if (url.indexOf('#') === 0) return false;
16 if (url.match(/^http/)) return false;
17 if (!url.match(/\.html/)) return true;
23 // load page after click on relative URL
24 document.addEventListener('click', function (e) {
26 // loop parent nodes from the target to the delegation node
27 for (var target = e.target; target && target !== this; target = target.parentNode) {
29 if (target.matches('a') && target.href) {
30 // target.href always contains the full absolute URL, inspect the raw value instead
31 var target_url = target.attributes.href.value;
33 if (!is_relative_url(target_url)) return;
38 window.history.pushState(myhistory, '', target_url);