diff options
| author | Fuwn <[email protected]> | 2024-10-09 00:41:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-09 00:41:43 -0700 |
| commit | 998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch) | |
| tree | 50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Utility | |
| parent | feat(graphql): add badgeCount field (diff) | |
| download | due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip | |
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Utility')
| -rw-r--r-- | src/lib/Utility/Loading.svelte | 16 | ||||
| -rw-r--r-- | src/lib/Utility/device.ts | 26 | ||||
| -rw-r--r-- | src/lib/Utility/fingerprint.ts | 20 | ||||
| -rw-r--r-- | src/lib/Utility/html.ts | 70 | ||||
| -rw-r--r-- | src/lib/Utility/image.ts | 68 | ||||
| -rw-r--r-- | src/lib/Utility/notifications.ts | 34 | ||||
| -rw-r--r-- | src/lib/Utility/oauth.ts | 74 | ||||
| -rw-r--r-- | src/lib/Utility/parameters.ts | 40 | ||||
| -rw-r--r-- | src/lib/Utility/proxy.ts | 18 | ||||
| -rw-r--r-- | src/lib/Utility/root.ts | 6 | ||||
| -rw-r--r-- | src/lib/Utility/string.ts | 2 | ||||
| -rw-r--r-- | src/lib/Utility/time.ts | 14 |
12 files changed, 194 insertions, 194 deletions
diff --git a/src/lib/Utility/Loading.svelte b/src/lib/Utility/Loading.svelte index 829a3a45..92cbc1ac 100644 --- a/src/lib/Utility/Loading.svelte +++ b/src/lib/Utility/Loading.svelte @@ -1,13 +1,13 @@ <script lang="ts"> - export let type: string | undefined = undefined; - export let percent: number | undefined = undefined; - export let card = true; + export let type: string | undefined = undefined; + export let percent: number | undefined = undefined; + export let card = true; </script> <div class:card> - {#if type} - Loading {type} ...{percent ? ` ${percent}%` : ''} - {:else} - <slot /> - {/if} + {#if type} + Loading {type} ...{percent ? ` ${percent}%` : ''} + {:else} + <slot /> + {/if} </div> diff --git a/src/lib/Utility/device.ts b/src/lib/Utility/device.ts index 79eb1495..4687e1d8 100644 --- a/src/lib/Utility/device.ts +++ b/src/lib/Utility/device.ts @@ -1,17 +1,17 @@ export const mobile = () => { - let check = false; + let check = false; - ((a) => { - if ( - /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test( - a - ) || - /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( - a.substr(0, 4) - ) - ) - check = true; - })(navigator.userAgent || navigator.vendor); + ((a) => { + if ( + /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test( + a + ) || + /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( + a.substr(0, 4) + ) + ) + check = true; + })(navigator.userAgent || navigator.vendor); - return check; + return check; }; diff --git a/src/lib/Utility/fingerprint.ts b/src/lib/Utility/fingerprint.ts index d526d332..2c7211b4 100644 --- a/src/lib/Utility/fingerprint.ts +++ b/src/lib/Utility/fingerprint.ts @@ -1,14 +1,14 @@ export const getFingerprint = () => - btoa( - `${(() => { - const gl = new OffscreenCanvas(0, 0).getContext('webgl'); + btoa( + `${(() => { + const gl = new OffscreenCanvas(0, 0).getContext('webgl'); - if (!gl) return 'none'; + if (!gl) return 'none'; - const debugInfo = gl.getExtension('WEBGL_debug_renderer_info'); + const debugInfo = gl.getExtension('WEBGL_debug_renderer_info'); - return debugInfo ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : 'unknown'; - })()}-${ - navigator === null || navigator === void 0 ? void 0 : navigator.hardwareConcurrency - }-${new Date().getTimezoneOffset()}` - ); + return debugInfo ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : 'unknown'; + })()}-${ + navigator === null || navigator === void 0 ? void 0 : navigator.hardwareConcurrency + }-${new Date().getTimezoneOffset()}` + ); diff --git a/src/lib/Utility/html.ts b/src/lib/Utility/html.ts index 9dc16634..8d60d3b6 100644 --- a/src/lib/Utility/html.ts +++ b/src/lib/Utility/html.ts @@ -4,39 +4,39 @@ import { get } from 'svelte/store'; export const nbsp = (str: string) => str.replace(/ /g, ' '); export const createHeightObserver = (details = true) => { - document.querySelectorAll('.list').forEach((element) => { - if ( - !( - element as unknown as { - dataset: { observed: string }; - } - ).dataset.observed - ) { - new ResizeObserver((entries) => { - entries.forEach((entry) => { - const element = entry.target as HTMLElement; - - if (get(settings).displayLimitListHeight) { - element.style.height = 'auto'; - - const elementBound = element.getBoundingClientRect(); - const height = window.innerHeight - elementBound.top - 2.5 * 16; - - if (elementBound.height > height) element.style.height = `${height}px`; - } - }); - }).observe(element); - - if (details) - new MutationObserver((mutations) => { - mutations.forEach((mutation) => { - const element = mutation.target as HTMLDetailsElement; - - if (element.tagName === 'DETAILS' && !element.open) element.style.height = 'auto'; - }); - }).observe(element, { attributes: true }); - - element.setAttribute('data-observed', 'true'); - } - }); + document.querySelectorAll('.list').forEach((element) => { + if ( + !( + element as unknown as { + dataset: { observed: string }; + } + ).dataset.observed + ) { + new ResizeObserver((entries) => { + entries.forEach((entry) => { + const element = entry.target as HTMLElement; + + if (get(settings).displayLimitListHeight) { + element.style.height = 'auto'; + + const elementBound = element.getBoundingClientRect(); + const height = window.innerHeight - elementBound.top - 2.5 * 16; + + if (elementBound.height > height) element.style.height = `${height}px`; + } + }); + }).observe(element); + + if (details) + new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + const element = mutation.target as HTMLDetailsElement; + + if (element.tagName === 'DETAILS' && !element.open) element.style.height = 'auto'; + }); + }).observe(element, { attributes: true }); + + element.setAttribute('data-observed', 'true'); + } + }); }; diff --git a/src/lib/Utility/image.ts b/src/lib/Utility/image.ts index 94f0859c..fecc11b5 100644 --- a/src/lib/Utility/image.ts +++ b/src/lib/Utility/image.ts @@ -1,46 +1,46 @@ import { env } from '$env/dynamic/public'; export const cdn = (urlString: string | undefined) => - !urlString || - !['http', 'https'].some((protocol) => urlString.startsWith(protocol)) || - env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') || - [ - 'api.telegram.org', - 'telegra.ph', - 't.me', - 'discord.com', - 'cdn.discordapp.com', - 'media.discordapp.net', - 'images-ext-1.discordapp.net', - 'images-ext-2.discordapp.net', - 'media.trace.moe', - 'files.catbox.moe' - ].includes(new URL(urlString).hostname) - ? urlString - : `https://cdn.due.moe?url=${encodeURIComponent(urlString)}`; + !urlString || + !['http', 'https'].some((protocol) => urlString.startsWith(protocol)) || + env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') || + [ + 'api.telegram.org', + 'telegra.ph', + 't.me', + 'discord.com', + 'cdn.discordapp.com', + 'media.discordapp.net', + 'images-ext-1.discordapp.net', + 'images-ext-2.discordapp.net', + 'media.trace.moe', + 'files.catbox.moe' + ].includes(new URL(urlString).hostname) + ? urlString + : `https://cdn.due.moe?url=${encodeURIComponent(urlString)}`; export const thumbnail = (url: string | undefined) => { - const width = 144; - const height = 200; + const width = 144; + const height = 200; - if (url && url.includes('catbox.moe') && !url.includes('gif')) - return url.replace('catbox.moe/', 'catbox.moe/thumbs/t_'); + if (url && url.includes('catbox.moe') && !url.includes('gif')) + return url.replace('catbox.moe/', 'catbox.moe/thumbs/t_'); - if (url && url.includes('imgur') && !url.includes('gif')) - return (!url.includes('i.imgur.com') ? url.replace('imgur.com', 'i.imgur.com') : url).replace( - /(\.\w+)$/, - `_d.webp?maxwidth=${width}&shape=thumb&fidelity=high` - ); + if (url && url.includes('imgur') && !url.includes('gif')) + return (!url.includes('i.imgur.com') ? url.replace('imgur.com', 'i.imgur.com') : url).replace( + /(\.\w+)$/, + `_d.webp?maxwidth=${width}&shape=thumb&fidelity=high` + ); - if (url && url.includes('discordapp')) { - const match = url.match(/attachments\/(\d+)\/(\d+)\/(.+)/); + if (url && url.includes('discordapp')) { + const match = url.match(/attachments\/(\d+)\/(\d+)\/(.+)/); - if (match) { - const [_, server, id, file] = match; + if (match) { + const [_, server, id, file] = match; - return `https://media.discordapp.net/attachments/${server}/${id}/${file}?width=${width}&height=${height}`; - } - } + return `https://media.discordapp.net/attachments/${server}/${id}/${file}?width=${width}&height=${height}`; + } + } - return url; + return url; }; diff --git a/src/lib/Utility/notifications.ts b/src/lib/Utility/notifications.ts index 44fa0dd7..95cb51c1 100644 --- a/src/lib/Utility/notifications.ts +++ b/src/lib/Utility/notifications.ts @@ -3,22 +3,22 @@ import { getFingerprint } from './fingerprint'; import root from './root'; export const requestNotifications = async () => { - if ('Notification' in window && navigator.serviceWorker) { - if ((await Notification.requestPermission()) === 'granted') { - const pushSubscription = await ( - await navigator.serviceWorker.ready - ).pushManager.subscribe({ - userVisibleOnly: true, - applicationServerKey: env.PUBLIC_VAPID_PUBLIC_KEY - }); + if ('Notification' in window && navigator.serviceWorker) { + if ((await Notification.requestPermission()) === 'granted') { + const pushSubscription = await ( + await navigator.serviceWorker.ready + ).pushManager.subscribe({ + userVisibleOnly: true, + applicationServerKey: env.PUBLIC_VAPID_PUBLIC_KEY + }); - await fetch(root(`/api/notifications/subscribe?p=${getFingerprint()}`), { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(pushSubscription) - }); - } - } + await fetch(root(`/api/notifications/subscribe?p=${getFingerprint()}`), { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(pushSubscription) + }); + } + } }; diff --git a/src/lib/Utility/oauth.ts b/src/lib/Utility/oauth.ts index bc71db5e..78f52bfa 100644 --- a/src/lib/Utility/oauth.ts +++ b/src/lib/Utility/oauth.ts @@ -1,51 +1,51 @@ import { redirect, type Cookies } from '@sveltejs/kit'; export interface ClientOptions { - id: string; - secret: string; - redirectURI: string; + id: string; + secret: string; + redirectURI: string; } export interface CallbackOptions { - url: URL; - cookies: Cookies; - cookie: string; - authorise: string; - redirect?: string; - client: ClientOptions; - verifier?: string; + url: URL; + cookies: Cookies; + cookie: string; + authorise: string; + redirect?: string; + client: ClientOptions; + verifier?: string; } export const callback = async (options: CallbackOptions) => { - const { url, cookies, cookie, authorise, client } = options; - const formData = new FormData(); + const { url, cookies, cookie, authorise, client } = options; + const formData = new FormData(); - formData.append('grant_type', 'authorization_code'); - formData.append('client_id', client.id); - formData.append('client_secret', client.secret); - formData.append('redirect_uri', client.redirectURI); - formData.append('code', url.searchParams.get('code') || 'null'); + formData.append('grant_type', 'authorization_code'); + formData.append('client_id', client.id); + formData.append('client_secret', client.secret); + formData.append('redirect_uri', client.redirectURI); + formData.append('code', url.searchParams.get('code') || 'null'); - if (options.verifier) formData.append('code_verifier', options.verifier); + if (options.verifier) formData.append('code_verifier', options.verifier); - cookies.set( - cookie, - JSON.stringify( - await ( - await fetch(authorise, { - method: 'POST', - body: formData - }) - ).json() - ), - { - path: '/', - maxAge: 60 * 60 * 24 * 7, - httpOnly: false, - sameSite: 'lax', - secure: false - } - ); + cookies.set( + cookie, + JSON.stringify( + await ( + await fetch(authorise, { + method: 'POST', + body: formData + }) + ).json() + ), + { + path: '/', + maxAge: 60 * 60 * 24 * 7, + httpOnly: false, + sameSite: 'lax', + secure: false + } + ); - throw redirect(303, options.redirect ?? '/'); + throw redirect(303, options.redirect ?? '/'); }; diff --git a/src/lib/Utility/parameters.ts b/src/lib/Utility/parameters.ts index 8844f109..07154754 100644 --- a/src/lib/Utility/parameters.ts +++ b/src/lib/Utility/parameters.ts @@ -3,29 +3,29 @@ import { page } from '$app/stores'; import { get } from 'svelte/store'; export const clearAllParameters = (saved: string[] = []) => { - if (browser) { - if (get(page).url.searchParams.size === 0) return; + if (browser) { + if (get(page).url.searchParams.size === 0) return; - const parameters = new URLSearchParams(); + const parameters = new URLSearchParams(); - saved.forEach((key) => { - if (get(page).url.searchParams.has(key)) { - parameters.set(key, get(page).url.searchParams.get(key) || ''); - } - }); - history.replaceState(null, '', `${get(page).url.pathname}?${parameters}`); - } + saved.forEach((key) => { + if (get(page).url.searchParams.has(key)) { + parameters.set(key, get(page).url.searchParams.get(key) || ''); + } + }); + history.replaceState(null, '', `${get(page).url.pathname}?${parameters}`); + } }; export const parseOrDefault = <T = string | number>( - urlParameters: URLSearchParams | null, - parameter: string, - fallback: T + urlParameters: URLSearchParams | null, + parameter: string, + fallback: T ): T => - typeof fallback === 'number' - ? ((browser && urlParameters?.size !== 0 - ? parseInt(urlParameters?.get(parameter) || '', 10) || fallback - : fallback) as T) - : ((browser && urlParameters?.size !== 0 - ? urlParameters?.get(parameter) || fallback - : fallback) as T); + typeof fallback === 'number' + ? ((browser && urlParameters?.size !== 0 + ? parseInt(urlParameters?.get(parameter) || '', 10) || fallback + : fallback) as T) + : ((browser && urlParameters?.size !== 0 + ? urlParameters?.get(parameter) || fallback + : fallback) as T); diff --git a/src/lib/Utility/proxy.ts b/src/lib/Utility/proxy.ts index 7838f3cb..4c7cbb90 100644 --- a/src/lib/Utility/proxy.ts +++ b/src/lib/Utility/proxy.ts @@ -1,16 +1,16 @@ import { env } from '$env/dynamic/public'; export const proxy = (url: string, disable = false) => { - const randomKey = Math.floor(Math.random() * 90) + 10; + const randomKey = Math.floor(Math.random() * 90) + 10; - return env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') && !disable - ? url - : `https://proxy.due.moe/?d2=${btoa( - url - .split('') - .map((char) => char.charCodeAt(0) + randomKey) - .join(':') - )}${randomKey}&dh`; + return env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') && !disable + ? url + : `https://proxy.due.moe/?d2=${btoa( + url + .split('') + .map((char) => char.charCodeAt(0) + randomKey) + .join(':') + )}${randomKey}&dh`; }; export default proxy; diff --git a/src/lib/Utility/root.ts b/src/lib/Utility/root.ts index 3f9ea07d..f2a17d04 100644 --- a/src/lib/Utility/root.ts +++ b/src/lib/Utility/root.ts @@ -1,8 +1,8 @@ import { env } from '$env/dynamic/public'; export const root = (path: string, enable = false) => - env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') || enable - ? `http://localhost:5173${path}` - : `https://due.moe${path}`; + env.PUBLIC_ANILIST_REDIRECT_URI?.includes('localhost') || enable + ? `http://localhost:5173${path}` + : `https://due.moe${path}`; export default root; diff --git a/src/lib/Utility/string.ts b/src/lib/Utility/string.ts index 8cfc4ee5..7ecd2023 100644 --- a/src/lib/Utility/string.ts +++ b/src/lib/Utility/string.ts @@ -1,2 +1,2 @@ export const abbreviate = (title: string, maxLength: number) => - title.length > maxLength ? `${title.slice(0, maxLength)}...` : title; + title.length > maxLength ? `${title.slice(0, maxLength)}...` : title; diff --git a/src/lib/Utility/time.ts b/src/lib/Utility/time.ts index 4ab72212..c5edc6fb 100644 --- a/src/lib/Utility/time.ts +++ b/src/lib/Utility/time.ts @@ -1,20 +1,20 @@ export const databaseTimeToDate = (time: string) => new Date(time + 'Z'); export const dateToDatabaseTime = (date: Date) => - date.toISOString().replace('T', ' ').replace(/\..+/, ''); + date.toISOString().replace('T', ' ').replace(/\..+/, ''); export const dateToInputTime = (date: Date) => { - const offset = date.getTimezoneOffset(); + const offset = date.getTimezoneOffset(); - date.setMinutes(date.getMinutes() - offset); + date.setMinutes(date.getMinutes() - offset); - return date.toISOString().slice(0, 16); + return date.toISOString().slice(0, 16); }; export const inputTimeToDatabaseTime = (date: Date) => { - const offset = date.getTimezoneOffset(); + const offset = date.getTimezoneOffset(); - date.setMinutes(date.getMinutes() + offset); + date.setMinutes(date.getMinutes() + offset); - return dateToDatabaseTime(date); + return dateToDatabaseTime(date); }; |