Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Container, Service, Token } from 'typedi'; import { AppImage } from '@constants/image'; import { site } from '@constants/site'; import { getLog } from '@services/internal/logService'; interface IAddScriptToHead { id: string; url: string; async?: boolean; defer?: boolean; onLoad?: () => void; } @Service() export class DocumentService { setDocumentTitle = (pageTitle: string) => { document.title = `${site.title} - ${pageTitle}`; }; // getWindowProperty = (property: string) => // (window as unknown as { [prop: string]: unknown })[property]; addScriptToHead = (props: IAddScriptToHead) => { const existingScript = document.getElementById(props.id); if (existingScript != null) { existingScript.remove(); } try { const scriptNode = document.createElement('script'); scriptNode.id = props.id; scriptNode.type = 'text/javascript'; scriptNode.async = props.async ?? false; scriptNode.defer = props.defer ?? false; if (props.onLoad != null) { scriptNode.onload = props.onLoad; } scriptNode.src = props.url; document.head?.appendChild?.(scriptNode); } catch (err) { getLog().e('addScriptToHead ex', err); } }; addVideoBackground = () => { const videoBgId = 'bg-vid'; if (document.body.clientWidth < 700) { getLog().i('screen too small form video bg'); return; } const existingScript = document.getElementById(videoBgId); if (existingScript != null) { existingScript.remove(); } try { const videoElem = document.createElement('video'); videoElem.id = videoBgId; videoElem.playsInline = true; videoElem.autoplay = true; videoElem.muted = true; videoElem.loop = true; const vidUrlTypes = ['webm', 'mp4']; for (const vidUrlType of vidUrlTypes) { const videoSourceElem = document.createElement('source'); videoSourceElem.src = `${AppImage.backgroundVideo}.${vidUrlType}`; videoSourceElem.type = `video/${vidUrlType}`; videoElem.appendChild(videoSourceElem); } document.body.prepend(videoElem); } catch (err) { getLog().e('addVideoBackground ex', err); } }; } export const getDocumentServ = () => Container.get(DocumentService); |