PageSourceSearch

https://hospicefoundation.org/wp-content/plugins/donation-for-wooc…/frontend.js?ver=3.9.8%26t%3D01102026054858

js hospicefoundation.org collected 2026-10-02 02:59:55 UTC 35,524 bytes, 937 lines download raw bytes

1$ = jQuery;
2
3let flag = true;
4
5if ( jQuery("form.woocommerce-checkout").length > 0 && !( jQuery("form.woocommerce-checkout").hasClass('wc-roundoff')  )  ) {
6	jQuery("form.woocommerce-checkout").addClass('wc-roundoff');
7}
8dispaly_socialshare_links( jQuery );
9jQuery(window).on('load', function(){
10	if ( wcOrderScript.donationToOrder.is_checkout && wcOrderScript.donationToOrder.is_roundOff == 'yes' ) {
11		jQuery( '.wc-block-components-checkout-place-order-button' ).on('click', function (e) {
12			if ( flag ) {
13				e.stopPropagation();
14				add_popup_before_order();
15			}
16		});
17	}
18});
19
20jQuery(window).on('load', function(){
21
22
23	jQuery('.flip-clock').each(function() {
24		var clockElement = jQuery(this);
25		var clock;
26		var startTimeStr = jQuery(this).data('start-time');
27		var endTimeStr = jQuery(this).data('end-time');
28		var endTimeArr = endTimeStr.split(':'); // Split the time string into hours and minutes
29		var startTimeArr = startTimeStr.split(':'); // Split the start time string into hours and minutes
30		var now = new Date();
31
32		// Set the start and end times to today with the provided hours and minutes
33		var startTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(startTimeArr[0]), parseInt(startTimeArr[1]), 0);
34		var endTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(endTimeArr[0]), parseInt(endTimeArr[1]), 0);
35
36		// If the end time is before the current time, set it to tomorrow with the same hours and minutes
37		if (endTime.getTime() < now.getTime()) {
38			endTime.setDate(endTime.getDate() + 1);
39		}
40
41		var diff = endTime.getTime() / 1000 - now.getTime() / 1000;
42		diff = Math.max(diff, 0);
43		clockElement.addClass('non-clickable');
44		clock = jQuery(this).FlipClock(diff, {
45			clockFace: 'HourlyCounter',
46			countdown: true
47		});
48		console.log('startTime');
49		console.log(startTime);
50		console.log('endTime');
51		console.log(endTime);
52
53		// Check the remaining time and start time every second
54		var interval = setInterval(function() {
55			now = new Date();
56			var remainingTime = clock.getTime().time;
57
58			if (remainingTime <= 0) {
59				clearInterval(interval);
60				console.log('Reloading page');
61				location.reload(); // Reload the page
62			}
63		}, 1000);
64
65		// To forcefully set the remaining time to the clock instance
66		clock.setTime(diff);
67		clock.start();
68	});
69
70
71	// Initialize Pomodoro clock instances
72	jQuery('.pomodoro-clock-container').each(function () {
73		var container = this;
74		var timerLabel = jQuery(container).find('.timer-label');
75		var startTimeStr = jQuery(this).data('start-time');
76		var endTimeStr = jQuery(this).data('end-time');
77
78		var startTimeParts = startTimeStr.split(':');
79		var endTimeParts = endTimeStr.split(':');
80
81		var now = new Date();
82		var start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), startTimeParts[0], startTimeParts[1], 0);
83		var end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), endTimeParts[0], endTimeParts[1], 0);
84
85		if (end < start) {
86			end.setDate(end.getDate() + 1);
87		}
88
89		var duration = (end - start) / 1000;
90		var elapsedTime = (now - start) / 1000;
91		var remainingTime = duration - elapsedTime;
92
93		var storedRemainingTime = localStorage.getItem('remainingTime');
94		var lastSaved = localStorage.getItem('lastSaved');
95		if (storedRemainingTime && lastSaved) {
96			var elapsedSinceLastSave = (now.getTime() - new Date(lastSaved).getTime()) / 1000;
97			remainingTime = Math.max(0, storedRemainingTime - elapsedSinceLastSave);
98		}
99
100		var totalSecondsInDay = 24 * 60 * 60;
101		remainingTime = remainingTime % totalSecondsInDay;
102
103		var bar = new ProgressBar.Circle(container, {
104			color: '#EFBBBE',
105			trailColor: '#BF5252',
106			trailWidth: 5,
107			duration: remainingTime * 1000,
108			easing: 'linear',
109			strokeWidth: 5,
110			from: { color: '#EFBBBE', width: 5 },
111			to: { color: '#EFBBBE', width: 5 },
112			step: function (state, circle) {
113				var elapsed = (1.0 - circle.value()) * duration;
114				var remaining = Math.max(duration - elapsed, 0);
115				timerLabel.text(formatDuration(remaining));
116				circle.path.setAttribute('stroke', state.color);
117				circle.path.setAttribute('stroke-width', state.width);
118			}
119		});
120
121		function updateProgressBar() {
122			bar.set(remainingTime / duration);
123			if (remainingTime <= 0) {
124				clearInterval(progressInterval);
125			}
126		}
127
128		var progressInterval = setInterval(updateProgressBar, 1100);
129
130		var interval = setInterval(function () {
131			now = new Date();
132			elapsedTime = (now - start) / 1000;
133			remainingTime = Math.max(duration - elapsedTime, 0);
134			remainingTime = remainingTime % totalSecondsInDay;
135			timerLabel.text(formatDuration(remainingTime));
136
137			localStorage.setItem('remainingTime', remainingTime);
138			localStorage.setItem('lastSaved', new Date().toISOString());
139
140			if (remainingTime <= 1) {
141				clearInterval(interval);
142				location.reload();
143			}
144		}, 1000);
145
146		jQuery(window).on('beforeunload', function () {
147			now = new Date();
148			elapsedTime = (now - start) / 1000;
149			remainingTime = Math.max(duration - elapsedTime, 0);
150			remainingTime = remainingTime % totalSecondsInDay;
151			localStorage.setItem('remainingTime', remainingTime);
152			localStorage.setItem('lastSaved', new Date().toISOString());
153		});
154	});
155
156	jQuery('<style>')
157		.prop('type', 'text/css')
158		.html('\
159        .flip-clock-wrapper .flip-clock-days {\
160            display: none;\
161        }\
162    ')
163		.appendTo('head');
164});
165
166function formatTime(date) {
167	var hours = date.getHours();
168	var minutes = date.getMinutes();
169	return (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
170}
171
172function formatDuration(seconds) {
173	var hours = Math.floor(seconds / 3600);
174	seconds %= 3600;
175	var minutes = Math.floor(seconds / 60);
176	var sec = Math.floor(seconds % 60);
177	return (hours < 10 ? '0' : '') + hours + ':' +
178		(minutes < 10 ? '0' : '') + minutes + ':' +
179		(sec < 10 ? '0' : '') + sec;
180}
181//WC Donation Tabs Frontend
182jQuery(document).on('click', '.wc-donation-tabs-wrap ul.tab-nav > li', function(event) {
183	event.preventDefault();
184	jQuery(this).siblings().removeClass('active');
185	jQuery(this).addClass('active');
186	var content = jQuery(this).data('tab');
187	jQuery('.wc-donation-tab-content').removeClass('active');
188	jQuery(`.wc-donation-tab-content.${content}`).addClass('active');
189});
190
191function add_popup_before_order () {
192	jQuery.ajax({
193		url: wcOrderScript.donationToOrder.ajaxUrl,
194		type: "POST",
195		dataType: "json",
196		data: {
197			action: 'add_popup_before_order',
198			nonce: wcOrderScript.donationToOrder.nonce
199		},
200		beforeSend: function () {
201			//if loader needs to add put here
202		},
203		success: function (response) {
204			if (response['status']=='success') {
205				jQuery(".wc-donation-popup").find("#wc-donation-price-" + response['campaign_id']).val(response['donation']);
206				var text = jQuery(".wc-donation-popup").find(".donation_text").text();
207				var res = text.replace("%amount%", response['donation']);
208				jQuery(".wc-donation-popup").find(".donation_text").text(res);
209				jQuery(".wc-donation-popup:not(.cart-campaign-popup)").addClass('wc-popup-show');
210			} else {
211				flag = false;
212				jQuery( '.wc-block-components-checkout-place-order-button' ).trigger('click');
213				jQuery("form.woocommerce-checkout").submit();
214			}
215		}
216	});
217}
218
219if ( wcOrderScript.donationToOrder.is_checkout && ! wcOrderScript.donationToOrder.is_order_pay ) {
220	/* when click on place order*/
221	jQuery( document ).on(
222		"click",
223		"#place_order",
224		function (e) {
225			//console.log( wcOrderScript.donationToOrder.is_checkout );
226			if ( wcOrderScript.donationToOrder.is_checkout && wcOrderScript.donationToOrder.is_roundOff == 'yes' ) {
227				e.preventDefault();
228				//debugger;
229				add_popup_before_order();
230			}
231		}
232	);
233}
234
235function NumbersOnly(myfield, e, dec) {
236	/*if ( isNaN(removeCommas(myfield.value)) && myfield.value != "-") {
237        return false;
238	}*/
239	// console.log(min);
240	// console.log(max);
241
242	// var priceEl = document.getElementById('wc-donation-price-' + id);
243	var allowNegativeNumber = false;
244	var key;
245	var keychar;
246
247	if (window.event)
248		key = window.event.keyCode;
249	else if (e)
250		key = e.which;
251	else
252		return true;
253	keychar = String.fromCharCode(key);
254	var srcEl = e.srcElement ? e.srcElement : e.target;
255
256	// if (typeof(priceEl) != 'undefined' && priceEl != null) {
257
258	// 	priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : '';
259	// }
260	// control keys
261	if ((key == null) || (key == 0) || (key == 9) || (key == 13) || (key == 27) ) {
262		return true;
263	}
264
265	// if ( min != '' && max != '' ) {
266	// 	if ( ( parseFloat(myfield.value) >= min) && ( parseFloat(myfield.value) <= max) ) {
267	// 		if (typeof(priceEl) != 'undefined' && priceEl != null) {
268	// 			priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : '';
269	// 		}
270	// 		return true;
271	// 	} else {
272	// 		myfield.value = '';
273	// 		if (typeof(priceEl) != 'undefined' && priceEl != null) {
274	// 			priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : '';
275	// 		}
276	// 		return false;
277	// 	}
278	// }
279
280	// numbers
281	if ((("0123456789").indexOf(keychar) > -1) )
282		return true;
283
284	// decimal point jump
285	else if (dec && (keychar == ".")) {
286		//myfield.form.elements[dec].focus();
287		return srcEl.value.indexOf(".") == -1;
288	}
289
290	else if (dec && (keychar == ",")) {
291		return srcEl.value.indexOf(",") == -1;
292	}
293
294	//allow negative numbers
295	else if (allowNegativeNumber && (keychar == "-")) {
296		return (srcEl.value.length == 0 || srcEl.value == "0.00")
297	}
298	else
299		return false;
300}
301
302jQuery(document).on('focusout', '.grab-donation', function() {
303	var This = jQuery(this);
304	var min = This.data('min');
305	var max = This.data('max');
306	var id = This.data('campaign_id');
307	var rand_id = This.data('rand_id');
308	var priceEl = document.getElementById('wc-donation-price-' + id + '_' + rand_id);
309	var val = This.val();
310
311	if ( max <= 0 && max != 'any' ) {
312		max = val;
313	}
314
315	if ( (min == 'any' && max == 'any') || (val >= min && val <= max) ) {
316		var procFees = jQuery('#processing-fees-' + id + '_' + rand_id).val();
317		if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) {
318			var donation_card_fee = val*(procFees/100);
319		} else {
320			var donation_card_fee = procFees;
321		}
322
323		var donation_summary_total = parseFloat(val) + parseFloat(donation_card_fee);
324
325		if ( donation_summary_total > 0 && donation_summary_total != '' ) {
326			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important');
327			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(val).toFixed(2));
328			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2));
329			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2));
330		} else {
331			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important');
332			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(0).toFixed(2));
333			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(0).toFixed(2));
334			jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(0).toFixed(2));
335		}
336		priceEl.value = val;
337	} else {
338		priceEl.value = '';
339		This.val('');
340	}
341});
342
343jQuery(document).on("click", ".wc-close", function(){
344	jQuery(this).parents(".wc-donation-popup").removeClass("wc-popup-show");
345	if ( jQuery('body').hasClass('stopScroll') ) {
346		jQuery('body').removeClass('stopScroll');
347	}
348});
349
350
351function addDonationToOrder(type, amount, min_amount, max_amount, campaign_id, is_recurring, new_period, new_length, new_interval, tracker, donation_type, cause, fees, gift_aid='', tribute='', tribute_message='', e_card_email, cc_processing_fee, _this ,wps_sfw_sub_number, wps_sfw_sub_interval,wps_sfw_sub_exp_number,wps_sfw_sub_exp_interval, selectedLabel) {
352
353	let skip = false;
354
355	if ( type === 'roundoff-skip' ) {
356		flag = false;
357		jQuery( '.wc-block-components-checkout-place-order-button' ).trigger('click');
358		jQuery("form.woocommerce-checkout").submit();
359		return true;
360	}
361
362	if ( (amount != 0 && amount != null && amount > 0) ) {
363
364		jQuery.ajax(
365			{
366				url: wcOrderScript.donationToOrder.ajaxUrl,
367				type: "POST",
368				dataType: "json",
369				data: {
370					action: wcOrderScript.donationToOrder.action,
371					nonce: wcOrderScript.donationToOrder.nonce,
372					campaign_id: campaign_id,
373					amount: amount,
374					selectedLabel: selectedLabel,
375					cause: cause,
376					fees: fees,
377					type: type,
378					tribute: tribute,
379					tribute_message: tribute_message,
380					e_card_email: e_card_email,
381					gift_aid: gift_aid,
382					is_recurring: is_recurring,
383					new_period: new_period,
384					new_length: new_length,
385					new_interval: new_interval,
386					cc_processing_fee: cc_processing_fee,
387					wps_sfw_subscription_number : wps_sfw_sub_number,
388					wps_sfw_subscription_interval : wps_sfw_sub_interval,
389					wps_sfw_subscription_expiry_number : wps_sfw_sub_exp_number,
390					wps_sfw_subscription_expiry_interval : wps_sfw_sub_exp_interval,
391				},
392				beforeSend: function() {
393					jQuery(_this).parents('.wc_donation_on_cart').append('<div class="wc-donation-loader-css"><div class="wc-donation-blur-effect"></div><div class="wc-donation-loader" style="display:block;"></div></div>');
394					jQuery(_this).parents('.widget_wc-donation-widget').append('<div class="wc-donation-loader-css"><div class="wc-donation-blur-effect"></div><div class="wc-donation-loader" style="display:block;"></div></div>');
395				},
396				success: function (response) {
397					if (response['response'] == 'success') {
398						jQuery(`input[value="${campaign_id}"]`).closest('.wc_donation_on_cart').find('div.wc-donation-loader-css').remove();
399						jQuery(`input[value="${campaign_id}"]`).closest('.widget_wc-donation-widget').find('div.wc-donation-loader-css').remove();
400						jQuery( "[name='update_cart']" ).prop( "disabled", false );
401						jQuery( "[name='update_cart']" ).trigger( "click" );
402
403						if (type==='roundoff') {
404							jQuery(".wc-donation-popup").removeClass("wc-popup-show");
405						}
406
407						jQuery('body').trigger('update_checkout');
408						if ( typeof wc !== 'undefined') {
409							flag = false;
410							const { extensionCartUpdate } = wc.blocksCheckout;
411							extensionCartUpdate({
412								namespace: 'dfw',
413								data: {},
414							});
415						}
416
417						if( jQuery("#wc-donation-woocommerce-notices-wrapper").length ) {
418							jQuery("#wc-donation-woocommerce-notices-wrapper").show();
419							document
420								.getElementById("wc-donation-woocommerce-notices-wrapper")
421								.scrollIntoView({ behavior: "smooth" });
422						}
423						if( response['cart_url'] != '' ) {
424							window.location.href = response['cart_url'];
425						}
426
427						if ( response['checkoutUrl'] != '' ) {
428							window.location.href = response['checkoutUrl'];
429						}
430
431						jQuery('body').trigger('wc_donation_checkout_event');
432
433					}
434					if ( 'failed' === response['response'] ) {
435						jQuery(`input[value="${campaign_id}"]`).closest('.wc_donation_on_cart').find('div.wc-donation-loader-css').remove();
436						jQuery(`input[value="${campaign_id}"]`).closest('.widget_wc-donation-widget').find('div.wc-donation-loader-css').remove();
437
438						if( ! jQuery(`input[value="${campaign_id}"]`).siblings('div').hasClass('cc-require-message') ) {
439							var messageElement = jQuery('<div class="cc-require-message">'+response.message+'</div>');
440							jQuery(`input[value="${campaign_id}"]`).siblings('button').after(messageElement);
441						}
442					}
443					if ('error' === response['response']) {
444						location.reload(); // This will reload the page when "OK" is clicked
445					}
446				}
447			}
448		);
449		setTimeout(function() {
450			jQuery('.cc-require-message').remove();
451		}, 7000);
452	} else {
453		var text = wcOrderScript.donationToOrder.other_amount_placeholder;
454		text = text.replace("%min%", min_amount);
455		text = text.replace("%max%", max_amount);
456		if ( donation_type == 'both' || donation_type == 'predefined' ) {
457			if ( tracker == 1 ) {
458				alert(`${text}`);
459			} else {
460				alert(`Please select amount`);
461			}
462		} else {
463			alert(`${text}`);
464		}
465		return true;
466	}
467
468}
469
470jQuery( document ).on("click", ".wc-donation-f-submit-donation, #wc-donation-round-f-submit-donation, #wc-donation-round-f-submit-skip-donation", function (e) {
471		e.preventDefault();
472		var _this = jQuery(this);
473		var parents = jQuery(this).parents('.wc-donation-in-action');
474		var type = jQuery(this).data('type');
475		var campaign_id = jQuery(this).siblings('.wc_donation_camp').val();
476		var rand_id = jQuery(this).siblings('.wp_rand').val();
477		var is_recurring = false;
478		var new_period = 'day';
479		var new_length = '1';
480		var new_interval = '1';
481		var min_amount = 0;
482		var max_amount = 0;
483		var donation_type = jQuery(parents).data('donation-type');
484		var tracker = jQuery(parents).find('.wc-opened').length;
485		var subscription_data = [];
486		var tracker2 = jQuery(parents).find('.wc-donation-f-donation-other-value').length;
487		var selectBox = jQuery(parents).find('select.wc-label-select');
488		selectedLabel = '';
489		if (selectBox.length && selectBox.find('option:selected').val()) {
490			selectedLabel = selectBox.find('option:selected').text().trim();
491		}
492
493		// If no valid selection from <select>, try radio buttons
494		if (!selectedLabel) {
495			var selectedRadio = jQuery(parents).find('input[name="wc_label_price"]:checked');
496			if (selectedRadio.length) {
497				selectedLabel = selectedRadio.closest('label').text().trim();
498			}
499		}
500		if ( jQuery(this).data('min-value') ) {
501			min_amount = jQuery(this).data('min-value');
502		}
503
504		if ( jQuery(this).data('max-value') ) {
505			max_amount = jQuery(this).data('max-value');
506		}
507
508		if ( jQuery(parents).find('.donation-is-recurring').length > 0 && jQuery(parents).find('.donation-is-recurring').is(':checked') ) {
509			is_recurring = jQuery(parents).find('.donation-is-recurring').val();
510			new_period = jQuery(parents).find('._subscription_period').val();
511			new_length = jQuery(parents).find('#_subscription_length').val();
512			new_interval = jQuery(parents).find('#_subscription_period_interval').val();
513		} else {
514			is_recurring = 'no';
515		}
516
517		//alert(campaign_id);
518		if ( type == 'roundoff' || type ==  'roundoff-skip' ) {
519			jQuery(".wc-donation-popup").removeClass("wc-popup-show");
520			var amount = jQuery('.roundoff-donation-price').val();
521		} else {
522			var id = '.donate_' + campaign_id + '_' + rand_id;
523			//alert(id);
524			var amount = jQuery(id).val();
525		}
526		var causeID = '.donate_cause_' + campaign_id + '_' + rand_id;
527		var cause = jQuery(causeID).val();
528		var feeCheck = '.donate_fees_' + campaign_id + '_' + rand_id;
529
530		var fees = jQuery(feeCheck).val();
531
532		var cc_processing_fee = '';
533		if( jQuery(feeCheck).data('require') !== '' ) {
534			if( false == jQuery('#processing-fees-'+ campaign_id + '_' + rand_id ).prop( 'checked' ) ){
535				var cc_processing_fee = 'require';
536			}
537		}
538
539		var gift_aid = '';
540
541		if ( jQuery( `#wc_donation_gift_aid_checkbox_${campaign_id}_${rand_id}` ).length > 0 && jQuery( `#wc_donation_gift_aid_checkbox_${campaign_id}_${rand_id}` ).is(':checked') ) {
542			gift_aid = 'yes';
543		}
544
545		var tribute 		= '';
546		var tribute_message = '';
547
548		if ( jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).length > 0 && jQuery("input[name='wc_donation_tribute_checkbox']:checked").length && jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).val() != '' ) {
549			tribute = jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).val();
550		}
551
552		if( jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).length > 0 && jQuery("input[name='wc_donation_tribute_checkbox']:checked").length && jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).val() != '' ) {
553			tribute_message = jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).val();
554		}
555		var e_card_email    = '';
556		if ( jQuery(`#wc_donation_e_card_email_${campaign_id}`).length > 0 
557		     && jQuery(`#wc_donation_e_card_email_${campaign_id}`).val() != '' ) {
558		    e_card_email = jQuery(`#wc_donation_e_card_email_${campaign_id}`).val();
559		}
560		var wps_sfw_sub_number  		= '';
561		var wps_sfw_sub_interval 		= '';
562		var wps_sfw_sub_exp_number 		= '';
563		var wps_sfw_sub_exp_interval 	= '';
564
565		if (jQuery('.wc_donation_subscription_table').length) {
566			var wps_sfw_sub_number = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_number').val();
567			var wps_sfw_sub_interval = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_interval').val();
568			var wps_sfw_sub_exp_number = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_expiry_number').val();
569			var wps_sfw_sub_exp_interval = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_expiry_interval').val();
570		}
571
572
573
574		addDonationToOrder(type, amount, min_amount, max_amount, campaign_id, is_recurring, new_period, new_length, new_interval, tracker, donation_type, cause, fees, gift_aid, tribute, tribute_message, e_card_email, cc_processing_fee, _this ,wps_sfw_sub_number ,wps_sfw_sub_interval ,wps_sfw_sub_exp_number, wps_sfw_sub_exp_interval, selectedLabel);
575	}
576);
577
578jQuery(document).on('click', 'label.wc-label-button input[type="radio"][name="wc_label_price"], label.wc-label-button input[type="radio"][name="wc_label_cause"]', function() {
579
580	if ( jQuery(this).is(':checked') ) {
581		//alert('I clicked');
582		jQuery(this).parent('.wc-label-button').siblings().removeClass('wc-active');
583		jQuery(this).parent('.wc-label-button').addClass('wc-active');
584	}
585});
586
587jQuery(document).on('click', 'label.wc-label-radio input[type="radio"][name="wc_donation_tribute_checkbox"]', function() {
588	//debugger;
589	if ( jQuery(this).is(':checked') ) {
590		jQuery(this).parent().siblings('.wc_donation_trubte_name').prop('type', 'text');
591		jQuery(this).parent().siblings('.wc_donation_trubte_message').prop('type', 'text');
592	}
593});
594
595jQuery(document).on('copy paste keyup click', '.wc_donation_trubte_name', function() {
596	var tribute_name = jQuery(this).val();
597	var tribute_check_value = jQuery(this).siblings('label.wc-label-radio').find('input[name="wc_donation_tribute_checkbox"]:checked').val();
598	if ( jQuery.trim( tribute_name ) != '' && jQuery.trim( tribute_check_value ) != '' ) {
599		jQuery(this).siblings('input[name="tribute"]').val( `${tribute_check_value} ${tribute_name}` );
600	} else {
601		jQuery(this).siblings('input[name="tribute"]').val('');
602	}
603});
604
605jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){
606	var id = jQuery(this).data('id');
607	var campid = jQuery(this).data('camp');
608	var procFees = jQuery(this).val();
609	var wcdonationprice = jQuery('#wc-donation-price-'+campid).val();
610	if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) {
611		var donation_card_fee = wcdonationprice*(procFees/100);
612	} else {
613		var donation_card_fee = procFees;
614	}
615	var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee);
616
617	if ( donation_summary_total > 0 && donation_summary_total != '' ) {
618		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important');
619		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2));
620		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2));
621		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2));
622	}
623	if ( jQuery(this).is(':checked') ) {
624		jQuery('#wc-donation-summary-'+campid).show();
625		jQuery('#wc-donation-' + id).val(procFees);
626	}
627	else {
628		jQuery('#wc-donation-summary-'+campid).hide();
629		jQuery('#wc-donation-' + id).val(undefined);
630	}
631});
632jQuery(document).on("click", "ul.causes-dropdown .init", function() {
633	jQuery(this).parent().children('li:not(.init)').toggle();
634	jQuery(this).parent().toggleClass('active');
635	if ( jQuery(this).parent().hasClass('active') ) {
636		if ( jQuery(this).parents('.wc-donation-container').length ) {
637			var i = (75 * jQuery(this).parent().children('li:not(.init)').length);
638			jQuery(this).parents('.wc-donation-cause').css('margin-bottom', `${i}px`);
639		}
640	} else {
641		jQuery(this).parents('.wc-donation-cause').css('margin-bottom', `0px`);
642	}
643});
644
645jQuery(document).on("click", "ul.causes-dropdown li:not(.init)", function() {
646	var allOptions = jQuery(this).parent().children('li:not(.init)');
647	var id = jQuery(this).data('id');
648	var causeName = jQuery(this).data('name');
649	jQuery('#wc-donation-' + id).val(causeName);
650	allOptions.removeClass('selected');
651	jQuery(this).addClass('selected');
652	jQuery(this).parent().removeClass('active');
653	jQuery(this).parent().children('.init').html(jQuery(this).html());
654	allOptions.toggle();
655});
656
657jQuery(document.body).mousedown(function(event) {
658	var target = jQuery(event.target);
659	if ( jQuery('ul.causes-dropdown').hasClass('active') && !target.parents().andSelf().is('ul.causes-dropdown')) { // Clicked outside
660		jQuery('ul.causes-dropdown').removeClass( 'active' );
661		jQuery('ul.causes-dropdown').children('li:not(.init)').toggle();
662	}
663});
664
665// jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){
666// 	if(jQuery(this).is('checked')){
667// 		var id = jQuery(this).data('id');
668// 		jQuery('#wc-donation-' + id).val(jQuery(this).val());
669// 	}
670// 	else{
671// 		jQuery('#wc-donation-' + id).val('');
672// 	}
673// });
674
675jQuery(document).on('change copy paste click', '.wc-label-button input, .wc-label-radio input, .wc-label-select', function(){
676
677	var id = jQuery(this).data('id');
678
679	jQuery('#wc-donation-price-' + id).val(jQuery(this).val());
680	if ( jQuery(this).val() == 'wc-donation-other-amount' ) {
681		jQuery("#wc-donation-f-donation-other-value-" + id).show();
682		jQuery("#wc-donation-f-donation-other-value-" + id).addClass('wc-opened');
683		// jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').show();
684		jQuery(".other-price-wrapper-" + id).show();
685		jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').show();
686	} else {
687		jQuery("#wc-donation-f-donation-other-value-" + id).hide();
688		jQuery("#wc-donation-f-donation-other-value-" + id).removeClass('wc-opened');
689		// jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').hide();
690		jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').hide();
691		jQuery(".other-price-wrapper-" + id).hide();
692	}
693	var procFees = jQuery('#processing-fees-'+id).val();
694	var wcdonationprice = jQuery('#wc-donation-price-' + id).val();
695	if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) {
696		var donation_card_fee = wcdonationprice*(procFees/100);
697	} else {
698		var donation_card_fee = procFees;
699	}
700	var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee);
701	if ( donation_summary_total > 0 && donation_summary_total != '' ) {
702		jQuery('#wc-donation-summary-' + id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important');
703		jQuery('#wc-donation-summary-' + id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2));
704		jQuery('#wc-donation-summary-' + id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2));
705		jQuery('#wc-donation-summary-' + id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2));
706	}
707});
708
709jQuery(document).on('change', '._subscription_period', function(){
710
711	var $this = jQuery(this);
712	var subscription_field = $this.parents('.wc-donation-in-action').find('select[name="_subscription_length"]');
713	var period = $this.val();
714
715	jQuery.ajax({
716		url: wcOrderScript.donationToOrder.ajaxUrl,
717		type: "POST",
718		dataType: "json",
719		data: {
720			action: 'wc_donation_get_sub_length_by_sub_period',
721			period: period,
722			nonce: wcOrderScript.donationToOrder.nonce
723		},
724		beforeSend: function () {
725			jQuery(subscription_field).css({'pointer-events': 'none', 'opacity': '0.5'});
726		},
727		success: function (response) {
728
729			if ( response.range != '' ) {
730				jQuery(subscription_field).html('');
731				jQuery.each(response.range, function(index, val) {
732					jQuery(subscription_field).append('<option value="'+ index +'">'+ val +'</option>');
733				} );
734
735				jQuery(subscription_field).removeAttr('style');
736			}
737		}
738	});
739
740});
741
742jQuery(function(jQuery){
743
744	jQuery(".donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
745	jQuery(".anonymous-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
746	jQuery(".global-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
747	jQuery(".leaderboard-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
748	jQuery(".give-donor__load_more").on('click', function (e) {
749		e.preventDefault();
750		jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").slice(0, 4).css('display', 'flex');
751		if (jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").length == 0) {
752			jQuery(this).fadeOut(700);
753		}
754	});
755
756	jQuery('input[name="wc_donation_tribute_checkbox"]').click(function(){
757		var $radio = jQuery(this);
758		if ($radio.data('waschecked') == true) {
759			$radio.prop('checked', false);
760			jQuery(".wc_donation_trubte_name").prop('type', 'hidden');
761			jQuery(".wc_donation_trubte_message").prop('type', 'hidden');
762			$radio.data('waschecked', false);
763		} else {
764			$radio.data('waschecked', true);
765		}
766		$radio.siblings('input[name="wc_donation_tribute_checkbox"]').data('waschecked', false);
767	});
768});
769
770function dispaly_socialshare_links( $ ) {
771	jQuery( document ).ready( function() {
772		// Show the popup when the button is clicked
773		jQuery( document ).on( 'click', '#wc-donation-social-share', function() {
774			jQuery('#social-share-popup').css({
775				'display': 'flex',
776				'justify-content': 'center',
777				'align-items': 'center',
778				'overflow': 'hidden'
779			}).show();
780		});
781
782		// Hide the popup when the close button is clicked
783		jQuery('.close').click(function() {
784			jQuery('#social-share-popup').hide();
785		});
786
787		// Hide the popup when clicking outside of the popup content
788		jQuery(window).click(function(event) {
789			if (jQuery(event.target).is('#social-share-popup')) {
790				jQuery('#social-share-popup').hide();
791			}
792		});
793
794		// Copy link to clipboard
795		jQuery('#copy-link').click(function(e) {
796			e.preventDefault();
797			const url = jQuery(this).data('url');
798			const tempInput = jQuery('<input>');
799			jQuery('body').append(tempInput);
800			tempInput.val(url).select();
801			document.execCommand('copy');
802			tempInput.remove();
803			alert('Link copied to clipboard!');
804		});
805
806		// Trigger print dialog with custom content
807		jQuery('#print-poster').click(function(e) {
808			e.preventDefault();
809
810			// Create a new window
811			var printWindow = window.open('', '_blank');
812
813			// Get the content to print
814			var printContents = document.getElementById('print-section').innerHTML;
815
816			// Write the content into the new window
817			printWindow.document.write('<html><head><title>Print Poster</title>');
818			printWindow.document.write('</head><body>');
819			printWindow.document.write(printContents);
820			printWindow.document.write('</body></html>');
821
822			// Close the document to trigger the print dialog
823			printWindow.document.close();
824
825			// Wait for the content to be fully loaded
826			printWindow.onload = function() {
827				printWindow.print();
828				printWindow.close();
829			};
830		});
831
832	});
833}
834
835document.addEventListener("DOMContentLoaded", function () {
836	if (jQuery('.donation-is-recurring').length) {
837		const recurringCheckbox = document.querySelector(".donation-is-recurring");
838		const donationSubscriptionDiv = document.querySelector(".donation_subscription");
839
840		// Function to toggle visibility based on checkbox state
841		function toggleSubscriptionVisibility() {
842			if (recurringCheckbox.checked) {
843				donationSubscriptionDiv.style.display = "block";
844			} else {
845				donationSubscriptionDiv.style.display = "none";
846			}
847		}
848
849		// Run on page load in case checkbox is already checked
850		toggleSubscriptionVisibility();
851
852		// Add event listener for changes to the checkbox
853		recurringCheckbox.addEventListener("change", toggleSubscriptionVisibility);
854	}
855});
856
857document.addEventListener("DOMContentLoaded", function () {
858	if (jQuery('.donation-is-recurring').length) {
859		const recurringCheckbox = document.querySelector(".donation-is-recurring");
860		const subscriptionOptions = document.querySelectorAll(".subscription-options");
861
862		// Function to toggle visibility based on checkbox state
863		function toggleSubscriptionOptions() {
864			const display = recurringCheckbox.checked ? "table-row" : "none";
865			subscriptionOptions.forEach(row => {
866				row.style.display = display;
867			});
868		}
869
870		// Run on page load to set initial state
871		toggleSubscriptionOptions();
872
873		// Add event listener for changes to the checkbox
874		recurringCheckbox.addEventListener("change", toggleSubscriptionOptions);
875	}
876});
877
878jQuery(document).ready(function($) {
879	var allowSubmit = true; // Flag to control AJAX submission
880
881	jQuery('#wc-donation-f-submit-donation').on('click', function(e) {
882		var subscriptionNumber = parseInt(jQuery('#wps_sfw_subscription_number').val(), 10);
883		var expiryNumber = parseInt(jQuery('#wps_sfw_subscription_expiry_number').val(), 10);
884		if (jQuery('#wps_sfw_subscription_number').length) {
885			// Check if the checkbox is checked and subscription number is empty
886			if (jQuery('.donation-is-recurring').is(':checked')) {
887
888				if (isNaN(subscriptionNumber) || subscriptionNumber === '') {
889					alert('Please enter the number of subscriptions per interval.');
890					allowSubmit = false;
891					e.preventDefault(); // Prevent form submission
892					return; // Exit the function to avoid further checks
893				}
894
895			}
896			// Validate if number is positive
897			if (subscriptionNumber < 1 || expiryNumber < 1) {
898				alert('Interval cannot be negative.');
899				allowSubmit = false;
900				e.preventDefault(); // Prevent form submission
901				return; // Exit the function to avoid further checks
902			}
903			// Check if the subscription number is greater than the expiry number
904			if (subscriptionNumber > expiryNumber) {
905				alert('Subscriptions Per Interval must not be greater than Subscriptions Expiry Interval.');
906				allowSubmit = false; // Set flag to false to prevent AJAX
907				e.preventDefault(); // Prevent form submission
908			} else {
909				allowSubmit = true; // Allow AJAX if condition is met
910			}
911		}
912	});
913
914	// Intercept AJAX request if necessary
915	jQuery(document).ajaxSend(function(event, jqxhr, settings) {
916		if (!allowSubmit) {
917			jqxhr.abort(); // Abort the AJAX request
918			jQuery('.wc-donation-loader-css').hide(); // Hide loader if any
919		}
920	});
921});
922
923
924jQuery(document).ready(function($) {
925	jQuery('#wps_sfw_subscription_interval').on('change', function() {
926		var selectedInterval = jQuery(this).val();
927
928		// Clear the Expiry Interval options
929		jQuery('#wps_sfw_subscription_expiry_interval').empty();
930
931		// Add the selected interval as the only option in Expiry Interval
932		jQuery('#wps_sfw_subscription_expiry_interval').append('<option value="' + selectedInterval + '">' + selectedInterval.charAt(0).toUpperCase() + selectedInterval.slice(1) + '(s)</option>');
933	});
934
935	// Trigger the change event on page load to set the initial state
936	jQuery('#wps_sfw_subscription_interval').trigger('change');
937});

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.