PageSourceSearch

https://www.energy-omni.com/static/web/scripts/plugins/jquery.counterup.js

js energy-omni.com collected 2026-09-26 06:54:41 UTC 4,000 bytes, 111 lines download raw bytes

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