1// counter 2if (document.querySelector('.counter')) { 3 var counters = document.querySelectorAll('.counter'); 4 var c = document.querySelector('.counter'); 5 var counted; 6 7 var isInViewport = function (elem) { 8 var distance = elem.getBoundingClientRect(); 9 return ( 10 distance.top >= 0 && 11 distance.left >= 0 && 12 distance.bottom <= 13 (window.innerHeight || document.documentElement.clientHeight) && 14 distance.right <= 15 (window.innerWidth || document.documentElement.clientWidth) 16 ); 17 }; 18 19 window.addEventListener( 20 'scroll', 21 function (event) { 22 if (isInViewport(c)) { 23 countUp(counters, 1000); 24 counted = true; 25 } else { 26 counted = false; 27 } 28 }, 29 false 30 ); 31 32 function countUp(element, interval) { 33 Array.prototype.slice.call(element).forEach(function (counter) { 34 var max = counter.innerHTML; 35 var i = 0; 36 counter.innerHTML = i; 37 var timer = interval / max; 38 39 if (!counted) { 40 var counting = setInterval(function () { 41 i += 1; 42 if (i <= max) { 43 counter.innerHTML = i; 44 } else { 45 clearInterval(counting); 46 } 47 }, timer); 48 } else { 49 counter.innerHTML = max; 50 } 51 }); 52 } 53}
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.