+export function refresh_page(pagename, params) {
+ if (typeof pagename === 'undefined') {
+ pagename = window.location.pathname.replace('.html', '').replace(/^.*\//, '');
+
+ if (!pagenames.includes(pagename)) pagename = default_pagename;
+
+ params = new URLSearchParams(window.location.search);
+ } else {
+ if (!pagenames.includes(pagename)) pagename = default_pagename;
+
+ if (typeof params === 'undefined') {
+ params = new URLSearchParams();
+ }
+
+ let param_str = params.toString();
+ if (param_str) {
+ param_str = '?' + 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;
+ }
+ }
+
+ if (pagename === 'search' && params.has('q')) {
+ const arrTypeAndId = identifyLinkInQuery(params.get('q'));
+ if (arrTypeAndId instanceof Array) {
+ pagename = 'details';
+ params = new URLSearchParams();
+ params.set('osmtype', arrTypeAndId[0]);
+ params.set('osmid', arrTypeAndId[1]);