PageSourceSearch

https://anchukoegl.com/wp-content/themes/enfold/config-templatebui…/avia-shortcodes/numbers/numbers.js?ver=8.1

js anchukoegl.com collected 2026-09-24 17:38:58 UTC 3,705 bytes, 123 lines download raw bytes

1// -------------------------------------------------------------------------------------------
2// Big Number animation shortcode javascript
3// -------------------------------------------------------------------------------------------
4
5(function($)
6{
7	// options.simple_up = dont prepend leading zeros, options.instant_start = trigger counting instantly, options.start_timer = delay when to start counting
8	$.fn.avia_sc_animated_number = function(options)
9	{
10		if(!this.length) return;
11		if(this.is('.avia_sc_animated_number_active')) return;
12
13		this.addClass('avia_sc_animated_number_active');
14
15		var simple_upcount 	= (options && options.simple_up) ? true : false,
16			start_timer 	= (options && options.start_timer) ? options.start_timer : 300,
17
18			format_number = function( number, number_format, final_number )
19			{
20				var prepend = '',
21					addZeros = final_number.toString().length - number.toString().length;
22
23				//if the number has less digits than the final number some zeros where omitted. add them to the front
24				for(var i = addZeros; i > 0; i--)
25				{
26					prepend += '0';
27				}
28
29				number = ( simple_upcount ) ? number.toString() : prepend + number.toString();
30
31				if( '' == number_format )
32				{
33					return number;
34				}
35
36				return number.split( /(?=(?:...)*$)/ ).join( number_format );
37			},
38
39			start_count = function(element, countTo, increment, current, fakeCountTo, number_format)
40			{
41				//calculate the new number
42				var newCount = current + increment,
43					final = '';
44
45				//if the number is bigger than our final number set the number and finish
46				if(newCount >= fakeCountTo)
47				{
48					final = format_number( countTo, number_format, countTo );
49					element.text( final ); //exit
50				}
51				else
52				{
53					final = format_number( newCount, number_format, countTo );
54					element.text(final);
55
56					window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo, number_format); });
57				}
58			};
59
60		return this.each(function()
61		{
62			var number_container = $(this),
63				elements = number_container.find('.__av-single-number'),
64				countTimer = number_container.data('timer') || 3000;
65
66			//prepare elements
67			elements.each(function(i)
68			{
69				var element = $(this),
70					text = element.text();
71
72				if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
73			});
74
75			//trigger number animation
76			number_container.addClass('number_prepared').on('avia_start_animation', function()
77			{
78				if(number_container.is('.avia_animation_done')) return;
79				number_container.addClass('avia_animation_done');
80
81				elements.each(function(i)
82				{
83					var element = $(this),
84						countTo = element.data('number'),
85						fakeCountTo = countTo,
86						current = parseInt(element.text(),10),
87						zeroOnly = /^0+$/.test(countTo),
88						increment = 0,
89						number_format = '';
90
91					if( 'undefined' != typeof element.data('start_from') )
92					{
93						current = element.data('start_from');
94					}
95
96					if( 'undefined' != typeof element.data('number_format') )
97					{
98						number_format = element.data('number_format');
99					}
100
101					//fallback for decimals like 00 or 000
102					if( zeroOnly && countTo !== 0 )
103					{
104						fakeCountTo = countTo.replace( /0/g, '9' );
105					}
106
107					increment = Math.round( fakeCountTo * 32 / countTimer);
108					if(increment == 0 || increment % 10 == 0) increment += 1;
109
110					setTimeout( function(){ start_count(element, countTo, increment, current, fakeCountTo, number_format);}, start_timer);
111				});
112			});
113
114			if(options && options.instant_start == true)
115			{
116				number_container.trigger('avia_start_animation');
117			}
118
119
120		});
121	};
122})(jQuery);
123

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.