PageSourceSearch

https://manhoodjourney.org/wp-content/plugins/donation-for-woocomm…/frontend.js?ver=3.9.7%26t%3D01102026041456

js manhoodjourney.org collected 2026-10-02 06:31:40 UTC 35,282 bytes, 934 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='', 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					gift_aid: gift_aid,
381					is_recurring: is_recurring,
382					new_period: new_period,
383					new_length: new_length,
384					new_interval: new_interval,
385					cc_processing_fee: cc_processing_fee,
386					wps_sfw_subscription_number : wps_sfw_sub_number,
387					wps_sfw_subscription_interval : wps_sfw_sub_interval,
388					wps_sfw_subscription_expiry_number : wps_sfw_sub_exp_number,
389					wps_sfw_subscription_expiry_interval : wps_sfw_sub_exp_interval,
390				},
391				beforeSend: function() {
392					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>');
393					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>');
394				},
395				success: function (response) {
396					if (response['response'] == 'success') {
397						jQuery(`input[value="${campaign_id}"]`).closest('.wc_donation_on_cart').find('div.wc-donation-loader-css').remove();
398						jQuery(`input[value="${campaign_id}"]`).closest('.widget_wc-donation-widget').find('div.wc-donation-loader-css').remove();
399						jQuery( "[name='update_cart']" ).prop( "disabled", false );
400						jQuery( "[name='update_cart']" ).trigger( "click" );
401
402						if (type==='roundoff') {
403							jQuery(".wc-donation-popup").removeClass("wc-popup-show");
404						}
405
406						jQuery('body').trigger('update_checkout');
407						if ( typeof wc !== 'undefined') {
408							flag = false;
409							const { extensionCartUpdate } = wc.blocksCheckout;
410							extensionCartUpdate({
411								namespace: 'dfw',
412								data: {},
413							});
414						}
415
416						if( jQuery("#wc-donation-woocommerce-notices-wrapper").length ) {
417							jQuery("#wc-donation-woocommerce-notices-wrapper").show();
418							document
419								.getElementById("wc-donation-woocommerce-notices-wrapper")
420								.scrollIntoView({ behavior: "smooth" });
421						}
422						if( response['cart_url'] != '' ) {
423							window.location.href = response['cart_url'];
424						}
425
426						if ( response['checkoutUrl'] != '' ) {
427							window.location.href = response['checkoutUrl'];
428						}
429
430						jQuery('body').trigger('wc_donation_checkout_event');
431
432					}
433					if ( 'failed' === response['response'] ) {
434						jQuery(`input[value="${campaign_id}"]`).closest('.wc_donation_on_cart').find('div.wc-donation-loader-css').remove();
435						jQuery(`input[value="${campaign_id}"]`).closest('.widget_wc-donation-widget').find('div.wc-donation-loader-css').remove();
436
437						if( ! jQuery(`input[value="${campaign_id}"]`).siblings('div').hasClass('cc-require-message') ) {
438							var messageElement = jQuery('<div class="cc-require-message">'+response.message+'</div>');
439							jQuery(`input[value="${campaign_id}"]`).siblings('button').after(messageElement);
440						}
441					}
442					console.log(response['response']);
443					if ('error' === response['response']) {
444						alert('Time Limit Exceeded');
445						location.reload(); // This will reload the page when "OK" is clicked
446					}
447				}
448			}
449		);
450		setTimeout(function() {
451			jQuery('.cc-require-message').remove();
452		}, 7000);
453	} else {
454		var text = wcOrderScript.donationToOrder.other_amount_placeholder;
455		text = text.replace("%min%", min_amount);
456		text = text.replace("%max%", max_amount);
457		if ( donation_type == 'both' || donation_type == 'predefined' ) {
458			if ( tracker == 1 ) {
459				alert(`${text}`);
460			} else {
461				alert(`Please select amount`);
462			}
463		} else {
464			alert(`${text}`);
465		}
466		return true;
467	}
468
469}
470
471jQuery( document ).on("click", ".wc-donation-f-submit-donation, #wc-donation-round-f-submit-donation, #wc-donation-round-f-submit-skip-donation", function (e) {
472		e.preventDefault();
473		var _this = jQuery(this);
474		var parents = jQuery(this).parents('.wc-donation-in-action');
475		var type = jQuery(this).data('type');
476		var campaign_id = jQuery(this).siblings('.wc_donation_camp').val();
477		var rand_id = jQuery(this).siblings('.wp_rand').val();
478		var is_recurring = false;
479		var new_period = 'day';
480		var new_length = '1';
481		var new_interval = '1';
482		var min_amount = 0;
483		var max_amount = 0;
484		var donation_type = jQuery(parents).data('donation-type');
485		var tracker = jQuery(parents).find('.wc-opened').length;
486		var subscription_data = [];
487		var tracker2 = jQuery(parents).find('.wc-donation-f-donation-other-value').length;
488		var selectBox = jQuery(parents).find('select.wc-label-select');
489		selectedLabel = '';
490		if (selectBox.length && selectBox.find('option:selected').val()) {
491			selectedLabel = selectBox.find('option:selected').text().trim();
492		}
493
494		// If no valid selection from <select>, try radio buttons
495		if (!selectedLabel) {
496			var selectedRadio = jQuery(parents).find('input[name="wc_label_price"]:checked');
497			if (selectedRadio.length) {
498				selectedLabel = selectedRadio.closest('label').text().trim();
499			}
500		}
501		if ( jQuery(this).data('min-value') ) {
502			min_amount = jQuery(this).data('min-value');
503		}
504
505		if ( jQuery(this).data('max-value') ) {
506			max_amount = jQuery(this).data('max-value');
507		}
508
509		if ( jQuery(parents).find('.donation-is-recurring').length > 0 && jQuery(parents).find('.donation-is-recurring').is(':checked') ) {
510			is_recurring = jQuery(parents).find('.donation-is-recurring').val();
511			new_period = jQuery(parents).find('._subscription_period').val();
512			new_length = jQuery(parents).find('#_subscription_length').val();
513			new_interval = jQuery(parents).find('#_subscription_period_interval').val();
514		} else {
515			is_recurring = 'no';
516		}
517
518		//alert(campaign_id);
519		if ( type == 'roundoff' || type ==  'roundoff-skip' ) {
520			jQuery(".wc-donation-popup").removeClass("wc-popup-show");
521			var amount = jQuery('.roundoff-donation-price').val();
522		} else {
523			var id = '.donate_' + campaign_id + '_' + rand_id;
524			//alert(id);
525			var amount = jQuery(id).val();
526		}
527		var causeID = '.donate_cause_' + campaign_id + '_' + rand_id;
528		var cause = jQuery(causeID).val();
529		var feeCheck = '.donate_fees_' + campaign_id + '_' + rand_id;
530
531		var fees = jQuery(feeCheck).val();
532
533		var cc_processing_fee = '';
534		if( jQuery(feeCheck).data('require') !== '' ) {
535			if( false == jQuery('#processing-fees-'+ campaign_id + '_' + rand_id ).prop( 'checked' ) ){
536				var cc_processing_fee = 'require';
537			}
538		}
539
540		var gift_aid = '';
541
542		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') ) {
543			gift_aid = 'yes';
544		}
545
546		var tribute 		= '';
547		var tribute_message = '';
548
549		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() != '' ) {
550			tribute = jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).val();
551		}
552
553		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() != '' ) {
554			tribute_message = jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).val();
555		}
556
557		var wps_sfw_sub_number  		= '';
558		var wps_sfw_sub_interval 		= '';
559		var wps_sfw_sub_exp_number 		= '';
560		var wps_sfw_sub_exp_interval 	= '';
561
562		if (jQuery('.wc_donation_subscription_table').length) {
563			var wps_sfw_sub_number = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_number').val();
564			var wps_sfw_sub_interval = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_interval').val();
565			var wps_sfw_sub_exp_number = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_expiry_number').val();
566			var wps_sfw_sub_exp_interval = jQuery('.wc_donation_subscription_table').find('.wps_sfw_subscription_expiry_interval').val();
567		}
568
569
570
571		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, cc_processing_fee, _this ,wps_sfw_sub_number ,wps_sfw_sub_interval ,wps_sfw_sub_exp_number, wps_sfw_sub_exp_interval, selectedLabel);
572	}
573);
574
575jQuery(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() {
576
577	if ( jQuery(this).is(':checked') ) {
578		//alert('I clicked');
579		jQuery(this).parent('.wc-label-button').siblings().removeClass('wc-active');
580		jQuery(this).parent('.wc-label-button').addClass('wc-active');
581	}
582});
583
584jQuery(document).on('click', 'label.wc-label-radio input[type="radio"][name="wc_donation_tribute_checkbox"]', function() {
585	//debugger;
586	if ( jQuery(this).is(':checked') ) {
587		jQuery(this).parent().siblings('.wc_donation_trubte_name').prop('type', 'text');
588		jQuery(this).parent().siblings('.wc_donation_trubte_message').prop('type', 'text');
589	}
590});
591
592jQuery(document).on('copy paste keyup click', '.wc_donation_trubte_name', function() {
593	var tribute_name = jQuery(this).val();
594	var tribute_check_value = jQuery(this).siblings('label.wc-label-radio').find('input[name="wc_donation_tribute_checkbox"]:checked').val();
595	if ( jQuery.trim( tribute_name ) != '' && jQuery.trim( tribute_check_value ) != '' ) {
596		jQuery(this).siblings('input[name="tribute"]').val( `${tribute_check_value} ${tribute_name}` );
597	} else {
598		jQuery(this).siblings('input[name="tribute"]').val('');
599	}
600});
601
602jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){
603	var id = jQuery(this).data('id');
604	var campid = jQuery(this).data('camp');
605	var procFees = jQuery(this).val();
606	var wcdonationprice = jQuery('#wc-donation-price-'+campid).val();
607	if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) {
608		var donation_card_fee = wcdonationprice*(procFees/100);
609	} else {
610		var donation_card_fee = procFees;
611	}
612	var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee);
613
614	if ( donation_summary_total > 0 && donation_summary_total != '' ) {
615		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important');
616		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2));
617		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2));
618		jQuery('#wc-donation-summary-' + campid + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2));
619	}
620	if ( jQuery(this).is(':checked') ) {
621		jQuery('#wc-donation-summary-'+campid).show();
622		jQuery('#wc-donation-' + id).val(procFees);
623	}
624	else {
625		jQuery('#wc-donation-summary-'+campid).hide();
626		jQuery('#wc-donation-' + id).val(undefined);
627	}
628});
629jQuery(document).on("click", "ul.causes-dropdown .init", function() {
630	jQuery(this).parent().children('li:not(.init)').toggle();
631	jQuery(this).parent().toggleClass('active');
632	if ( jQuery(this).parent().hasClass('active') ) {
633		if ( jQuery(this).parents('.wc-donation-container').length ) {
634			var i = (75 * jQuery(this).parent().children('li:not(.init)').length);
635			jQuery(this).parents('.wc-donation-cause').css('margin-bottom', `${i}px`);
636		}
637	} else {
638		jQuery(this).parents('.wc-donation-cause').css('margin-bottom', `0px`);
639	}
640});
641
642jQuery(document).on("click", "ul.causes-dropdown li:not(.init)", function() {
643	var allOptions = jQuery(this).parent().children('li:not(.init)');
644	var id = jQuery(this).data('id');
645	var causeName = jQuery(this).data('name');
646	jQuery('#wc-donation-' + id).val(causeName);
647	allOptions.removeClass('selected');
648	jQuery(this).addClass('selected');
649	jQuery(this).parent().removeClass('active');
650	jQuery(this).parent().children('.init').html(jQuery(this).html());
651	allOptions.toggle();
652});
653
654jQuery(document.body).mousedown(function(event) {
655	var target = jQuery(event.target);
656	if ( jQuery('ul.causes-dropdown').hasClass('active') && !target.parents().andSelf().is('ul.causes-dropdown')) { // Clicked outside
657		jQuery('ul.causes-dropdown').removeClass( 'active' );
658		jQuery('ul.causes-dropdown').children('li:not(.init)').toggle();
659	}
660});
661
662// jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){
663// 	if(jQuery(this).is('checked')){
664// 		var id = jQuery(this).data('id');
665// 		jQuery('#wc-donation-' + id).val(jQuery(this).val());
666// 	}
667// 	else{
668// 		jQuery('#wc-donation-' + id).val('');
669// 	}
670// });
671
672jQuery(document).on('change copy paste click', '.wc-label-button input, .wc-label-radio input, .wc-label-select', function(){
673
674	var id = jQuery(this).data('id');
675
676	jQuery('#wc-donation-price-' + id).val(jQuery(this).val());
677	if ( jQuery(this).val() == 'wc-donation-other-amount' ) {
678		jQuery("#wc-donation-f-donation-other-value-" + id).show();
679		jQuery("#wc-donation-f-donation-other-value-" + id).addClass('wc-opened');
680		// jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').show();
681		jQuery(".other-price-wrapper-" + id).show();
682		jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').show();
683	} else {
684		jQuery("#wc-donation-f-donation-other-value-" + id).hide();
685		jQuery("#wc-donation-f-donation-other-value-" + id).removeClass('wc-opened');
686		// jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').hide();
687		jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').hide();
688		jQuery(".other-price-wrapper-" + id).hide();
689	}
690	var procFees = jQuery('#processing-fees-'+id).val();
691	var wcdonationprice = jQuery('#wc-donation-price-' + id).val();
692	if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) {
693		var donation_card_fee = wcdonationprice*(procFees/100);
694	} else {
695		var donation_card_fee = procFees;
696	}
697	var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee);
698	if ( donation_summary_total > 0 && donation_summary_total != '' ) {
699		jQuery('#wc-donation-summary-' + id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important');
700		jQuery('#wc-donation-summary-' + id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2));
701		jQuery('#wc-donation-summary-' + id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2));
702		jQuery('#wc-donation-summary-' + id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2));
703	}
704});
705
706jQuery(document).on('change', '._subscription_period', function(){
707
708	var $this = jQuery(this);
709	var subscription_field = $this.parents('.wc-donation-in-action').find('select[name="_subscription_length"]');
710	var period = $this.val();
711
712	jQuery.ajax({
713		url: wcOrderScript.donationToOrder.ajaxUrl,
714		type: "POST",
715		dataType: "json",
716		data: {
717			action: 'wc_donation_get_sub_length_by_sub_period',
718			period: period,
719			nonce: wcOrderScript.donationToOrder.nonce
720		},
721		beforeSend: function () {
722			jQuery(subscription_field).css({'pointer-events': 'none', 'opacity': '0.5'});
723		},
724		success: function (response) {
725
726			if ( response.range != '' ) {
727				jQuery(subscription_field).html('');
728				jQuery.each(response.range, function(index, val) {
729					jQuery(subscription_field).append('<option value="'+ index +'">'+ val +'</option>');
730				} );
731
732				jQuery(subscription_field).removeAttr('style');
733			}
734		}
735	});
736
737});
738
739jQuery(function(jQuery){
740
741	jQuery(".donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
742	jQuery(".anonymous-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
743	jQuery(".global-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
744	jQuery(".leaderboard-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex');
745	jQuery(".give-donor__load_more").on('click', function (e) {
746		e.preventDefault();
747		jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").slice(0, 4).css('display', 'flex');
748		if (jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").length == 0) {
749			jQuery(this).fadeOut(700);
750		}
751	});
752
753	jQuery('input[name="wc_donation_tribute_checkbox"]').click(function(){
754		var $radio = jQuery(this);
755		if ($radio.data('waschecked') == true) {
756			$radio.prop('checked', false);
757			jQuery(".wc_donation_trubte_name").prop('type', 'hidden');
758			jQuery(".wc_donation_trubte_message").prop('type', 'hidden');
759			$radio.data('waschecked', false);
760		} else {
761			$radio.data('waschecked', true);
762		}
763		$radio.siblings('input[name="wc_donation_tribute_checkbox"]').data('waschecked', false);
764	});
765});
766
767function dispaly_socialshare_links( $ ) {
768	jQuery( document ).ready( function() {
769		// Show the popup when the button is clicked
770		jQuery( document ).on( 'click', '#wc-donation-social-share', function() {
771			jQuery('#social-share-popup').css({
772				'display': 'flex',
773				'justify-content': 'center',
774				'align-items': 'center',
775				'overflow': 'hidden'
776			}).show();
777		});
778
779		// Hide the popup when the close button is clicked
780		jQuery('.close').click(function() {
781			jQuery('#social-share-popup').hide();
782		});
783
784		// Hide the popup when clicking outside of the popup content
785		jQuery(window).click(function(event) {
786			if (jQuery(event.target).is('#social-share-popup')) {
787				jQuery('#social-share-popup').hide();
788			}
789		});
790
791		// Copy link to clipboard
792		jQuery('#copy-link').click(function(e) {
793			e.preventDefault();
794			const url = jQuery(this).data('url');
795			const tempInput = jQuery('<input>');
796			jQuery('body').append(tempInput);
797			tempInput.val(url).select();
798			document.execCommand('copy');
799			tempInput.remove();
800			alert('Link copied to clipboard!');
801		});
802
803		// Trigger print dialog with custom content
804		jQuery('#print-poster').click(function(e) {
805			e.preventDefault();
806
807			// Create a new window
808			var printWindow = window.open('', '_blank');
809
810			// Get the content to print
811			var printContents = document.getElementById('print-section').innerHTML;
812
813			// Write the content into the new window
814			printWindow.document.write('<html><head><title>Print Poster</title>');
815			printWindow.document.write('</head><body>');
816			printWindow.document.write(printContents);
817			printWindow.document.write('</body></html>');
818
819			// Close the document to trigger the print dialog
820			printWindow.document.close();
821
822			// Wait for the content to be fully loaded
823			printWindow.onload = function() {
824				printWindow.print();
825				printWindow.close();
826			};
827		});
828
829	});
830}
831
832document.addEventListener("DOMContentLoaded", function () {
833	if (jQuery('.donation-is-recurring').length) {
834		const recurringCheckbox = document.querySelector(".donation-is-recurring");
835		const donationSubscriptionDiv = document.querySelector(".donation_subscription");
836
837		// Function to toggle visibility based on checkbox state
838		function toggleSubscriptionVisibility() {
839			if (recurringCheckbox.checked) {
840				donationSubscriptionDiv.style.display = "block";
841			} else {
842				donationSubscriptionDiv.style.display = "none";
843			}
844		}
845
846		// Run on page load in case checkbox is already checked
847		toggleSubscriptionVisibility();
848
849		// Add event listener for changes to the checkbox
850		recurringCheckbox.addEventListener("change", toggleSubscriptionVisibility);
851	}
852});
853
854document.addEventListener("DOMContentLoaded", function () {
855	if (jQuery('.donation-is-recurring').length) {
856		const recurringCheckbox = document.querySelector(".donation-is-recurring");
857		const subscriptionOptions = document.querySelectorAll(".subscription-options");
858
859		// Function to toggle visibility based on checkbox state
860		function toggleSubscriptionOptions() {
861			const display = recurringCheckbox.checked ? "table-row" : "none";
862			subscriptionOptions.forEach(row => {
863				row.style.display = display;
864			});
865		}
866
867		// Run on page load to set initial state
868		toggleSubscriptionOptions();
869
870		// Add event listener for changes to the checkbox
871		recurringCheckbox.addEventListener("change", toggleSubscriptionOptions);
872	}
873});
874
875jQuery(document).ready(function($) {
876	var allowSubmit = true; // Flag to control AJAX submission
877
878	jQuery('#wc-donation-f-submit-donation').on('click', function(e) {
879		var subscriptionNumber = parseInt(jQuery('#wps_sfw_subscription_number').val(), 10);
880		var expiryNumber = parseInt(jQuery('#wps_sfw_subscription_expiry_number').val(), 10);
881		if (jQuery('#wps_sfw_subscription_number').length) {
882			// Check if the checkbox is checked and subscription number is empty
883			if (jQuery('.donation-is-recurring').is(':checked')) {
884
885				if (isNaN(subscriptionNumber) || subscriptionNumber === '') {
886					alert('Please enter the number of subscriptions per interval.');
887					allowSubmit = false;
888					e.preventDefault(); // Prevent form submission
889					return; // Exit the function to avoid further checks
890				}
891
892			}
893			// Validate if number is positive
894			if (subscriptionNumber < 1 || expiryNumber < 1) {
895				alert('Interval cannot be negative.');
896				allowSubmit = false;
897				e.preventDefault(); // Prevent form submission
898				return; // Exit the function to avoid further checks
899			}
900			// Check if the subscription number is greater than the expiry number
901			if (subscriptionNumber > expiryNumber) {
902				alert('Subscriptions Per Interval must not be greater than Subscriptions Expiry Interval.');
903				allowSubmit = false; // Set flag to false to prevent AJAX
904				e.preventDefault(); // Prevent form submission
905			} else {
906				allowSubmit = true; // Allow AJAX if condition is met
907			}
908		}
909	});
910
911	// Intercept AJAX request if necessary
912	jQuery(document).ajaxSend(function(event, jqxhr, settings) {
913		if (!allowSubmit) {
914			jqxhr.abort(); // Abort the AJAX request
915			jQuery('.wc-donation-loader-css').hide(); // Hide loader if any
916		}
917	});
918});
919
920
921jQuery(document).ready(function($) {
922	jQuery('#wps_sfw_subscription_interval').on('change', function() {
923		var selectedInterval = jQuery(this).val();
924
925		// Clear the Expiry Interval options
926		jQuery('#wps_sfw_subscription_expiry_interval').empty();
927
928		// Add the selected interval as the only option in Expiry Interval
929		jQuery('#wps_sfw_subscription_expiry_interval').append('<option value="' + selectedInterval + '">' + selectedInterval.charAt(0).toUpperCase() + selectedInterval.slice(1) + '(s)</option>');
930	});
931
932	// Trigger the change event on page load to set the initial state
933	jQuery('#wps_sfw_subscription_interval').trigger('change');
934});

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.