1// global options 2let 3ENABLE_PAGE_PRELOADER = PRELOADER_CONTROLLER.ENABLE_PAGE_PRELOADER == 1 ? true : false, 4DEFAULT_DARK_MODE = PRELOADER_CONTROLLER.DEFAULT_DARK_MODE == 1 ? true : false, 5USE_LOCAL_STORAGE = true, 6USE_SYSTEM_PREFERENCES = PRELOADER_CONTROLLER.USE_SYSTEM_PREFERENCES == 1 ? true : false, 7DEFAULT_BREAKPOINTS = { xs: 0, sm: 576, md: 768, lg: 992, xl: 1200, xxl: 1400 }; 8 9// add dom-ready class 10document.addEventListener('DOMContentLoaded', () => { 11 html.classList.add('dom-ready'); 12}); 13 14// body scroll width 15const updateScrollWidth = () => document.documentElement.style.setProperty('--body-scroll-width', `${window.innerWidth - document.documentElement.clientWidth}px`); 16window.addEventListener('resize', updateScrollWidth); 17updateScrollWidth(); 18 19// default breakpoints classes 20const html = document.documentElement, 21 setupBp = (bp, bpSize, type = 'min') => { 22 const media = matchMedia(`(${type}-width: ${bpSize}px)`), 23 cls = `bp-${bp}${type === 'max' ? '-max' : ''}`, 24 update = () => html.classList.toggle(cls, media.matches); 25 media.onchange = update; 26 update(); 27 }; 28Object.entries(DEFAULT_BREAKPOINTS).forEach(([bp, bpSize]) => { 29 setupBp(bp, bpSize, 'min'); 30 setupBp(bp, bpSize - 1, 'max'); 31}); 32 33// auto darkmode feature 34const isDarkMode = () => html.classList.contains('uc-dark'), 35 setDarkMode = enableDark => { 36 enableDark = !!enableDark; 37 if (isDarkMode() === enableDark) return; 38 html.classList.toggle('uc-dark', enableDark); 39 window.dispatchEvent(new CustomEvent('darkmodechange')); 40 }, 41 getInitialDarkMode = () => USE_LOCAL_STORAGE && localStorage.getItem('darkMode') !== null ? localStorage.getItem('darkMode') === '1' : USE_SYSTEM_PREFERENCES ? matchMedia('(prefers-color-scheme: dark)').matches : DEFAULT_DARK_MODE; 42setDarkMode(getInitialDarkMode()); 43 44// darkmode feature by url parameters 45const dark = new URLSearchParams(location.search).get('dark'); 46if (dark) html.classList.toggle('uc-dark', dark === '1'); 47 48// page preloader feature 49if (ENABLE_PAGE_PRELOADER) { 50 const style = document.createElement('style'); 51 style.textContent = ` 52 .uc-pageloader { 53 position: fixed; top: 0; left: 0; bottom: 0; right: 0; 54 display: flex; justify-content: center; align-items: center; 55 z-index: 99999; background-color: white; 56 } 57 .uc-dark .uc-pageloader, .uc-pageloader:where(.uc-dark) { 58 background-color: #131313; 59 } 60 .uc-pageloader>.loading { 61 display: inline-block; position: relative; width: 40px; height: 40px; 62 } 63 .uc-pageloader>.loading>div { 64 box-sizing: border-box; display: block; position: absolute; 65 width: 40px; height: 40px; margin: 0; 66 border: 4px solid transparent; border-radius: 50%; 67 animation: uc-loading 1s cubic-bezier(0.5, 0, 0.5, 1) infinite; 68 border-color: var(--color-primary) transparent transparent transparent; 69 } 70 .uc-pageloader>.loading>div:nth-child(1) { animation-delay: -0.1s; } 71 .uc-pageloader>.loading>div:nth-child(2) { animation-delay: -0.2s; } 72 .uc-pageloader>.loading>div:nth-child(3) { animation-delay: -0.3s; } 73 @keyframes uc-loading { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } 74 html.show-preloader body { display: none; } 75 `; 76 document.head.append(style); 77 78 const preloader = document.createElement('div'); 79 preloader.className = 'uc-pageloader'; 80 preloader.innerHTML = '<div class="loading"><div></div><div></div><div></div><div></div></div>'; 81 html.classList.add('show-preloader'); 82 html.append(preloader); 83 84 (async () => { 85 const t0 = Date.now(); 86 await new Promise(r => document.addEventListener('DOMContentLoaded', r)); 87 html.classList.remove('show-preloader'); 88 await new Promise(r => requestAnimationFrame(r)); 89 await new Promise(r => setTimeout(r, Math.max(0, 500 - (Date.now() - t0)))); 90 preloader.style.transition = `opacity 1.1s cubic-bezier(0.8, 0, 0.2, 1)`; 91 preloader.style.opacity = 0; 92 await new Promise(r => setTimeout(r, 1100)); 93 preloader.remove(); 94 })(); 95}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.