const scrollIntoViewOptions = { behavior: "instant", block: "start", inline: "start" } const navbarHeight = 80; const scrollIntoView = (el) => { el.scrollIntoView(scrollIntoViewOptions) if ((window.innerHeight + window.scrollY) <= document.body.offsetHeight - navbarHeight ) { window.scrollBy(0,-navbarHeight ) } } window.gitlist.isDark =(theme) => { for(var i = 0; i < window.gitlist.dark.length; i++ ) { if (window.gitlist.dark[i] === theme) { return true; } } return false; } let $body; window.gitlist.codemirrorTheme = { light: 'idea', dark: 'dracula', } window.gitlist.getActualTheme = () => { const theme = window.gitlist.getThemeCookie() const actualTheme = theme.split('-')[1] return actualTheme; } window.gitlist.getActualThemeCodemirror = () => { if (window.gitlist.isDark(window.gitlist.getActualTheme())) { return window.gitlist.codemirrorTheme.dark; } else { return window.gitlist.codemirrorTheme.light; } } window.gitlist.setTheme = () => { if ($body === undefined) { setTimeout(() => { window.gitlist.setTheme() }) return; } const theme = window.gitlist.getActualTheme(); if (window.gitlist.isDark(theme)) { $body.addClass('p3x-gitlist-dark') $body.removeClass('p3x-gitlist-light') if (gitlist.viewer !== undefined) { gitlist.viewer.setOption("theme", window.gitlist.codemirrorTheme.dark); } } else { $body.addClass('p3x-gitlist-light') $body.removeClass('p3x-gitlist-dark') if (gitlist.viewer !== undefined) { gitlist.viewer.setOption("theme", window.gitlist.codemirrorTheme.light); } } let setTimeoutSwitch; if (window.gitlist.lastloadSpan !== undefined && window.gitlist.lastloadSpan > 1000) { clearTimeout(setTimeoutSwitch) setTimeoutSwitch = setTimeout(() => { $('.p3x-gitlist-overlay').remove(); }, window.gitlist.lastloadSpan) } } const pushHash = (hash) => { if(history.pushState) { const pushState = location.pathname + hash; history.pushState(null, null, pushState); } else { location.hash = hash; } } $(function () { $body = $('body'); const es = document.getElementsByTagName('a') for(let i=0; i