1function debounce (func, wait, immediate) { 2 var timeout 3 return function () { 4 var context = this 5 var args = arguments 6 var later = function () { 7 timeout = null 8 if (!immediate) func.apply(context, args) 9 } 10 var callNow = immediate && !timeout 11 clearTimeout(timeout) 12 timeout = setTimeout(later, wait) 13 if (callNow) func.apply(context, args) 14 } 15}; 16 17function throttle (func, wait, options) { 18 var timeout, context, args 19 var previous = 0 20 if (!options) options = {} 21 22 var later = function () { 23 previous = options.leading === false ? 0 : new Date().getTime() 24 timeout = null 25 func.apply(context, args) 26 if (!timeout) context = args = null 27 } 28 29 var throttled = function () { 30 var now = new Date().getTime() 31 if (!previous && options.leading === false) previous = now 32 var remaining = wait - (now - previous) 33 context = this 34 args = arguments 35 if (remaining <= 0 || remaining > wait) { 36 if (timeout) { 37 clearTimeout(timeout) 38 timeout = null 39 } 40 previous = now 41 func.apply(context, args) 42 if (!timeout) context = args = null 43 } else if (!timeout && options.trailing !== false) { 44 timeout = setTimeout(later, remaining) 45 } 46 } 47 48 return throttled 49} 50 51function sidebarPaddingR () { 52 var innerWidth = window.innerWidth 53 var clientWidth = document.body.clientWidth 54 var paddingRight = innerWidth - clientWidth 55 if (innerWidth !== clientWidth) { 56 $('body').css('padding-right', paddingRight) 57 } 58} 59 60// iPadOS 61function isIpad () { 62 return navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 63} 64 65function isTMobile () { 66 var ua = navigator.userAgent 67 var pa = /iPad|iPhone|iPod|Android|Opera Mini|BlackBerry|webOS|UCWEB|Blazer|PSP|IEMobile|Symbian/g 68 return window.screen.width < 992 && pa.test(ua) 69} 70 71function isMobile () { 72 return this.isIpad() || this.isTMobile() 73} 74 75function isDesktop () { 76 return !this.isMobile() 77} 78 79function scrollTo (name) { 80 var scrollOffset = $(name).offset() 81 $('body,html').animate({ 82 scrollTop: scrollOffset.top 83 }) 84}; 85 86function loadScript (url, callback) { 87 var script = document.createElement('script') 88 script.type = 'text/javascript' 89 if (script.readyState) { // IE 90 script.onreadystatechange = function () { 91 if (script.readyState === 'loaded' || 92 script.readyState === 'complete') { 93 script.onreadystatechange = null 94 callback() 95 } 96 } 97 } else { // Others 98 script.onload = function () { 99 callback() 100 } 101 } 102 script.src = url 103 document.body.appendChild(script) 104}; 105 106function snackbarShow (text, showAction, duration) { 107 var a = (typeof showAction !== 'undefined') ? showAction : false 108 var d = (typeof duration !== 'undefined') ? duration : 2000 109 var position = GLOBAL_CONFIG.Snackbar.position 110 var bg = document.documentElement.getAttribute('data-theme') === 'light' ? GLOBAL_CONFIG.Snackbar.bgLight : GLOBAL_CONFIG.Snackbar.bgDark 111 Snackbar.show({ 112 text: text, 113 backgroundColor: bg, 114 showAction: a, 115 duration: d, 116 pos: position 117 }) 118} 119 120window.debounce = debounce 121 122window.throttle = throttle 123 124window.isMobile = isMobile 125 126window.loadScript = loadScript
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.