PageSourceSearch

https://flatrockarchive.com/wp-content/plugins/ph-bookings-appoint…/js/ph-booking-addon-general.js?ver=7.1.3

js flatrockarchive.com collected 2026-10-10 00:36:26 UTC 23,451 bytes, 679 lines download raw bytes

1/********* class-ph-booking-search-widget.php *********/
2jQuery(document).ready(function ($) {
3	detachElementAndPosition('ph_book_search_asset_list', 'ph_book_search_asset_name_container');
4	detachElementAndPosition('ph_book_search_number_of_participants_button', 'ph_book_search_number_of_participants_container');
5	/**
6	 * Detach the element from the DOM and append to body.
7	 * This will allow use to properly position the element as a popup based on the offset of it's parent.
8	 *
9	 * @param {string} element Element ID to position 
10	 * @param {string} parent Parent element to target.
11	 */
12	function detachElementAndPosition(element, parent) {
13
14		// Hide popup on page load.
15		$(`#${element}`).hide();
16
17		// Detach element and attach back to body.
18		$(`#${element}`).appendTo('body');
19
20		// Attach offset to display the popup.
21		jQuery(`#${parent}`).on('click', function () {
22
23			const offset = $(this).offset();
24			if ((element == 'ph_book_search_number_of_participants_button') && ($(`.ph_controls`).length == 0)) {
25				$(`#${element}`).css({
26					'top': offset.top + $(this).outerHeight(),
27					'left': offset.left
28				}).hide();
29			} else {
30				$(`#${element}`).css({
31					'top': offset.top + $(this).outerHeight(),
32					'left': offset.left
33				}).show()
34			}
35		});
36
37		//if participant is checked and no rule is selected then hide the container
38		if ($(`.ph_controls`).length == 0) {
39			$('#ph_book_search_number_of_participants_container').hide();
40		}
41	}
42
43	// Retrieve user settings
44
45	var participantCounts = [];
46	var date_format = jQuery("#ph_book_search_date_format").val();
47	var fixedDate = $('#ph_fixed_date').val();
48	let checkInRestriction = $('#ph_checkin_day_checked').val();
49	let checkOutRestriction = $('#ph_checkout_day_checked').val();
50	var timeEnabled = $('#ph_book_search_filter_date_and_time').val();
51	var timeInterval = $('#ph_book_search_interval').val();
52	var from_time = $('#ph_book_search_range_from').val();
53	var to_time = $('#ph_book_search_range_to').val();
54	var from_date_text = $('#ph_from_date_text').val();
55	var to_date_text = $('#ph_to_date_text').val();
56	var assetEnabled = $('#ph_book_search_filter_asset_name').val();
57	var clearDisabled = $('#ph_booking_clear').val();
58	var participantEnabled = $('#ph_book_search_filter_number_of_participant').val();
59	var assetLabel = $('#ph_asset_label').val();
60	var borderRadius = $('#ph_border_radius').val();
61	var borderStyle = $('#ph_border_style').val();
62	var borderColor = $('#ph_border_color').val();
63	var borderWidth = $('#ph_border_width').val();
64
65
66	let availableCheckInDays = checkInRestriction ? $("#ph_checkin_day_related").val().split(' ') : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
67	let availableCheckOutDays = checkOutRestriction ? $("#ph_checkout_day_related").val().split(' ') : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
68
69	var momentDateFormat, momentDateTimeFormat;
70	switch (date_format) {
71		case 'dd-mm-yy':
72			momentDateFormat = 'DD-MM-YYYY';
73			momentDateTimeFormat = 'DD-MM-YYYY hh:mm A';
74			break;
75		case 'yy-mm-dd':
76			momentDateFormat = 'YYYY-MM-DD';
77			momentDateTimeFormat = 'YYYY-MM-DD hh:mm A';
78			break;
79		case 'dd/mm/yy':
80			momentDateFormat = 'DD/MM/YYYY';
81			momentDateTimeFormat = 'DD/MM/YYYY hh:mm A';
82			break;
83		case 'yy/mm/dd':
84			momentDateFormat = 'YYYY/MM/DD';
85			momentDateTimeFormat = 'YYYY/MM/DD hh:mm A';
86			break;
87		default:
88			momentDateFormat = 'YYYY-MM-DD';
89			momentDateTimeFormat = 'YYYY-MM-DD hh:mm A';
90			break;
91	}
92
93	var currentDate = moment().format(momentDateFormat);
94	var startDate = moment(`${currentDate}`, momentDateFormat, true);
95	var endDate;
96	var dateTime = timeEnabled == '1' ? momentDateTimeFormat : momentDateFormat;
97	// var fromDateTime = from_time ? moment(`${currentDate} ${from_time}`, momentDateTimeFormat) : moment(`${currentDate}`, momentDateFormat);
98	var toDateTime = to_time ? moment(`${currentDate} ${to_time}`, momentDateTimeFormat) : moment(`${currentDate}`, momentDateFormat);
99	var fromDateSet = false;
100	var firstDate;
101	var minDate;
102
103	//show searching data in frontend
104	var getUrlParameter = function getUrlParameter(sParam) {
105		var sPageURL = window.location.search.substring(1),
106			sURLVariables = sPageURL.split('&'),
107			sParameterName,
108			i;
109
110		for (i = 0; i < sURLVariables.length; i++) {
111			sParameterName = sURLVariables[i].split('=');
112
113			if (sParameterName[0] === sParam) {
114				var n = (typeof sParameterName[1] === undefined);
115				return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
116			}
117		}
118	};
119
120	var resultFrom = getUrlParameter('book_search_from');
121	var formattedDateFrom = null;
122	if (typeof resultFrom !== "undefined" && resultFrom !== null) {
123		formattedDateFrom = moment(resultFrom, dateTime).format(dateTime);
124		$("#ph_book_search_from").val(formattedDateFrom);
125		firstDate = formattedDateFrom;
126		fromDateSet = true;
127	}
128
129	if (firstDate && moment(firstDate, dateTime).isValid()) {
130		minDate = moment(firstDate, dateTime).toDate();
131	} else {
132		minDate = new Date();
133	}
134
135	//from Calendar Configuration
136	let fromCalendarConfig = {
137		singleDatePicker: true,
138		autoApply: true,
139		showDropdowns: true,
140		minDate: new Date(),
141		maxYear: 2026,
142		isInvalidDate: checkInvalidDate(availableCheckInDays),
143		locale: {
144			format: dateTime
145		},
146		startDate: minDate
147	};
148
149	//to Calendar Configuration
150	let toCalendarConfig = {
151		singleDatePicker: true,
152		autoApply: true,
153		showDropdowns: true,
154		maxYear: 2026,
155		isInvalidDate: checkInvalidDate(availableCheckOutDays, fromDateSet),
156		locale: {
157			format: dateTime
158		},
159		startDate: minDate
160	};
161
162	/**
163	 * Check if the day is restricted for checkin or checkout.
164	 * @param {*} availableDays 
165	 * @returns
166	 */
167	function checkInvalidDate(availableDays, fromDateSet) {
168
169		return function (date) {
170			const incomingDay = date.format('dddd');
171
172			// Check if the day is restricted for checkout as per widget settings.
173			const isRestrictedDay = !availableDays.includes(incomingDay);
174
175			// Check if 'from' date is set and 'to' date is after 'from' date.
176			const isBeforeFromDate = fromDateSet && date.isBefore(moment($("#ph_book_search_from").val(), dateTime));
177
178			// Combine both conditions: if either is true, the date is invalid.
179			return isRestrictedDay || isBeforeFromDate;
180		};
181
182	}
183
184	const defaultTimeInterval = 5;
185	const timeIntervalValue = (timeInterval !== null && timeInterval !== "") ? parseInt(timeInterval) : defaultTimeInterval;
186	fromCalendarConfig.timePickerIncrement = timeIntervalValue;
187	toCalendarConfig.timePickerIncrement = timeIntervalValue;
188
189	if (timeEnabled) {
190		fromCalendarConfig.timePicker = true;
191		toCalendarConfig.timePicker = true;
192		fromCalendarConfig.timePicker24Hour = true;
193		toCalendarConfig.timePicker24Hour = true;
194		fromCalendarConfig.timePickerIncrement = timeIntervalValue;
195		toCalendarConfig.timePickerIncrement = timeIntervalValue;
196	}
197
198	if (fixedDate) {
199		$('.ph_book_search_date_container, .ph_book_search_time_container').css('min-width', '20%');
200		$('.ph_book_search_date_container1').hide();
201
202	} else {
203		$('.ph_book_search_date_container, .ph_book_search_time_container').css('min-width', '51%');
204	}
205
206	//if a Fixed Date is checked in Admin Widget then Single Date Picker is Enabled
207	if (!fixedDate) {
208		var fromDate = '';
209		const initialPlaceholderFrom = $("#ph_book_search_from").attr('placeholder');
210		const initialPlaceholderTo = $("#ph_book_search_to").attr('placeholder');
211		
212		// For "From" Date
213		if (jQuery('#ph_book_search_from').length) {
214			$("#ph_book_search_from").daterangepicker({
215				...fromCalendarConfig,
216				autoUpdateInput: false,
217			}, function (start, end, label) {
218				fromDate = start.format(dateTime);
219				$("#ph_book_search_from").val(start.format(dateTime));
220				$("#ph_book_search_from").attr('placeholder', '');
221				$('#ph_book_search_to').data('daterangepicker').minDate = start;
222				$('#ph_book_search_to').data('daterangepicker').setStartDate(start);
223				fromDateSet = true;
224
225				$("#ph_book_search_to").trigger('click');
226			});
227
228
229			$("#ph_book_search_from").on('apply.daterangepicker', function (ev, picker) {
230				$(this).val(picker.startDate.format(dateTime));
231				$('#ph_book_search_to').val('');
232				$('#ph_book_search_to').attr('placeholder', initialPlaceholderTo);
233				$('#ph_book_search_to').on('show.daterangepicker', function (ev, picker) {
234					$('.daterangepicker td.in-range').css('background', 'none');
235					$('.daterangepicker td.in-range').css('color', '#6D6D6D');
236					$('.daterangepicker td.active').css('color', '#6D6D6D');
237					$('.daterangepicker td.active').css('font-weight', 'normal');
238				});
239			});
240
241			$("#ph_book_search_from").on('cancel.daterangepicker', function (ev, picker) {
242				$(this).val('');
243				$(this).attr('placeholder', initialPlaceholderFrom);
244				$('#ph_book_search_to').prop('disabled', true);
245				$('#ph_book_search_to').val('');
246				$('#ph_book_search_to').attr('placeholder', initialPlaceholderTo);
247				fromDateSet = false;
248			});
249		}
250
251		// For "To" Date
252
253		$('#ph_book_search_to').prop('required', true);
254		if (jQuery('#ph_book_search_to').length) {
255			$("#ph_book_search_to").daterangepicker({
256				...toCalendarConfig,
257				autoUpdateInput: false
258			}, function (start, end, label) {
259				$("#ph_book_search_to").val(end.format(dateTime));
260				$("#ph_book_search_to").attr('placeholder', '');
261			});
262
263			$("#ph_book_search_to").on('apply.daterangepicker', function (ev, picker) {
264				if (fromDateSet) {
265					$(this).val(picker.endDate.format(dateTime));
266					picker.hide();
267				} else {
268					$(this).val('');
269					$(this).attr('placeholder', initialPlaceholderTo);
270				}
271			});
272
273			$("#ph_book_search_to").on('cancel.daterangepicker', function (ev, picker) {
274				$(this).val('');
275				$(this).attr('placeholder', initialPlaceholderTo);
276				picker.hide();
277			});
278
279			$(document).on('mousedown', function (e) {
280				if (!$(e.target).closest('#ph_book_search_to, .daterangepicker').length) {
281					$("#ph_book_search_to").data('daterangepicker').hide();
282				}
283			});
284		}
285	}
286	else {
287		$('#ph_book_search_to').css('display', 'none');
288		if (jQuery('#ph_book_search_from').length) {
289			const initialPlaceholderFrom = $("#ph_book_search_from").attr('placeholder');
290
291			$("#ph_book_search_from").daterangepicker({
292				...fromCalendarConfig,
293				autoUpdateInput: false,
294			}, function (start, end, label) {
295				const fromDate = start.format(dateTime);
296				$("#ph_book_search_from").val(start.format(dateTime));
297				$("#ph_book_search_from").attr('placeholder', '');
298				// $("#ph_book_search_to").trigger('click');
299			});
300
301
302			$("#ph_book_search_from").on('apply.daterangepicker', function (ev, picker) {
303				$(this).val(picker.startDate.format(dateTime));
304			});
305
306			$("#ph_book_search_from").on('cancel.daterangepicker', function (ev, picker) {
307				$(this).val('');
308				$(this).attr('placeholder', initialPlaceholderFrom);
309			});
310		}
311
312	}
313
314	var filter_time = jQuery("#ph_book_search_filter_date_and_time").val();
315	var filter_participant = jQuery("#ph_book_search_filter_number_of_participant").val();
316	if (filter_participant == 1) {
317		$("#ph_book_search_number_of_participants").attr({
318			"min": 1,
319		});
320	}
321
322	if (filter_time == 1) {
323		//time format conversion
324		var wp_date_format = jQuery("#ph_book_search_time_format").val();
325		var wp_date_format = wp_date_format.replace("A", "p");
326		var wp_date_format = wp_date_format.replace("g", "h");
327		var wp_date_format = wp_date_format.replace("h", "hh");
328		var wp_date_format = wp_date_format.replace("G", "H");
329		var wp_date_format = wp_date_format.replace("H", "HH");
330		var wp_date_format = wp_date_format.replace("i", "mm");
331		var wp_date_format = wp_date_format.replace("s", "ss");
332		//time picker interval
333		var intervals = jQuery("#ph_book_search_interval").val();
334		//time picker range
335		var range_from = jQuery("#ph_book_search_range_from").val();
336		var range_to = jQuery("#ph_book_search_range_to").val();
337
338		// Timepicker not working if intervals, range_from, range_to not present
339		intervals = intervals ? intervals : 60;
340		range_from = range_from ? range_from : '00:00';
341		range_to = range_to ? range_to : '23:00';
342
343		var time_zone_conversion_enable = jQuery("#ph_book_search_time_zone_conversion_enable").val();
344
345		if (time_zone_conversion_enable == 'yes') {
346			$('#ph_book_search_time_from').hide();
347			$('#ph_book_search_time_to').hide();
348		}
349	}
350
351	var resultTo = getUrlParameter('book_search_to');
352	if (typeof resultTo !== "undefined" && resultTo !== null && resultTo) {
353		var formattedDateTo = moment(resultTo, dateTime).format(dateTime);
354		$("#ph_book_search_to").val(formattedDateTo);
355		fromDateSet = true;
356	}
357
358	var result = getUrlParameter('ph_search_asset_name');
359	if (typeof (result) != "undefined" && result !== null) {
360		var selectedText = $('.ph_book_search_asset_item[data-value="' + result + '"]').text();
361		if (selectedText && result) {
362			$('#ph_asset_name').val(selectedText);
363			$('#ph_asset_name').attr('data-ph-search-asset-id', result);
364		} else {
365			var defaultElement = $('#ph_book_search_asset_list .ph_book_search_asset_item[data-value="default"]');
366			var defaultText = defaultElement.text();
367			$('#ph_asset_name').val(defaultText);
368			$('#ph_asset_name').attr('data-ph-search-asset-id', 'default');
369		}
370
371	}
372
373	var result = getUrlParameter('ph_book_search_participants');
374	if (typeof (result) != "undefined" && result !== null) {
375		var participantsArray = JSON.parse(result);
376		jQuery('.ph_participant-group').each(function () {
377			var participantGroup = jQuery(this);
378			var rule = participantGroup.data('participant').replace(/\+/g, ' ');
379			var inputField = participantGroup.find('input[type="number"]');
380			var participant = participantsArray.find(p => p.rule.replace(/\+/g, ' ') === rule);
381			if (participant) {
382				inputField.val(participant.count);
383				participantCounts.push({ rule: rule, count: participant.count });
384
385			}
386		});
387
388		var totalCount = participantsArray.reduce(function (sum, participant) {
389			return sum + participant.count;
390		}, 0);
391		$("#participant_count_display").text(totalCount);
392	}
393
394	//styling for clear button based on settings
395	if (typeof clearDisabled === 'undefined') {
396		$('.ph_book_search_button_container').css({
397			'justify-content': 'center',
398			'max-width': '116px',
399			'align-content': 'end',
400			'flex-direction': 'row-reverse'
401
402		});
403	}
404	else {
405		$('.ph_book_search_button_container').css({
406			'justify-content': 'end',
407			'max-width': '213px',
408			'align-content': 'stretch',
409			'flex-direction': 'column'
410
411		});
412	}
413
414	//when clicked on clear button then empty the values
415	$("#ph_booking_clear").click(function () {
416		$('#ph_book_search_from').val('').attr('placeholder', from_date_text);
417		$('#ph_book_search_to').val('').attr('placeholder', to_date_text);
418		$('#ph_asset_name').val(assetLabel);
419		$("#participant_count_display").text('');
420		$('#ph_book_search_to').data('daterangepicker').minDate = moment().startOf('day');
421
422		// To reset participants array upon clear
423		jQuery('.ph_participant-group').each(function () {
424			var participantGroup = jQuery(this);
425			var inputField = participantGroup.find('input[type="number"]');
426			inputField.val(0);
427		});
428
429		participantCounts = [];
430
431		fromDateSet = false;
432	});
433
434	if ($('.ph_book_search_time_from').length && $('.ph_book_search_asset_name_container').length && $('.ph_book_search_number_of_participants_canatiner').length) {
435		var all_filter_present = true;
436	} else {
437		var all_filter_present = false
438	}
439
440	if (!$('.ph_book_search_time_from').length && !$('.ph_book_search_asset_name_container').length && !$('.ph_book_search_number_of_participants_canatiner').length) {
441		var date_filter_only = true;
442	} else {
443		var date_filter_only = false
444	}
445
446	if ($('.ph_book_search_time_from').length && !$('.ph_book_search_asset_name_container').length && !$('.ph_book_search_number_of_participants_canatiner').length) {
447		var date_and_time_filter = true;
448	} else {
449		var date_and_time_filter = false
450	}
451	if ($('.ph_booking_clear').length) {
452		var clear_button_present = true;
453	} else {
454		var clear_button_present = false;
455	}
456
457	$('.ph_booking_search_widget_wrapper').each(function () {
458		toggle_search_widget_container(this);
459	})
460
461	$(window).resize(function () {
462		$('.ph_booking_search_widget_wrapper').each(function () {
463			toggle_search_widget_container(this);
464		})
465	});
466
467	//search bar styling based on admin settings.
468	$('.ph_book_search_widget_container').css({
469		'border-radius': borderRadius + 'px',
470		'border-style': borderStyle,
471		'border-color': borderColor,
472		'border-width': borderWidth + 'px'
473	});
474
475	/**
476	 * Check the width of the widget area and toggle the widget bar accordingly
477	 * @param {*widget} widget 
478	 */
479	function toggle_search_widget_container(widget) {
480		let widget_width = $(widget).width();
481		let widget_container = $(widget).find('.ph_book_search_widget_container');
482
483		if ((widget_width < 730 && all_filter_present && clear_button_present) ||
484			(widget_width < 650 && all_filter_present && !clear_button_present) ||
485			(widget_width < 300 && date_filter_only && !clear_button_present) ||
486			(widget_width < 350 && date_filter_only && clear_button_present) ||
487			(widget_width < 550 && date_and_time_filter && clear_button_present) ||
488			(widget_width < 500 && date_and_time_filter && !clear_button_present)
489		) {
490
491			$(widget_container).addClass('ph_book_search_widget_container_column');
492			$(widget_container).removeClass('ph_book_search_widget_container_row');
493
494		} else if ((widget_width >= 730 && all_filter_present && clear_button_present) ||
495			(widget_width >= 650 && all_filter_present && !clear_button_present) ||
496			(widget_width >= 300 && date_filter_only && !clear_button_present) ||
497			(widget_width >= 350 && date_filter_only && clear_button_present) ||
498			(widget_width >= 550 && date_and_time_filter && clear_button_present) ||
499			(widget_width >= 500 && date_and_time_filter && !clear_button_present)
500		) {
501
502			$(widget_container).removeClass('ph_book_search_widget_container_column');
503			$(widget_container).addClass('ph_book_search_widget_container_row');
504
505		} else if ((widget_width >= 550 && !clear_button_present) || (widget_width >= 600)) {
506
507			$(widget_container).removeClass('ph_book_search_widget_container_column');
508			$(widget_container).addClass('ph_book_search_widget_container_row');
509
510		} else {
511
512			$(widget_container).addClass('ph_book_search_widget_container_column');
513			$(widget_container).removeClass('ph_book_search_widget_container_row');
514
515		}
516	}
517
518	//participant count script
519	document.querySelectorAll('.minus, .plus').forEach(button => {
520		button.addEventListener('click', function (event) {
521			event.stopPropagation();
522			const input = document.getElementById(this.dataset.target);
523			let value = parseInt(input.value);
524			
525			if (this.classList.contains('minus')) {
526				value -= 1;
527				if (value < parseInt(input.min)) return;
528			} else {
529				value += 1;
530				if (value > parseInt(input.max)) return;
531			}
532			
533			input.value = value;
534			updateParticipantCount(this.dataset.target, value);
535			updateTotalParticipants();
536		});
537	});
538
539	/**
540	 * Updating the Count value to its respective Participant Type
541	 * @param {rule, count} 
542	 */
543	function updateParticipantCount(rule, count) {
544		var found = false;
545		for (var i = 0; i < participantCounts.length; i++) {
546			if (participantCounts[i].rule === rule) {
547				participantCounts[i].count = count;
548				found = true;
549				break;
550			}
551		}
552		if (!found) {
553			participantCounts.push({ rule: rule, count: count });
554		}
555	}
556
557	/**
558	 * Updating the Count value in Product Page after Search
559	 */
560	function getParticipantCounts() {
561		jQuery('.ph_participant-group').each(function () {
562			var participantGroup = jQuery(this);
563			var rule = participantGroup.data('participant').replace(/\+/g, ' ');
564			var inputField = participantGroup.find('input[type="number"]');
565			var count = parseInt(inputField.val(), 10) || 0;
566			if (count != 0 && participantCounts) {
567				updateParticipantCount(rule, count);
568			}
569		});
570		return participantCounts;
571	}
572
573	/**
574	 * Updating the total count value to its respective Participant
575	 */
576	function updateTotalParticipants() {
577		var total = 0;
578		$('.ph_participant-group input[type="number"]').each(function () {
579			total += parseInt($(this).val()) || 0;
580		});
581		$('#participant_count_display').text(total > 0 ? total : '');
582	}
583
584	// Select an item from the list for asset container
585	$('.ph_book_search_asset_item').on('click', function () {
586		var selectedText = $(this).text();
587		var assetId = $(this).attr('data-value');
588		$('#ph_asset_name').val(selectedText);
589		$('#ph_asset_name').attr('data-ph-search-asset-id', assetId);
590		$('#ph_book_search_asset_list').hide();
591	});
592
593	// Hide the asset list and popup if clicked outside for asset container or participant container
594	$(document).on('click', function (event) {
595		if (!$(event.target).closest('#ph_book_search_asset_name_container').length) {
596			$('#ph_book_search_asset_list').hide();
597		}
598		if (!$(event.target).closest('#ph_book_search_number_of_participants_container').length) {
599			$('#ph_book_search_number_of_participants_button').hide();
600		}
601	});
602
603	$(".ph_book_search_from, .ph_book_search_to ,#ph_asset_name,.ph_book_search_number_of_participants_buttons").on('keydown paste focus mousedown', function (e) {
604		if (e.keyCode != 9)
605			e.preventDefault();
606	});
607
608
609	$('#ph_booking_searchform').on('submit', function (e) {
610
611		const value = jQuery('#ph_asset_name').attr('data-ph-search-asset-id');
612		$('#ph_search_asset_name').val(value === 'default' ? '' : value);
613			
614		$('#ph_book_search_participants').val(JSON.stringify(participantCounts));
615
616		const from = $('#ph_book_search_from').val();
617		const to = $('#ph_book_search_to').val();
618		const isFixedDate = $('#ph_fixed_date').val();
619		if (to && !isFixedDate) {
620			$('#s').val(`${from} - ${to}`);
621		} else {
622			$('#s').val(from);
623		}
624
625		// Get the form data as query parameters
626		var formData = $(this).serializeArray();
627
628		// Check if the 'ph_booking_product_page' entry exists
629		var isProductPageSearch = formData.find(function (item) {
630			return item.name === 'ph_booking_product_page';
631		});
632
633		if (isProductPageSearch) {
634
635			e.preventDefault();
636			participantCounts = getParticipantCounts();
637			$('#ph_book_search_participants').val(JSON.stringify(participantCounts));
638			formData = $(this).serializeArray();
639
640			// Filter out the entry with the name 'ph_booking_product_page' to avoid infinite looped redirection.
641			var filteredFormData = formData.filter(function (item) {
642				return item.name !== 'ph_booking_product_page';
643			});
644
645			// Convert the filtered array back to a query string
646			var filteredFormData = $.param(filteredFormData);
647			var base_url = ph_booking_search_data.home_url + "/?"
648			window.location.href = base_url + filteredFormData;
649
650		}
651
652		$(".ph_book_search_from, .ph_book_search_to, #ph_asset_name, .ph_book_search_number_of_participants_buttons").on('keydown paste focus mousedown', function (e) {
653			if (!fixedDate) {
654				$(".ph_book_search_to").attr('required', 'required');
655			}
656			if (e.keyCode != 9)
657				e.preventDefault();
658		});
659	});
660
661	// Handle book now on search results page.
662	$('.ph_search_book_now').on('click', function (e) {
663
664		e.preventDefault();
665
666		const data = {
667			action: 'ph_handle_book_now_from_search',
668			product_id: $(this).attr('data-product-id')
669		};
670
671		$.post(ph_booking_search_data.ajaxurl, data, function (response) {
672
673			if (response.success && response?.data?.cart_url) {
674				window.location.href = response.data.cart_url;
675			}
676		});
677	});
678});
679

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.