PageSourceSearch

https://apremierhealth.com/js/timer.js

js apremierhealth.com collected 2026-10-05 22:06:12 UTC 3,105 bytes, 96 lines download raw bytes

1//窗口显示才加载
2	var wrapTop = $(".c-timer").offset().top;
3	var istrue = true;
4	$(window).on("scroll",
5	function() {
6	    var s = $(window).scrollTop();
7	    if (s > wrapTop - 500 && istrue) {
8	        $(".timer").each(count);
9	        function count(a) {
10	            var b = $(this);
11	            a = $.extend({},
12	            a || {},
13	            b.data("countToOptions") || {});
14	            b.countTo(a)
15	        };
16	        istrue = false;
17	    };
18	})
19	//设置计数
20	$.fn.countTo = function (options) {
21		options = options || {};
22		return $(this).each(function () {
23			//当前元素的选项
24			var settings = $.extend({}, $.fn.countTo.defaults, {
25				from:            $(this).data('from'),
26				to:              $(this).data('to'),
27				speed:           $(this).data('speed'),
28				refreshInterval: $(this).data('refresh-interval'),
29				decimals:        $(this).data('decimals')
30			}, options);
31			//更新值
32			var loops = Math.ceil(settings.speed / settings.refreshInterval),
33			    increment = (settings.to - settings.from) / loops;
34			//更改应用和变量
35			var self = this,
36			$self = $(this),
37			loopCount = 0,
38			value = settings.from,
39			data = $self.data('countTo') || {};
40			$self.data('countTo', data);
41			//如果有间断,找到并清除
42			if (data.interval) {
43				clearInterval(data.interval);
44			};
45			data.interval = setInterval(updateTimer, settings.refreshInterval);
46			//初始化起始值
47			render(value);
48			function updateTimer() {
49				value += increment;
50				loopCount++;
51				render(value);
52				if (typeof(settings.onUpdate) == 'function') {
53					settings.onUpdate.call(self, value);
54				}
55				if (loopCount >= loops) {
56					//移出间隔
57					$self.removeData('countTo');
58					clearInterval(data.interval);
59					value = settings.to;
60					if (typeof(settings.onComplete) == 'function') {
61						settings.onComplete.call(self, value);
62					}
63				}
64			}
65			function render(value) {
66				var formattedValue = settings.formatter.call(self, value, settings);
67				$self.html(formattedValue);
68			}
69			});
70        };
71        $.fn.countTo.defaults={
72        	from:0,               //数字开始的值
73        	to:0,                 //数字结束的值
74        	speed:1000,           //设置步长的时间
75        	refreshInterval:100,  //隔间值
76        	decimals:0,           //显示小位数
77        	formatter: formatter, //渲染之前格式化
78        	onUpdate:null,        //每次更新前的回调方法
79        	onComplete:null       //完成更新的回调方法
80        };
81        function formatter(value, settings){
82        	return value.toFixed(settings.decimals);
83        }
84        //自定义格式
85        $('#count-number').data('countToOptions',{
86        	formmatter:function(value, options){
87        		return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
88        	}
89        });
90        //定时器
91        $('.timer').each(count);
92        function count(options){
93        	var $this=$(this);
94        	options=$.extend({}, options||{}, $this.data('countToOptions')||{});
95        	$this.countTo(options);
96        }

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.