fix: correct url copy

This commit is contained in:
dusk 2023-05-09 18:01:56 +03:00
parent 2fc154f8a4
commit eba9e8b5d0
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 62 additions and 62 deletions

View File

@ -1,2 +1,2 @@
export const ssr = false; export const ssr = true;
export const prerender = false; export const prerender = false;

View File

@ -4,77 +4,77 @@ import { PUBLIC_BASEURL } from '$env/static/public';
export const scheme = dev ? 'http' : 'https'; export const scheme = dev ? 'http' : 'https';
export function makeShareUrl(token: string) { export function makeShareUrl(token: string) {
return `${PUBLIC_BASEURL}/share/${token}`; return `${scheme}://${PUBLIC_BASEURL}/share/${token}`;
} }
export function getAudioElement() { export function getAudioElement() {
const elem = document.getElementById('audio-source'); const elem = document.getElementById('audio-source');
if (elem === null) { if (elem === null) {
return null; return null;
} }
return elem as HTMLAudioElement; return elem as HTMLAudioElement;
} }
export function calculateMinuteSecond(seconds: number) { export function calculateMinuteSecond(seconds: number) {
let secs = Math.floor(seconds); let secs = Math.floor(seconds);
let secsLeftover = secs % 60; let secsLeftover = secs % 60;
let minutes = (secs - secsLeftover) / 60; let minutes = (secs - secsLeftover) / 60;
let secondsFormatted = secsLeftover < 10 ? `0${secsLeftover}` : `${secsLeftover}`; let secondsFormatted = secsLeftover < 10 ? `0${secsLeftover}` : `${secsLeftover}`;
let minutesFormatted = minutes < 10 ? `0${minutes}` : `${minutes}`; let minutesFormatted = minutes < 10 ? `0${minutes}` : `${minutes}`;
return `${minutesFormatted}:${secondsFormatted}`; return `${minutesFormatted}:${secondsFormatted}`;
} }
export function interceptKeys( export function interceptKeys(
extraActions: [string, () => void][] = [] extraActions: [string, () => void][] = []
): (event: KeyboardEvent) => void { ): (event: KeyboardEvent) => void {
return (event) => { return (event) => {
const tagName = document.activeElement?.tagName ?? ''; const tagName = document.activeElement?.tagName ?? '';
const audio = getAudioElement(); const audio = getAudioElement();
const actions = new Map([ const actions = new Map([
...extraActions, ...extraActions,
[ [
'Space', 'Space',
() => { () => {
if (audio !== null) { if (audio !== null) {
audio.paused ? audio.play() : audio.pause(); audio.paused ? audio.play() : audio.pause();
} }
} }
], ],
[ [
'KeyM', 'KeyM',
() => { () => {
if (audio !== null) { if (audio !== null) {
audio.muted = !audio.muted; audio.muted = !audio.muted;
} }
} }
], ],
[ [
'ArrowLeft', 'ArrowLeft',
() => { () => {
if (audio !== null) { if (audio !== null) {
audio.currentTime -= 5; audio.currentTime -= 5;
} }
} }
], ],
[ [
'ArrowRight', 'ArrowRight',
() => { () => {
const audio = getAudioElement(); const audio = getAudioElement();
if (audio !== null) { if (audio !== null) {
audio.currentTime += 5; audio.currentTime += 5;
} }
} }
] ]
]); ]);
if (tagName !== 'INPUT' && actions.has(event.code)) { if (tagName !== 'INPUT' && actions.has(event.code)) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
const action = actions.get(event.code) ?? null; const action = actions.get(event.code) ?? null;
if (action !== null) { if (action !== null) {
action(); action();
} }
} }
}; };
} }