vendor: 4,746 bytes, lines 1-123
1/*! 2 * jquery.counterup.js 2.1.0 3 * 4 * Copyright 2013, Benjamin Intal http://gambit.ph @bfintal 5 * Released under the GPL v2 License 6 * 7 * Amended by Jeremy Paris, Ciro Mattia Gonano and others 8 * 9 * Date: Feb 24, 2017 10 */ 11(function ($) { 12 "use strict"; 13 14 $.fn.counterUp = function (options) { 15 16 // Defaults 17 var settings = $.extend({ 18 'time': 400, 19 'delay': 10, 20 'offset': 100, 21 'beginAt': 0, 22 'formatter': false, 23 'context': 'window', 24 callback: function () { 25 } 26 }, options), 27 s; 28 29 return this.each(function () { 30 31 // Store the object 32 var $this = $(this), 33 counter = { 34 time: $(this).data('counterup-time') || settings.time, 35 delay: $(this).data('counterup-delay') || settings.delay, 36 offset: $(this).data('counterup-offset') || settings.offset, 37 beginAt: $(this).data('counterup-beginat') || settings.beginAt, 38 context: $(this).data('counterup-context') || settings.context 39 }; 40 41 var counterUpper = function () { 42 var nums = []; 43 var divisions = counter.time / counter.delay; 44 var num = $this.attr('data-num') ? $this.attr('data-num') : $this.text(); 45 var isComma = /[0-9]+,[0-9]+/.test(num); 46 num = num.replace(/,/g, ''); 47 var decimalPlaces = (num.split('.')[1] || []).length; 48 if (counter.beginAt > num) 49 counter.beginAt = num; 50 51 var isTime = /[0-9]+:[0-9]+:[0-9]+/.test(num); 52 53 // Convert time to total seconds 54 if (isTime) { 55 var times = num.split(':'), 56 m = 1; 57 s = 0; 58 while (times.length > 0) { 59 s += m * parseInt(times.pop(), 10); 60 m *= 60; 61 } 62 } 63 64 // Generate list of incremental numbers to display 65 for (var i = divisions; i >= counter.beginAt / num * divisions; i--) { 66 67 var newNum = parseFloat(num / divisions * i).toFixed(decimalPlaces); 68 69 // Add incremental seconds and convert back to time 70 if (isTime) { 71 newNum = parseInt(s / divisions * i); 72 var hours = parseInt(newNum / 3600) % 24; 73 var minutes = parseInt(newNum / 60) % 60; 74 var seconds = parseInt(newNum % 60, 10); 75 newNum = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds); 76 } 77 78 // Preserve commas if input had commas 79 if (isComma) { 80 while (/(\d+)(\d{3})/.test(newNum.toString())) { 81 newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2'); 82 } 83 } 84 if (settings.formatter) { 85 newNum = settings.formatter.call(this, newNum); 86 } 87 nums.unshift(newNum); 88 } 89 90 $this.data('counterup-nums', nums); 91 $this.text(counter.beginAt); 92 93 // Updates the number until we're done 94 var f = function () { 95 if (!$this.data('counterup-nums')) { 96 settings.callback.call(this); 97 return; 98 } 99 $this.html($this.data('counterup-nums').shift()); 100 if ($this.data('counterup-nums').length) { 101 setTimeout($this.data('counterup-func'), counter.delay); 102 } else { 103 $this.data('counterup-nums', null); 104 $this.data('counterup-func', null); 105 settings.callback.call(this); 106 } 107 }; 108 $this.data('counterup-func', f); 109 110 // Start the count up 111 setTimeout($this.data('counterup-func'), counter.delay); 112 }; 113 114 // Perform counts when the element gets into view 115 $this.waypoint(function (direction) { 116 counterUpper(); 117 this.destroy(); //-- Waypoint 3.0 version of triggerOnce 118 }, {offset: counter.offset + "%", context: counter.context}); 119 }); 120 121 }; 122 123})(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.