PageSourceSearch

https://www.gesturbo.ru/fileadmin/templates/default/js/ms-countup.js?1734614363

js gesturbo.ru collected 2026-10-08 18:24:59 UTC 7,828 bytes, 92 lines download raw bytes

1/**
2@ includes:	
3	- https://github.com/protonet/jquery.inview
4	- http://pantrif.github.io/countUp.js/
5
6**/
7
8window.msCountJS = {
9	contSelector: '.countJS, .factoid', 
10	numberSelector: 'h1,h2,h3,h4',
11	start: 0,
12	duration: 1.5,
13	options: {
14		separator: ' ',
15		decimal: ',',
16	}  
17};
18
19
20// ready
21$(function() {
22	// temp todo > dont init in EN version yet
23	if (window.lang == 'en') {
24		return false;
25	}
26	
27	$(window.msCountJS.contSelector).each(function(){
28		initCountJs($(this)); 
29	}); 
30	 
31// ready > end
32});
33
34//////////////////////////////////////////////////////////////////////
35// function > init bind etc
36function initCountJs($cont) {
37	// 0. if disabled @2024
38	if ($cont.hasClass('nocount')) {
39		return false;
40	}
41	// 1. prepare numbers (setup return false if setup failed)
42	var countUp = setupCountJs($cont);
43	if (countUp) {
44		// 2. set up tracking
45		$cont.one('inview', function(event, isInView) {
46			if (isInView) {
47				// element is now visible in the viewport > fire
48				countUp.start();
49			} else {
50				// element has gone out of viewport
51			}		
52		});
53	}	
54}
55//////////////////////////////////////////////////////////////////////
56// function > setup numbers and count up options > if no number return false
57function setupCountJs($cont) {
58	// 1. find number within container (only in headers, first only)
59	var numRaw = $cont
60		.find(window.msCountJS.numberSelector)
61		.text()
62		.match(/[\d|,|\s]+/g)[0]
63		.trim();
64	
65	// 2. locate number and wrap number
66	var $numCont = $cont.find(window.msCountJS.numberSelector + ':contains('+ numRaw +')');
67	$numCont.html($numCont.html().replace(numRaw, '<span class="countUp">' + numRaw + '</span>'));
68	
69	// 3. analize number and init countUp.js on it
70	var $num = $numCont.find('.countUp');
71	var num = Number(numRaw.replace(' ', '').replace(',', '.'));
72
73// 3.1. if not number or 0 -> return false	
74if (num === NaN || num === 0) return false;
75	
76	var _decimals = num.toString();
77	_decimals = _decimals.indexOf('.') > 0  ? _decimals.length - _decimals.indexOf('.') - 1 : 0;
78	
79	
80	return new CountUp($num.get(0), 0, num, _decimals, window.msCountJS.duration, window.msCountJS.options);
81}
82
83
84////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
85// @ includes
86	// 1. https://github.com/protonet/jquery.inview 
87
88!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function i(){var b,c,d={height:f.innerHeight,width:f.innerWidth};return d.height||(b=e.compatMode,(b||!a.support.boxModel)&&(c="CSS1Compat"===b?g:e.body,d={height:c.clientHeight,width:c.clientWidth})),d}function j(){return{top:f.pageYOffset||g.scrollTop||e.body.scrollTop,left:f.pageXOffset||g.scrollLeft||e.body.scrollLeft}}function k(){if(b.length){var e=0,f=a.map(b,function(a){var b=a.data.selector,c=a.$element;return b?c.find(b):c});for(c=c||i(),d=d||j();e<b.length;e++)if(a.contains(g,f[e][0])){var h=a(f[e]),k={height:h[0].offsetHeight,width:h[0].offsetWidth},l=h.offset(),m=h.data("inview");if(!d||!c)return;l.top+k.height>d.top&&l.top<d.top+c.height&&l.left+k.width>d.left&&l.left<d.left+c.width?m||h.data("inview",!0).trigger("inview",[!0]):m&&h.data("inview",!1).trigger("inview",[!1])}}}var c,d,h,b=[],e=document,f=window,g=e.documentElement;a.event.special.inview={add:function(c){b.push({data:c,$element:a(this),element:this}),!h&&b.length&&(h=setInterval(k,250))},remove:function(a){for(var c=0;c<b.length;c++){var d=b[c];if(d.element===this&&d.data.guid===a.guid){b.splice(c,1);break}}b.length||(clearInterval(h),h=null)}},a(f).on("scroll resize scrollstop",function(){c=d=null}),!g.addEventListener&&g.attachEvent&&g.attachEvent("onfocusin",function(){d=null})});
89
90
91	// 2. http://pantrif.github.io/countUp.js/
92!function(a,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n(require,exports,module):a.CountUp=n()}(this,function(a,n,t){var e=function(a,n,t,e,i,r){function o(a){a=a.toFixed(l.decimals),a+="";var n,t,e,i,r,o;
92if(n=a.split("."),t=n[0],e=n.length>1?l.options.decimal+n[1]:"",l.options.useGrouping){for(i="",r=0,o=t.length;r<o;++r)0!==r&&r%3===0&&(i=l.options.separator+i),i=t[o-r-1]+i;t=i}return l.options.numerals.length&&(t=t.replace(/[0-9]/g,function(a){return l.options.numerals[+a]}),e=e.replace(/[0-9]/g,function(a){return l.options.numerals[+a]})),l.options.prefix+t+e+l.options.suffix}function u(a,n,t,e){return t*(-Math.pow(2,-10*a/e)+1)*1024/1023+n}function s(a){return"number"==typeof a&&!isNaN(a)}var l=this;if(l.version=function(){return"1.9.2"},l.options={useEasing:!0,useGrouping:!0,separator:",",decimal:".",easingFn:u,formattingFn:o,prefix:"",suffix:"",numerals:[]},r&&"object"==typeof r)for(var m in l.options)r.hasOwnProperty(m)&&null!==r[m]&&(l.options[m]=r[m]);""===l.options.separator?l.options.useGrouping=!1:l.options.separator=""+l.options.separator;for(var d=0,c=["webkit","moz","ms","o"],f=0;f<c.length&&!window.requestAnimationFrame;++f)window.requestAnimationFrame=window[c[f]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[c[f]+"CancelAnimationFrame"]||window[c[f]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(a,n){var t=(new Date).getTime(),e=Math.max(0,16-(t-d)),i=window.setTimeout(function(){a(t+e)},e);return d=t+e,i}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){clearTimeout(a)}),l.initialize=function(){return!!l.initialized||(l.error="",l.d="string"==typeof a?document.getElementById(a):a,l.d?(l.startVal=Number(n),l.endVal=Number(t),s(l.startVal)&&s(l.endVal)?(l.decimals=Math.max(0,e||0),l.dec=Math.pow(10,l.decimals),l.duration=1e3*Number(i)||2e3,l.countDown=l.startVal>l.endVal,l.frameVal=l.startVal,l.initialized=!0,!0):(l.error="[CountUp] startVal ("+n+") or endVal ("+t+") is not a number",!1)):(l.error="[CountUp] target is null or undefined",!1))},l.printValue=function(a){var n=l.options.formattingFn(a);"INPUT"===l.d.tagName?this.d.value=n:"text"===l.d.tagName||"tspan"===l.d.tagName?this.d.textContent=n:this.d.innerHTML=n},l.count=function(a){l.startTime||(l.startTime=a),l.timestamp=a;var n=a-l.startTime;l.remaining=l.duration-n,l.options.useEasing?l.countDown?l.frameVal=l.startVal-l.options.easingFn(n,0,l.startVal-l.endVal,l.duration):l.frameVal=l.options.easingFn(n,l.startVal,l.endVal-l.startVal,l.duration):l.countDown?l.frameVal=l.startVal-(l.startVal-l.endVal)*(n/l.duration):l.frameVal=l.startVal+(l.endVal-l.startVal)*(n/l.duration),l.countDown?l.frameVal=l.frameVal<l.endVal?l.endVal:l.frameVal:l.frameVal=l.frameVal>l.endVal?l.endVal:l.frameVal,l.frameVal=Math.round(l.frameVal*l.dec)/l.dec,l.printValue(l.frameVal),n<l.duration?l.rAF=requestAnimationFrame(l.count):l.callback&&l.callback()},l.start=function(a){l.initialize()&&(l.callback=a,l.rAF=requestAnimationFrame(l.count))},l.pauseResume=function(){l.paused?(l.paused=!1,delete l.startTime,l.duration=l.remaining,l.startVal=l.frameVal,requestAnimationFrame(l.count)):(l.paused=!0,cancelAnimationFrame(l.rAF))},l.reset=function(){l.paused=!1,delete l.startTime,l.initialized=!1,l.initialize()&&(cancelAnimationFrame(l.rAF),l.printValue(l.startVal))},l.update=function(a){if(l.initialize()){if(a=Number(a),!s(a))return void(l.error="[CountUp] update() - new endVal is not a number: "+a);l.error="",a!==l.frameVal&&(cancelAnimationFrame(l.rAF),l.paused=!1,delete l.startTime,l.startVal=l.frameVal,l.endVal=a,l.countDown=l.startVal>l.endVal,l.rAF=requestAnimationFrame(l.count))}},l.initialize()&&l.printValue(l.startVal)};return e});

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.