Files
lan-play/web/js/location.js
T
Ultradesu eb0d4fb1c5
Build and Publish / Build and Publish Docker Image (push) Successful in 10m8s
Init
2026-08-05 12:32:52 +01:00

25 lines
750 B
JavaScript

(function () {
function read() {
const params = new URLSearchParams(window.location.search);
return {
path: params.get('path') || '',
play: params.get('play') || null
};
}
function write(path, play, replace) {
const url = new URL(window.location.href);
path ? url.searchParams.set('path', path) : url.searchParams.delete('path');
play ? url.searchParams.set('play', play) : url.searchParams.delete('play');
const next = `${url.pathname}${url.search}`;
window.history[replace ? 'replaceState' : 'pushState']({}, '', next);
}
function fileName(path) {
const parts = path.split('/');
return parts[parts.length - 1] || path;
}
window.LanPlayLocation = { read, write, fileName };
})();