Show stream url

This commit is contained in:
ekzyis 2025-01-24 23:31:55 +01:00
parent 707b17efe3
commit 09e2c95651
1 changed files with 24 additions and 1 deletions

View File

@ -19,7 +19,7 @@ templ Overlay(lnurl string, lnaddr string) {
<style id="zap-custom-css"></style>
</head>
<body>
<div id="controls" class="hidden grid grid-cols-2 fixed top-0 left-0 items-center gap-3 m-3">
<div id="controls" class="hidden grid grid-cols-[auto_auto] fixed top-0 left-0 items-center gap-3 m-3">
<label for="qr-scale-slider" class="text-black">QR code size:</label>
<input
type="range"
@ -40,6 +40,8 @@ templ Overlay(lnurl string, lnaddr string) {
value="1.0"
class="w-32 accent-teal"
/>
<label for="stream-url" class="text-black">Stream URL:</label>
<a id="stream-url" class="text-sky-600 hover:text-sky-900 underline">click me</a>
</div>
<div
id="zap-container"
@ -143,6 +145,7 @@ templ Overlay(lnurl string, lnaddr string) {
clearTimeout(timeout);
localStorage.setItem(param, value);
onChange(target, value);
updateStreamUrl();
timeout = setTimeout(() => {
const params = new URLSearchParams(window.location.search);
params.set(param, value);
@ -207,6 +210,26 @@ templ Overlay(lnurl string, lnaddr string) {
}
`;
})
function updateStreamUrl() {
const params = new URLSearchParams();
const [qrX,qrY] = localStorage.getItem('qr-position')?.split(',').map(Number) ?? [0,0];
params.set("qrX", qrX);
params.set("qrY", qrY);
const [zapX,zapY] = localStorage.getItem('zap-container-position')?.split(',').map(Number) ?? [0,0];
params.set("zapX", zapX);
params.set("zapY", zapY);
const qrScale = localStorage.getItem('qrScale') ?? 1.0;
params.set("qrScale", qrScale);
const zapScale = localStorage.getItem('zapScale') ?? 1.0;
params.set("zapScale", zapScale);
const streamUrl = `${window.location.origin}${window.location.pathname}?${params.toString()}`
const element = document.getElementById('stream-url');
element.href = streamUrl;
element.textContent = '/overlay?' + params.toString();
}
updateStreamUrl();
</script>
</body>
</html>