PageSourceSearch

https://ciihrconclave.com/js/jquery.countdown.js

js ciihrconclave.com collected 2026-09-29 03:38:56 UTC 3,177 bytes, 112 lines download raw bytes

1// CountDown Clock
2// Version   : 1.0.1
3// Developer : Ekrem KAYA
4// Website   : http://e-piksel.com
5// GitHub    : https://github.com/epiksel/countdown
6
7(function ($) {
8	$.fn.countdown = function (options, callback) {
9		var settings = $.extend({
10			date: null,
11			offset: null,
12			day: 'Day',
13			days: 'Days',
14			hour: 'Hour',
15			hours: 'Hours',
16			minute: 'Minute',
17			minutes: 'Minutes',
18			second: 'Second',
19			seconds: 'Seconds'
20		}, options);
21
22		// Throw error if date is not set
23		if (!settings.date) {
24			$.error('Date is not defined.');
25		}
26
27		// Throw error if date is set incorectly
28		if (!Date.parse(settings.date)) {
29			$.error('Incorrect date format, it should look like this, 12/24/2012 12:00:00.');
30		}
31
32		// Save container
33		var container = this;
34
35		/**
36		 * Change client's local date to match offset timezone
37		 * @return {Object} Fixed Date object.
38		 */
39		var currentDate = function () {
40			// get client's current date
41			var date = new Date();
42
43			// turn date to utc
44			var utc = date.getTime() + (date.getTimezoneOffset() * 60000);
45
46			// set new Date object
47			var new_date = new Date(utc + (3600000*settings.offset));
48
49			return new_date;
50		};
51
52		/**
53		 * Main countdown function that calculates everything
54		 */
55		function countdown () {
56			var target_date = new Date(settings.date), // set target date
57				current_date = currentDate(); // get fixed current date
58
59			// difference of dates
60			var difference = target_date - current_date;
61
62			// if difference is negative than it's pass the target date
63			if (difference < 0) {
64				// stop timer
65				clearInterval(interval);
66
67				if (callback && typeof callback === 'function') callback();
68
69				return;
70			}
71
72			// basic math variables
73			var _second = 1000,
74				_minute = _second * 60,
75				_hour = _minute * 60,
76				_day = _hour * 24;
77
78			// calculate dates
79			var days = Math.floor(difference / _day),
80				hours = Math.floor((difference % _day) / _hour),
81				minutes = Math.floor((difference % _hour) / _minute),
82				seconds = Math.floor((difference % _minute) / _second);
83		
84			// based on the date change the refrence wording
85			var text_days = (days === 1) ? settings.day : settings.days,
86				text_hours = (hours === 1) ? settings.hour : settings.hours,
87				text_minutes = (minutes === 1) ? settings.minute : settings.minutes,
88				text_seconds = (seconds === 1) ? settings.second : settings.seconds;
89
90				// fix dates so that it will show two digets
91				days = (String(days).length >= 2) ? days : '0' + days;
92				hours = (String(hours).length >= 2) ? hours : '0' + hours;
93				minutes = (String(minutes).length >= 2) ? minutes : '0' + minutes;
94				seconds = (String(seconds).length >= 2) ? seconds : '0' + seconds;
95
96			// set to DOM
97			container.find('.days').text(days);
98			container.find('.hours').text(hours);
99			container.find('.minutes').text(minutes);
100			container.find('.seconds').text(seconds);
101
102			container.find('.days_text').text(text_days);
103			container.find('.hours_text').text(text_hours);
104			container.find('.minutes_text').text(text_minutes);
105			container.find('.seconds_text').text(text_seconds);
106		}
107		
108		// start
109		var interval = setInterval(countdown, 1000);
110	};
111
112})(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.