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) {
28 if (target.matches('a')) {
30 var target_url = target.href;
32 if (!is_relative_url(target_url)) return;
37 window.history.pushState(myhistory, '', target_url);
45 // deal with back-button and other user action
46 window.onpopstate = function () {