PageSourceSearch

https://www.frank.nl/wp-content/themes/rehub-theme/js/countdown.js?ver=1.1

js frank.nl collected 2026-10-05 18:10:38 UTC 4,161 bytes, 152 lines download raw bytes

1/*!
2 * jQuery Countdown plugin v1.0
3 * http://www.littlewebthings.com/projects/countdown/
4 *
5 * Copyright 2010, Vassilis Dourdounis
6 * Copyright 2010, Marcello Barnaba <[email protected]>
7 * 
8 */
9(function($) {
10
11	$.fn.countDown = function (options) {
12		// Public methods invocation
13		//
14		if (typeof options == 'string') {
15			return $(this).data('countDown')[options].apply(this) || this;
16		}
17
18		return this.each (function () {
19			// Initialization
20			//
21			var element = $(this), targetTime = new Date(), timer;
22
23			if (element.data ('countDown'))
24				return; // Already initialized
25
26			if (options.targetDate)
27			{
28				targetTime = new Date(
29					options.targetDate.month + '/' + options.targetDate.day + '/' + options.targetDate.year + ' ' +
30					options.targetDate.hour + ':' + options.targetDate.min + ':' + options.targetDate.sec +
31					(options.targetDate.utc ? ' UTC' : '')
32				);
33			}
34			else if (options.targetOffset)
35			{
36				targetTime.setFullYear(options.targetOffset.year + targetTime.getFullYear());
37				targetTime.setMonth(options.targetOffset.month   + targetTime.getMonth());
38				targetTime.setDate(options.targetOffset.day      + targetTime.getDate());
39				targetTime.setHours(options.targetOffset.hour    + targetTime.getHours());
40				targetTime.setMinutes(options.targetOffset.min   + targetTime.getMinutes());
41				targetTime.setSeconds(options.targetOffset.sec   + targetTime.getSeconds());
42			}
43
44			element.find('.digit').html('<div class="top"></div><div class="bottom"></div>');
45
46			// Public methods definition
47			//
48			element.data ('countDown', {
49				stop: function () {
50					if (timer == undefined)
51						return;
52
53					clearInterval(timer);
54					timer = undefined
55				},
56
57				start: function () {
58					if (timer != undefined)
59						return;
60
61					if(options.currenttime){
62						var currenttime = new Date(options.currenttime);
63					}else{
64						var currenttime = new Date();
65					}
66					//console.log(currenttime);
67					var diffSecs = Math.floor((+targetTime - currenttime)/1000);
68					var duration = 500;
69
70					if (diffSecs < 0)
71						diffSecs = 0;
72
73					var loop = function () {
74						render(diffSecs, duration);
75						diffSecs -= 1;
76					}
77
78					loop();
79					if (diffSecs > 0)
80						timer = setInterval (loop, 1000)
81				}
82			});
83
84			// Private method to render the whole thing
85			//
86			function render (diffSecs, duration) {
87				secs = diffSecs % 60;
88				mins = Math.floor(diffSecs/60)%60;
89				hours = Math.floor(diffSecs/60/60)%24;
90				if (options.omitWeeks)
91				{
92					days = Math.floor(diffSecs/60/60/24);
93					weeks = Math.floor(diffSecs/60/60/24/7);
94				}
95				else
96				{
97					days = Math.floor(diffSecs/60/60/24)%7;
98					weeks = Math.floor(diffSecs/60/60/24/7);
99				}
100
101				dashChangeTo('.seconds_dash', secs,  duration);
102				dashChangeTo('.minutes_dash', mins,  duration);
103				dashChangeTo('.hours_dash',   hours, duration);
104				dashChangeTo('.days_dash',    days,  duration);
105				dashChangeTo('.weeks_dash',   weeks, duration);
106
107				if (diffSecs <= 0)
108					complete();
109			}
110
111			// Privat method invoked by render() when the countdown is over
112			//
113			function complete() {
114				element.data('countDown').stop ();
115
116				if (options.onComplete)
117					options.onComplete.apply(element);
118
119				return true;
120			}
121
122			// Private method to update a single digit couple
123			//
124			function dashChangeTo (selector, n, duration) {
125				element.find (selector + ' .digit').each (function (i) {
126					// The first digit is i=0, the second i=1
127					digitChangeTo($(this), i == 0 ? Math.floor(n/10) : n%10, duration);
128				})
129			};
130
131			// Private method to update a single digit
132			//
133			function digitChangeTo (digit, n, duration) {
134				var top = digit.find('.top'),
135						bot = digit.find('.bottom');
136
137				if (top.html() != n + '')
138				{
139					top.html(n || '0').slideDown(duration);
140
141					bot.animate({height: 0}, duration, function() {
142						bot.html(n || '0').css({height: '100%'});
143						top.hide();
144					});
145				}
146			};
147
148			element.data('countDown').start();
149		});
150	};
151
152})(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.