PageSourceSearch

https://www.todopatuweb.net/wp-content/themes/numismatico/js/jquery.countTo.js?ver=1.0.0

js todopatuweb.net collected 2026-09-25 22:55:41 UTC 3,144 bytes, 84 lines download raw bytes

1
2/*
3 * 10. jQuery.countTo
4*/
5(function ($) {
6    $.fn.countTo = function (options) {
7        options = options || {};
8
9        return $(this).each(function () {
10            // set options for current element
11            var settings = $.extend({}, $.fn.countTo.defaults, {
12                from:            $(this).data('from'),
13                to:              $(this).data('to'),
14                speed:           $(this).data('speed'),
15                refreshInterval: $(this).data('refresh-interval'),
16                decimals:        $(this).data('decimals')
17            }, options);
18
19            // how many times to update the value, and how much to increment the value on each update
20            var loops = Math.ceil(settings.speed / settings.refreshInterval),
21                increment = (settings.to - settings.from) / loops;
22
23            // references & variables that will change with each update
24            var self = this,
25                $self = $(this),
26                loopCount = 0,
27                value = settings.from,
28                data = $self.data('countTo') || {};
29
30            $self.data('countTo', data);
31
32            // if an existing interval can be found, clear it first
33            if (data.interval) {
34                clearInterval(data.interval);
35            }
36            data.interval = setInterval(updateTimer, settings.refreshInterval);
37
38            // initialize the element with the starting value
39            render(value);
40
41            function updateTimer() {
42                value += increment;
43                loopCount++;
44
45                render(value);
46
47                if (typeof(settings.onUpdate) == 'function') {
48                    settings.onUpdate.call(self, value);
49                }
50
51                if (loopCount >= loops) {
52                    // remove the interval
53                    $self.removeData('countTo');
54                    clearInterval(data.interval);
55                    value = settings.to;
56
57                    if (typeof(settings.onComplete) == 'function') {
58                        settings.onComplete.call(self, value);
59                    }
60                }
61            }
62
63            function render(value) {
64                var formattedValue = settings.formatter.call(self, value, settings);
65                $self.text(formattedValue);
66            }
67        });
68    };
69
70    $.fn.countTo.defaults = {
71        from: 0,               // the number the element should start at
72        to: 0,                 // the number the element should end at
73        speed: 1000,           // how long it should take to count between the target numbers
74        refreshInterval: 100,  // how often the element should be updated
75        decimals: 0,           // the number of decimal places to show
76        formatter: formatter,  // handler for formatting the value before rendering
77        onUpdate: null,        // callback method for every time the element is updated
78        onComplete: null       // callback method for when the element finishes updating
79    };
80
81    function formatter(value, settings) {
82        return value.toFixed(settings.decimals);
83    }
84}(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.