1 import { writable } from 'svelte/store';
3 export const map_store = writable();
4 export const results_store = writable();
5 export const last_api_request_url_store = writable();
6 export const page = writable();
9 * Update the global page state.
11 * When called without a parameter, then the current window.location is
12 * parsed and the page state is set accordingly. Otherwise the page state
13 * is set from the parameters. 'pagename' is the overall subpage (without
14 * .html extension). 'params' must be an URLSearchParams object and contain
15 * the requested query parameters. It may also be omitted completely for a
16 * link without query parameters.
18 export function refresh_page(pagename, params) {
19 if (typeof pagename === 'undefined') {
20 pagename = window.location.pathname.replace('.html', '').replace(/^.*\//, '');
22 if (['search', 'reverse', 'details', 'deletable', 'polygons'].indexOf(pagename) === -1) {
26 params = new URLSearchParams(window.location.search);
28 if (typeof params === 'undefined') {
29 params = new URLSearchParams();
32 let param_str = params.toString();
34 param_str = '?' + param_str;
36 window.history.pushState([], '', pagename + '.html' + param_str);
39 page.set({ tab: pagename, params: params });