PageSourceSearch

https://rtv.es.gov.br/Themes/HotsiteTheme/scripts/jquery-counterup/jquery.counterup-3.js?v=4

js rtv.es.gov.br collected 2026-10-03 21:46:03 UTC 3,528 bytes, 112 lines download raw bytes

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
10function pad(str, max) {
11    str = str.toString();
12    return str.length < max ? pad("0" + str, max) : str;
13}
14
15(function( $ ){
16  "use strict";
17
18  $.fn.counterUp = function( options ) {
19
20    // Defaults
21    var settings = $.extend({
22        'time': 400,
23        'delay': 10,
24        'european': false,
25        'delimeter': '.',
26        'padleft': 0,
27        'repeat': true // switch to false to destroy waypoint
28    }, options);
29
30    return this.each(function(){
31
32        // Store the object
33        var $this = $(this);
34        var $settings = settings;
35
36        var counterUpper = function() {
37            var nums = [];
38            var divisions = $settings.time / $settings.delay;
39            var num = $this.text();
40            num = $.trim(num);
41            var numLength = num.length;
42            var isComma = /[0-9]+.[0-9]+/.test(num);
43            num = num.replace(/\./g, '');
44            var isInt = /^[0-9]+$/.test(num);
45            var isFloat = /^[0-9]+\,[0-9]+$/.test(num);
46            var decimalPlaces = isFloat ? (num.split(',')[1] || []).length : 0;
47            var delimeter = $settings.delimeter;
48
49            if ($this.hasClass("space-delimeter")) {
50                delimeter = " ";
51            }
52
53            // Generate list of incremental numbers to display
54            for (var i = divisions; i >= 1; i--) {
55
56                // Preserve as int if input was int
57                num = num.replace(/,/g, '\.');
58                var newNum = parseInt(num / divisions * i);
59
60                // Preserve float if input was float
61                if (isFloat) {
62                    newNum = parseFloat(num / divisions * i).toFixed(decimalPlaces);
63                }
64
65                newNum = newNum.toString().replace(/\./g, ',');
66
67
68                // Preserve commas if input had commas
69                if (isComma) {
70                    while (/(\d+)(\d{3})/.test(newNum.toString())) {
71                        // ref: https://blog.abelotech.com/posts/number-currency-formatting-javascript/
72                        newNum = newNum.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + delimeter);
73                    }
74                }
75
76
77                nums.unshift(pad(newNum, numLength));
78            }
79
80            $this.data('counterup-nums', nums);
81            $this.text('0');
82
83            // Updates the number until we're done
84            var f = function() {
85                $this.text($this.data('counterup-nums').shift());
86                if ($this.data('counterup-nums').length) {
87                    setTimeout($this.data('counterup-func'), $settings.delay);
88                } else {
89                    delete $this.data('counterup-nums');
90                    $this.data('counterup-nums', null);
91                    $this.data('counterup-func', null);
92                }
93            };
94            $this.data('counterup-func', f);
95
96            // Start the count up
97            setTimeout($this.data('counterup-func'), $settings.delay);
98        };
99
100        // Perform counts when the element gets into view
101        $this.waypoint(function(){
102            counterUpper();
103
104            if (!$settings.repeat) {
105                this.destroy();
106            }
107        }, { offset: '100%', triggerOnce: true });
108    });
109
110  };
111
112})( 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.