1/*! 2* jquery.counterup.js 1.0 3* 4* Copyright 2013, Benjamin Intal http://gambit.ph @bfintal 5* Released under the GPL v2 License 6* 7* Date: Nov 26, 2013 8*/ 9(function ($) { 10 "use strict"; 11 12 $.fn.counterUp = function (options) { 13 14 // Defaults 15 var settings = $.extend({ 16 'time': 400, 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 var $counted = false; /* changed by FONDA */ 26 27 var counterUpper = function () { 28 if( $counted ) { /* changed by FONDA */ 29 return; 30 } 31 32 var nums = []; 33 var divisions = $settings.time / $settings.delay; 34 var num = $this.text(); 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(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 if ($this.data('counterup-nums')) { 68 $this.text($this.data('counterup-nums').shift()); 69 70 if ($this.data('counterup-nums').length) { 71 setTimeout($this.data('counterup-func'), $settings.delay); 72 } else { 73 delete $this.data('counterup-nums'); 74 $this.data('counterup-nums', null); 75 $this.data('counterup-func', null); 76 } 77 } 78 }; 79 $this.data('counterup-func', f); 80 81 // Start the count up 82 setTimeout($this.data('counterup-func'), $settings.delay); 83 84 $counted = true; /* changed by FONDA */ 85 }; 86 87 // Perform counts when the element gets into view 88 $this.waypoint(counterUpper, {offset: '100%', triggerOnce: true}); 89 }); 90 91 }; 92 93})(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.