PageSourceSearch

https://www.whittleseashow.org.au/wp-content/plugins/countdown-tim…/assets/js/wpcdt-public.js?ver=2.6.9

js whittleseashow.org.au collected 2026-10-02 11:27:58 UTC 5,978 bytes, 191 lines download raw bytes

1(function($) {
2
3	'use strict';
4
5	/* Initialize Countdown Timer */
6	wpcdt_all_timer_init();
7
8	/* Beaver Builder Compatibility for Accordion & Tab */
9	$(document).on('click', '.fl-accordion-button, .fl-tabs-label', function() {
10
11		var ele_control	= $(this).attr('aria-controls');
12		var timer_wrap	= $('#'+ele_control).find('.wpcdt-timer-circle');
13
14		/* Tweak for countdown timer */
15		$( timer_wrap ).each(function( index ) {
16
17			var timer_id	= $(this).find('.wpcdt-timer-js').attr('id');
18				timer_id	= timer_id + ' .wpcdt-clock-circle';
19
20			if( typeof(timer_id) !== 'undefined' && timer_id != '' ) {
21				setTimeout(function() {
22					$('#'+timer_id).TimeCircles().rebuild();
23				}, 300);
24			}
25		});
26	});
27
28	/* Visual Composer Compatibility for Toggle */
29	$(document).on('click', '.vc_toggle', function() {
30
31		var timer_wrap	= $(this).find('.vc_toggle_content .wpcdt-timer-circle');
32
33		$( timer_wrap ).each(function( index ) {
34
35			var timer_id	= $(this).find('.wpcdt-timer-js').attr('id');
36				timer_id	= timer_id + ' .wpcdt-clock-circle';
37
38			if( typeof(timer_id) !== 'undefined' && timer_id != '' ) {
39				$('#'+timer_id).TimeCircles().rebuild();
40			}
41		});
42	});
43
44	/* Visual Composer Compatibility for Tabs & Accordion */
45	$(document).on('click', '.vc_tta-panel-title', function() {
46
47		var cls_ele		= $(this).closest('.vc_tta-panel');
48		var timer_wrap	= cls_ele.find('.wpcdt-timer-circle');
49
50		$( timer_wrap ).each(function( index ) {
51
52			var timer_id	= $(this).find('.wpcdt-timer-js').attr('id');
53				timer_id	= timer_id + ' .wpcdt-clock-circle';
54
55			if( typeof(timer_id) !== 'undefined' && timer_id != '' ) {
56				$('#'+timer_id).TimeCircles().rebuild();
57			}
58		});
59	});
60
61	/* Divi Builder Compatibility for Tabs, Accordion & Toggle */
62	$(document).on('click', '.et_pb_toggle', function() {
63
64		var acc_cont	= $(this).find('.et_pb_toggle_content');
65		var timer_wrap	= acc_cont.find('.wpcdt-timer-circle');
66
67		/* Tweak for slick slider */
68		$( timer_wrap ).each(function( index ) {
69
70			var timer_id	= $(this).find('.wpcdt-timer-js').attr('id');
71				timer_id	= timer_id + ' .wpcdt-clock-circle';
72
73			$('#'+timer_id).css({'visibility': 'hidden', 'opacity': 0});
74
75			if( typeof(timer_id) !== 'undefined' && timer_id != '' ) {
76				jQuery('#'+timer_id).TimeCircles().rebuild();
77				$('#'+timer_id).css({'visibility': 'visible', 'opacity': 1});
78			}
79		});
80	});
81})(jQuery);
82
83/* Function to initialize all the timer */
84function wpcdt_all_timer_init() {
85
86	/* Circle Style 1 Timer initialize */
87	jQuery( '.wpcdt-timer-circle .wpcdt-clock-circle' ).each( function( index ) {
88
89		var cls_ele			= jQuery(this).closest('.wpcdt-timer-wrap');
90		var timer_conf		= JSON.parse( cls_ele.attr('data-conf') );
91		var timer_id		= cls_ele.find('.wpcdt-timer-js').attr('id');
92			timer_id		= timer_id + ' .wpcdt-clock-circle';
93		var current_date	= new Date( timer_conf.current_date );
94		var expiry_date		= new Date( timer_conf.expiry_date );
95
96		/* Check Timer Initialize Class */
97		if( jQuery('#'+timer_id).hasClass('wpcdt-timer-initialized') ) {
98			return;
99		}
100
101		var difference		= wpcdt_date_diff( current_date, expiry_date );
102		var total_seconds	= difference.total_seconds;
103
104		jQuery('#'+timer_id).TimeCircles({
105			'animation'			: timer_conf.timercircle_animation,
106			'bg_width'			: ( timer_conf.timer_bg_width != '' )		? timer_conf.timer_bg_width		: 1.2,
107			'fg_width'			: ( timer_conf.timercircle_width != '' )	? timer_conf.timercircle_width	: 0.1,
108			'circle_bg_color'	: ( timer_conf.timer_bgclr != '' )			? timer_conf.timer_bgclr		: '#313332',
109			'time'				: {
110									'Days'		: {
111													'text'	: timer_conf.day_text,
112													'color'	: timer_conf.timer_day_bgclr,
113													'show'	: ( timer_conf.is_days == 1 ) ? true : false,
114												},
115									'Hours'		: {
116													'text'	: timer_conf.hour_text,
117													'color'	: timer_conf.timer_hour_bgclr,
118													'show'	: ( timer_conf.is_hours == 1 ) ? true : false,
119												},
120									'Minutes'	: {
121													'text'	: timer_conf.minute_text,
122													'color'	: timer_conf.timer_minute_bgclr,
123													'show'	: ( timer_conf.is_minutes == 1 ) ? true : false,
124												},
125									'Seconds'	: {
126													'text'	: timer_conf.second_text,
127													'color'	: timer_conf.timer_second_bgclr,
128													'show'	: ( timer_conf.is_seconds == 1 ) ? true : false,
129												},
130								},
131		});
132
133		jQuery("#"+timer_id).TimeCircles().addListener( wpcdt_timer_complete );
134		jQuery("#"+timer_id).addClass('wpcdt-timer-initialized');
135
136		/* Timer complete function */
137		function wpcdt_timer_complete( unit, value, total_seconds ) {
138
139			/* Need to stop timer otherwise it will start again on screen resize */
140			if( total_seconds <= 0 ) {
141				jQuery('#'+timer_id).TimeCircles().stop();
142			}
143		}
144
145		jQuery(window).on('resize', function() {
146			jQuery('#'+timer_id).TimeCircles().rebuild();
147		});
148	});
149}
150
151/* Function to get difference between two dates */
152function wpcdt_date_diff( current_date, expiry_date ) {
153	material					= [];
154	material['days']			= 0;
155	material['hours']			= 0;
156	material['minutes']			= 0;
157	material['seconds']			= 0;
158	material['total_seconds']	= 0;
159
160	if( expiry_date > current_date ) {
161
162		// get total seconds between the times
163		var delta = Math.abs( expiry_date - current_date ) / 1000;
164
165		// calculate (and subtract) whole days
166		var days			= Math.floor( delta / 86400 );
167		delta				-= days * 86400;
168		material['days']	= days;
169
170		// calculate (and subtract) whole hours
171		var hours			= Math.floor( delta / 3600 ) % 24;
172		delta				-= hours * 3600;
173		material['hours']	= hours;
174
175		// calculate (and subtract) whole minutes
176		var minutes			= Math.floor( delta / 60 ) % 60;
177		delta				-= minutes * 60;
178		material['minutes']	= minutes;
179
180		// what's left is seconds
181		var seconds			= delta % 60;
182		material['seconds']	= seconds;
183
184		var total_seconds			= ( expiry_date.getTime() - current_date.getTime() ) / 1000;
185		material['total_seconds']	= total_seconds;
186
187		return material;
188	}
189
190	return material;
191}

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.