1$.fn.countTo = function(options) { 2 options = options || {}; 3 return $(this).each(function() { 4 var settings = $.extend({}, 5 $.fn.countTo.defaults, { 6 from: $(this).data('from'), 7 to: $(this).data('to'), 8 speed: $(this).data('speed'), 9 refreshInterval: $(this).data('refresh-interval'), 10 decimals: $(this).data('decimals') 11 }, 12 options); 13 var loops = Math.ceil(settings.speed / settings.refreshInterval), 14 increment = (settings.to - settings.from) / loops; 15 var self = this, 16 $self = $(this), 17 loopCount = 0, 18 value = settings.from, 19 data = $self.data('countTo') || {}; 20 $self.data('countTo', data); 21 if (data.interval) { 22 clearInterval(data.interval); 23 } 24 data.interval = setInterval(updateTimer, settings.refreshInterval); 25 render(value); 26 function updateTimer() { 27 value += increment; 28 loopCount++; 29 render(value); 30 if (typeof(settings.onUpdate) == 'function') { 31 settings.onUpdate.call(self, value); 32 } 33 if (loopCount >= loops) { 34 $self.removeData('countTo'); 35 clearInterval(data.interval); 36 value = settings.to;
37 if (typeof(settings.onComplete) == 'function') { 38 settings.onComplete.call(self, value); 39 } 40 } 41 } 42 function render(value) { 43 var formattedValue = settings.formatter.call(self, value, settings); 44 //console.log(self, value, settings) 45 $self.html(formattedValue); 46 } 47 }); 48}; 49$.fn.countTo.defaults = { 50 from: 0, 51 to: 0, 52 speed: 1000, 53 refreshInterval: 100, 54 decimals: 0, 55 formatter: formatter, 56 onUpdate: null, 57 onComplete: null 58}; 59function formatter(value, settings) { 60 return value.toFixed(settings.decimals); 61} 62$('.count-number').each(function() { 63 var $this = $(this); 64 count.call($this); // 使ç¨.call()ç¡®ä¿thisæåå½åå ç´ 65}); 66 67function count() { 68 var $this = $(this); 69 var options = $.extend({}, 70 $.fn.countTo.defaults, 71 $this.data(), // 使ç¨$this.data()æ¥è·åæædata-*屿§ 72 $this.data('countToOptions') || {} // è¦çé»è®¤é项ådata-*屿§ 73 ); 74 $this.countTo(options); 75}
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.