1(() => { 2 const registerScrollToTop = () => { 3 4 const scrollIt = (destination, duration = 300) => { 5 const start = window.pageYOffset; 6 const startTime = 'now' in window.performance ? performance.now() : new Date().getTime(); 7 const documentHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); 8 const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight; 9 const destinationOffset = typeof destination === 'number' ? destination : destination.offsetTop; 10 const destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset); 11 12 if ('requestAnimationFrame' in window === false) { 13 window.scroll(0, destinationOffsetToScroll); 14 return; 15 } 16 17 function scroll() { 18 const now = 'now' in window.performance ? performance.now() : new Date().getTime(); 19 const time = Math.min(1, ((now - startTime) / duration)); 20 window.scroll(0, Math.ceil((time * (destinationOffsetToScroll - start)) + start)); 21 22 if (window.pageYOffset === destinationOffsetToScroll) { 23 return; 24 } 25 requestAnimationFrame(scroll); 26 } 27 28 scroll(); 29 } 30 31 const backToTopLink = document.createElement( 32 "a" 33 ); 34 backToTopLink.classList.add( 35 "mp-back-to-top" 36 ); 37 const clickBackToTop = (e) => { 38 e.preventDefault(); 39 scrollIt(0); 40 }; 41 backToTopLink.href="#"; 42 backToTopLink.innerHTML = "Back to Top"; 43 backToTopLink.addEventListener('click', clickBackToTop); 44 const body = document.getElementById('body'); 45 body.parentNode.insertBefore(backToTopLink, body.nextSibling); 46 47 const checkShowScrollButton = () => { 48 // check if we are scrolled down 49 const ScrollButton = document.querySelector('.mp-back-to-top'); 50 if (window.scrollY > 0) { 51 ScrollButton.style.display = 'block'; 52 } else { 53 ScrollButton.style.display = 'none'; 54 } 55 }; 56 57 window.addEventListener("scroll", checkShowScrollButton); 58 }; 59 60 const winLoad = (callback) => { 61 if (document.readyState === 'complete') { 62 callback(); 63 } else { 64 window.addEventListener('load', callback); 65 } 66 }; 67 68 winLoad(registerScrollToTop); 69})();(() => { 70 const registerFixedNav = () => { 71 const nav = document.querySelector('#topnav'); 72 const topOfNav = nav.offsetTop; 73 const mobileLogoLink = document.createElement('a'); 74 const logoToCopy = document.querySelector('link[rel="shortcut icon"]'); 75 76 const stickyLogo = document.createElement('img'); 77 stickyLogo.setAttribute('alt', 'Home'); 78 if (logoToCopy) { 79 stickyLogo.setAttribute('src', logoToCopy.href); 80 stickyLogo.setAttribute('width', 50); 81 stickyLogo.setAttribute('height', 50); 82 mobileLogoLink.append(stickyLogo); 83 } 84 mobileLogoLink.setAttribute('href', document.querySelector('#logo a[rel="home"]').href); 85 mobileLogoLink.classList.add('mp-sticky-logo'); 86 // remove existing sticky logo 87 const oldStickyLogo = nav.querySelector('a.mp-sticky-logo'); 88 if (oldStickyLogo) nav.removeChild(oldStickyLogo); 89 nav.insertBefore(mobileLogoLink, nav.firstChild); 90 91 const fixNav = () => { 92 if (window.scrollY >= topOfNav) { 93 nav.classList.add('fixed'); 94 } else { 95 nav.classList.remove('fixed'); 96 } 97 }; 98 window.addEventListener('scroll', fixNav); 99 }; 100 101 const winLoad = (callback) => { 102 if (document.readyState === 'complete') { 103 callback(); 104 } else { 105 window.addEventListener('load', callback); 106 } 107 }; 108 109 winLoad(registerFixedNav); 110})();
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.