1jQuery(document).ready(function () { 2 var $stats = jQuery('.p3-wpo-stat .stat'); 3 // console.log($stats); 4 var has_animated = false; 5 checkToCount(); 6 7 jQuery(window).on('scroll', function () { 8 checkToCount(); 9 }); 10 11 jQuery(window).resize(function () { 12 checkToCount(); 13 }); 14 15 function checkVisible(e) { 16 var viewport_height = jQuery(window).height(); 17 var scroll_top = jQuery(window).scrollTop(); 18 var y = jQuery(e).offset().top; 19 var element_height = jQuery(e).height(); 20 21 return y < viewport_height + scroll_top && y > scroll_top - element_height; 22 } 23 24 function checkToCount() { 25 if ($stats.length > 0) { 26 if (checkVisible($stats) && !has_animated) { 27 countStats(); 28 } 29 } 30 } 31 32 function commaSeparateNumber(val) { 33 while (/(\d+)(\d{3})/.test(val.toString())) { 34 val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2'); 35 } 36 return val; 37 } 38 39 function cleanStat(stat, decimal = 2) { 40 stat = +parseFloat(stat).toFixed(decimal); 41 return stat; 42 } 43 44 function step($this, current) { 45 if (current) { 46 if ($this.data('format') === 'commas') { 47 $this.html( 48 commaSeparateNumber( 49 cleanStat( 50 String(current).replace(/,/g, ''), 51 $this.data('decimal') 52 ).toLocaleString('en-US') 53 ) 54 ); 55 } else { 56 $this.html(cleanStat(current, $this.data('decimal'))); 57 } 58 } 59 } 60 61 function countStats() { 62 $stats.each(function () { 63 has_animated = true; 64 var $this = jQuery(this); 65 var goal = cleanStat( 66 String($this.html()).replace(/,/g, ''), 67 $this.data('decimal') 68 ); 69 70 // check if stat is NaN 71 if (parseFloat(goal) == parseFloat(goal)) { 72 jQuery({ stat: 0 }).animate( 73 { 74 stat: goal, 75 }, 76 { 77 duration: 1500, 78 easing: 'linear', 79 step: function (current) { 80 step($this, current); 81 }, 82 complete: function (current) { 83 step($this, current); 84 }, 85 } 86 ); 87 } 88 }); 89 } 90});
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.