From eba9e8b5d0fd3f584d372f0fb809295558576cb4 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Tue, 9 May 2023 18:01:56 +0300 Subject: [PATCH] fix: correct url copy --- src/routes/share/[token]/+layout.ts | 2 +- src/utils.ts | 122 ++++++++++++++-------------- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/routes/share/[token]/+layout.ts b/src/routes/share/[token]/+layout.ts index 83addb7..13c5c9a 100644 --- a/src/routes/share/[token]/+layout.ts +++ b/src/routes/share/[token]/+layout.ts @@ -1,2 +1,2 @@ -export const ssr = false; +export const ssr = true; export const prerender = false; diff --git a/src/utils.ts b/src/utils.ts index 86b876f..b8ddbae 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,77 +4,77 @@ import { PUBLIC_BASEURL } from '$env/static/public'; export const scheme = dev ? 'http' : 'https'; export function makeShareUrl(token: string) { - return `${PUBLIC_BASEURL}/share/${token}`; + return `${scheme}://${PUBLIC_BASEURL}/share/${token}`; } export function getAudioElement() { - const elem = document.getElementById('audio-source'); - if (elem === null) { - return null; - } - return elem as HTMLAudioElement; + const elem = document.getElementById('audio-source'); + if (elem === null) { + return null; + } + return elem as HTMLAudioElement; } export function calculateMinuteSecond(seconds: number) { - let secs = Math.floor(seconds); - let secsLeftover = secs % 60; - let minutes = (secs - secsLeftover) / 60; + let secs = Math.floor(seconds); + let secsLeftover = secs % 60; + let minutes = (secs - secsLeftover) / 60; - let secondsFormatted = secsLeftover < 10 ? `0${secsLeftover}` : `${secsLeftover}`; - let minutesFormatted = minutes < 10 ? `0${minutes}` : `${minutes}`; + let secondsFormatted = secsLeftover < 10 ? `0${secsLeftover}` : `${secsLeftover}`; + let minutesFormatted = minutes < 10 ? `0${minutes}` : `${minutes}`; - return `${minutesFormatted}:${secondsFormatted}`; + return `${minutesFormatted}:${secondsFormatted}`; } export function interceptKeys( - extraActions: [string, () => void][] = [] + extraActions: [string, () => void][] = [] ): (event: KeyboardEvent) => void { - return (event) => { - const tagName = document.activeElement?.tagName ?? ''; - const audio = getAudioElement(); - const actions = new Map([ - ...extraActions, - [ - 'Space', - () => { - if (audio !== null) { - audio.paused ? audio.play() : audio.pause(); - } - } - ], - [ - 'KeyM', - () => { - if (audio !== null) { - audio.muted = !audio.muted; - } - } - ], - [ - 'ArrowLeft', - () => { - if (audio !== null) { - audio.currentTime -= 5; - } - } - ], - [ - 'ArrowRight', - () => { - const audio = getAudioElement(); - if (audio !== null) { - audio.currentTime += 5; - } - } - ] - ]); - if (tagName !== 'INPUT' && actions.has(event.code)) { - event.preventDefault(); - event.stopPropagation(); - const action = actions.get(event.code) ?? null; - if (action !== null) { - action(); - } - } - }; + return (event) => { + const tagName = document.activeElement?.tagName ?? ''; + const audio = getAudioElement(); + const actions = new Map([ + ...extraActions, + [ + 'Space', + () => { + if (audio !== null) { + audio.paused ? audio.play() : audio.pause(); + } + } + ], + [ + 'KeyM', + () => { + if (audio !== null) { + audio.muted = !audio.muted; + } + } + ], + [ + 'ArrowLeft', + () => { + if (audio !== null) { + audio.currentTime -= 5; + } + } + ], + [ + 'ArrowRight', + () => { + const audio = getAudioElement(); + if (audio !== null) { + audio.currentTime += 5; + } + } + ] + ]); + if (tagName !== 'INPUT' && actions.has(event.code)) { + event.preventDefault(); + event.stopPropagation(); + const action = actions.get(event.code) ?? null; + if (action !== null) { + action(); + } + } + }; }