hic-et-nunc/assets/js/router.js

20 lines
442 B
JavaScript
Raw Normal View History

const Router = {
getParam(key) {
return new URLSearchParams(window.location.search).get(key);
},
2026-06-05 16:45:55 +02:00
setParam(key, value) {
const url = new URL(window.location);
if (value != null) {
url.searchParams.set(key, value);
} else {
url.searchParams.delete(key);
}
history.pushState({}, "", url);
},
};
window.addEventListener("popstate", () => {
window.dispatchEvent(new CustomEvent("routechange"));
});