1/*! 2* jquery.countup.js 1.0.3 3* 4* Copyright 2016, Adrián Guerra Marrero http://agmstudio.io @AGMStudio_io 5* Released under the MIT License 6* 7* Date: Oct 27, 2016 8*/ 9(function( $ ){ 10 "use strict"; 11 12 $.fn.countUp = function( options ) { 13 14 // Defaults 15 var settings = $.extend({ 16 'time': 2000, 17 'delay': 10 18 }, options); 19 20 return this.each(function(){ 21 22 // Store the object 23 var $this = $(this); 24 var $settings = settings; 25 26 var counterUpper = function() { 27 if(!$this.data('counterupTo')) { 28 $this.data('counterupTo',$this.text()); 29 } 30 var time = parseInt($this.data("counter-time")) > 0 ? parseInt($this.data("counter-time")) : $settings.time; 31 var delay = parseInt($this.data("counter-delay")) > 0 ? parseInt($this.data("counter-delay")) : $settings.delay; 32 var divisions = time / delay; 33 var num = $this.data('counterupTo'); 34 var nums = [num]; 35 var isComma = /[0-9]+,[0-9]+/.test(num); 36 num = num.replace(/,/g, ''); 37 var isInt = /^[0-9]+$/.test(num); 38 var isFloat = /^[0-9]+\.[0-9]+$/.test(num); 39 var decimalPlaces = isFloat ? (num.split('.')[1] || []).length : 0; 40 41 // Generate list of incremental numbers to display 42 for (var i = divisions; i >= 1; i--) { 43 44 // Preserve as int if input was int 45 var newNum = parseInt(Math.round(num / divisions * i)); 46 47 // Preserve float if input was float 48 if (isFloat) { 49 newNum = parseFloat(num / divisions * i).toFixed(decimalPlaces); 50 } 51 52 // Preserve commas if input had commas 53 if (isComma) { 54 while (/(\d+)(\d{3})/.test(newNum.toString())) { 55 newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2'); 56 } 57 } 58 59 nums.unshift(newNum); 60 } 61 62 $this.data('counterup-nums', nums); 63 $this.text('0'); 64 65 // Updates the number until we're done 66 var f = function() { 67 $this.text($this.data('counterup-nums').shift()); 68 if ($this.data('counterup-nums').length) { 69 setTimeout($this.data('counterup-func'),delay); 70 } else { 71 delete $this.data('counterup-nums'); 72 $this.data('counterup-nums', null); 73 $this.data('counterup-func', null); 74 } 75 }; 76 $this.data('counterup-func', f); 77 78 // Start the count up 79 setTimeout($this.data('counterup-func'),delay); 80 }; 81 82 // Perform counts when the element gets into view 83 $this.waypoint(counterUpper, { offset: '100%', triggerOnce: true }); 84 }); 85 86 }; 87 88})( jQuery );
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.