1/* 2 ** Plugin for counter shortcode 3 */ 4(function($) { 5 "use strict"; 6 7 $.fn.countTo = function(options) { 8 // merge the default plugin settings with the custom options 9 options = $.extend({}, $.fn.countTo.defaults, options || {}); 10 11 // how many times to update the value, and how much to increment the value on each update 12 var loops = Math.ceil(options.speed / options.refreshInterval), 13 increment = (options.to - options.from) / loops; 14 15 return $(this).each(function() { 16 var _this = this, 17 loopCount = 0, 18 value = options.from, 19 interval = setInterval(updateTimer, options.refreshInterval); 20 21 function updateTimer() { 22 value += increment; 23 loopCount++; 24 $(_this).html(value.toFixed(options.decimals)); 25 26 if (typeof(options.onUpdate) === 'function') { 27 options.onUpdate.call(_this, value); 28 } 29 30 if (loopCount >= loops) { 31 clearInterval(interval); 32 value = options.to; 33 34 if (typeof(options.onComplete) === 'function') { 35 options.onComplete.call(_this, value); 36 } 37 } 38 } 39 }); 40 }; 41 42 $.fn.countTo.defaults = { 43 from: 0, // the number the element should start at 44 to: 100, // the number the element should end at 45 speed: 1000, // how long it should take to count between the target numbers 46 refreshInterval: 100, // how often the element should be updated 47 decimals: 0, // the number of decimal places to show 48 onUpdate: null, // callback method for every time the element is updated, 49 onComplete: null // callback method for when the element finishes updating 50 }; 51})(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.