X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/9e8d3367fe08a708b1019ff39ac752e0105be20a..31109c4698b3bf0368d139b3edacd2235bc30853:/src/lib/stores.js diff --git a/src/lib/stores.js b/src/lib/stores.js index a7a524a..03f32cc 100644 --- a/src/lib/stores.js +++ b/src/lib/stores.js @@ -3,6 +3,7 @@ import { writable } from 'svelte/store'; export const map_store = writable(); export const results_store = writable(); export const last_api_request_url_store = writable(); +export const error_store = writable(); export const page = writable(); /** @@ -15,13 +16,13 @@ export const page = writable(); * the requested query parameters. It may also be omitted completely for a * link without query parameters. */ +const pagenames = ['search', 'reverse', 'details', 'deletable', 'polygons', 'status', 'about']; + export function refresh_page(pagename, params) { if (typeof pagename === 'undefined') { pagename = window.location.pathname.replace('.html', '').replace(/^.*\//, ''); - if (['search', 'reverse', 'details', 'deletable', 'polygons'].indexOf(pagename) === -1) { - pagename = 'search'; - } + if (!pagenames.includes(pagename)) pagename = 'search'; params = new URLSearchParams(window.location.search); } else { @@ -33,8 +34,16 @@ export function refresh_page(pagename, params) { if (param_str) { param_str = '?' + param_str; } - window.history.pushState([], '', pagename + '.html' + param_str); + let new_url = pagename + '.html' + param_str; + + if (window.location.protocol.match(/^http/)) { + window.history.pushState([], '', new_url); + } else { + window.location.href = new_url; + } } page.set({ tab: pagename, params: params }); + last_api_request_url_store.set(null); + error_store.set(null); }