1 2function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 3 4jQuery(document).ready(function ($) { 5 $is_booking_end_date_clicked = false; 6 $is_booking_end_date_calendar_open = false; 7 $ph_date_from_previous_value = ''; 8 9 function generate_booking_info_text(from, to, cost, custom_messages, result) { 10 $('.display_time_from').val(from); 11 $('.display_time_to').val(to); 12 if ($('#calender_type').val() == 'date' && $('#charge_per_night').length && $('#charge_per_night').val() == 'yes') { 13 from_text = phive_booking_ajax.checkin; 14 to_text = phive_booking_ajax.checkout; 15 } else { 16 from_text = phive_booking_ajax.booking; 17 to_text = phive_booking_ajax.to; 18 } 19 if (from !== to && phive_booking_ajax.display_end_time) { 20 from_date = new Date(result.org_from_date); 21 to_date = new Date(result.org_to_date); 22 if ($('#calender_type').val() != 'date' && $('#calender_type').val() != 'month' && from_date.getMonth() == to_date.getMonth() && from_date.getFullYear() == to_date.getFullYear() && from_date.getDate() == to_date.getDate()) { 23 var wp_date_format = jQuery("#ph_booking_wp_time_format").val(); 24 var hours = to_date.getHours(); 25 var ampm = hours >= 12 ? 'pm' : 'am'; 26 to_time = ph_convert_time_to_wp_time_format(wp_date_format, to_date, ampm); 27 date_html = "<b>" + from_text + ":</b> " + from + " <b>" + to_text + "</b> " + to_time; 28 } 29 else { 30 date_html = "<b>" + from_text + ":</b> " + from + " <b>" + to_text + "</b> " + to; 31 } 32 33 } else { 34 date_html = "<b>" + phive_booking_ajax.booking + ":</b> " + from; 35 } //for Addon 36 37 38 jQuery('.from_text').val(from_text); 39 jQuery('.to_text').val(to_text).trigger('change'); 40 if (custom_messages == '') 41 return '<p id="booking_info_text">' + date_html + '</p> <p id="booking_price_text"> <b>' + phive_booking_ajax.booking_cost + ': </b>' + cost + '</p>'; 42 else 43 return '<p id="booking_info_text">' + date_html + '</p> <p id="booking_price_text"> <b>' + phive_booking_ajax.booking_cost + ': </b>' + cost + '</p> <p id="booking_custom_text"> ' + custom_messages + '</p>'; 44 } 45 function timezoneOffset(date_string) { 46 // passing default parameter value doesn't work in safari 47 if (date_string === undefined || !date_string) { 48 date_string = ''; 49 } 50 let date = new Date(date_string), 51 timezoneOffset = date.getTimezoneOffset(), 52 hours = ('00' + Math.floor(Math.abs(timezoneOffset / 60))).slice(-2), 53 minutes = ('00' + Math.abs(timezoneOffset % 60)).slice(-2), 54 string = (timezoneOffset >= 0 ? '-' : '+') + hours + ':' + minutes; 55 return string; 56 } 57 function ph_convert_date_to_wp_date_format(wp_format, date) { 58 59 months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
59November", "December"]; 60 new_date = new Date(date + 'T' + '00:00' + timezoneOffset(date)); 61 62 month = ("0" + (new_date.getMonth() + 1)).slice(-2); 63 date = ("0" + new_date.getDate()).slice(-2); 64 switch (wp_format) { 65 case 'j F Y': display_date = date + ' ' + phive_booking_ajax.months[new_date.getMonth()] + ' ' + new_date.getFullYear(); 66 break; 67 case 'F j, Y': display_date = phive_booking_ajax.months[new_date.getMonth()] + ' ' + date + ', ' + new_date.getFullYear(); 68 break; 69 case 'Y-m-d': display_date = new_date.getFullYear() + '-' + month + '-' + date; 70 break; 71 case 'm/d/Y': display_date = month + '/' + date + '/' + new_date.getFullYear(); 72 break; 73 case 'd/m/Y': display_date = date + '/' + month + '/' + new_date.getFullYear(); 74 break; 75 default: display_date = new_date.getFullYear() + '-' + month + '-' + date; 76 break; 77 78 } 79 return display_date; 80 } 81 function ph_convert_time_to_wp_time_format(wp_format, date, am_pm) { 82 var hours = date.getHours(); 83 var minutes = date.getMinutes(); 84 wp_format = wp_format + ""; 85 switch (wp_format) { 86 case "g:i a": 87 hours = hours % 12; 88 hours = hours ? hours : 12; // the hour '0' should be '12' 89 minutes = minutes < 10 ? '0' + minutes : minutes; 90 display_time = hours + ':' + minutes + ' ' + am_pm.toLowerCase(); 91 break; 92 case "g:i A": 93 hours = hours % 12; 94 hours = hours ? hours : 12; // the hour '0' should be '12' 95 minutes = minutes < 10 ? '0' + minutes : minutes; 96 display_time = hours + ':' + minutes + ' ' + am_pm.toUpperCase(); 97 break; 98 case "H:i": 99 hours = hours.toString().padStart(2, 0); 100 minutes = minutes.toString().padStart(2, 0); 101 display_time = hours + ':' + minutes; 102 break; 103 case "G \\h i \\m\\i\\n": 104 display_time = hours + ' h ' + minutes + ' min'; 105 break; 106 default: 107 hours = hours % 12; 108 hours = hours ? hours : 12; // the hour '0' should be '12' 109 minutes = minutes < 10 ? '0' + minutes : minutes; 110 display_time = hours + ':' + minutes + ' ' + am_pm.toUpperCase(); 111 break; 112 113 } 114 return display_time; 115 } 116 function resetSelection(fullReset) { 117 fullReset = fullReset || 'yes'; 118 date_from = ''; 119 date_to = ''; 120 click = 0; 121 $(".single_add_to_cart_button").addClass("disabled"); 122 $(".selected-date").each(function () { 123 $(this).removeClass("selected-date"); 124 }); 125 126 127 $(".ph-date-from").val(""); 128 $(".ph-date-to").val(""); 129 $('.element_from').val(""); 130 $('.element_to').val(""); 131 $('.element_from_date').val(""); 132 $('.element_from_time').val(""); 133 $('.element_to_date').val(""); 134 $('.element_to_time').val(""); 135 136 if (fullReset == 'yes') { 137 $(".booking-info-wraper").html(""); 138 } 139 140 if ($(".not-startable").length) { 141 $(".not-startable").removeClass("hide-not-startable"); 142 } 143 } 144 /*function formate_date( input_date ){ 145 var date = new Date( input_date.replace(/-/g, "/") ); //Safari bowser will accept only with seprator '/' 146 147 var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 148 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][date.getMonth()]; 149 var strDate = date.getDate() + '-' + month + '-' + date.getFullYear(); 150 if( $("#calender_type").val() =='time' ){ 151 strDate += " "; 152 strDate += date.getHours()<10 ? "0"+date.getHours() : date.getHours(); 153 strDate += ":" 154 strDate += date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes(); 155 } 156 return strDate; 157 }*/ 158 // Calculate the booking price. 159 160 161 jQuery(".ph-date-to").on('change', function () { 162 calculate_booking_price(); 163 }); 164 jQuery(".addon,.wc-pao-addon-field,.ph-addons").on('change', function () { 165 from = jQuery(".ph-date-from").val(); 166 167 if (from != '') { 168 calculate_booking_price(); 169 } 170 }); 171 172 function calculate_booking_price() { 173 if ($('.input-disabled').length || !jQuery(".ph-date-from").length) { 174 return; 175 } 176 177 $(".shipping-price-related").addClass('input-disabled'); 178 $(".shipping-price-related").attr("disabled", true); 179 180 var loding_ico_url = $("#plugin_dir_url").val() + "/resources/icons/loading2.gif"; 181 182 $(".booking-info-wraper").html('<img class="loading-ico" align="middle" src="' + loding_ico_url + '">'); 183 $(".single_add_to_cart_button").addClass("disabled"); 184 var from = jQuery(".ph-date-from").val(); 185 var to = jQuery(".ph-date-to").val(); 186 var person_details = []; 187 $('.input-person').each(function () { 188 if ($(this).val() != '') person_details.push(parseInt($(this).val())); else person_details.push(0); 189 }); // for range values select min available slot 190 191 var available_slots = $('.selected-date').map(function () { 192 var attr = $(this).attr('data-title'); 193 194 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 195 return parseInt($(this).attr('data-title')); 196 } else { 197 if ($(this).text() == '' || ($(".selected-date").last().find('.callender-full-date').val() == $(this).find('.callender-full-date').val() && $('#charge_per_night').val() == 'yes')) return; // If try to book between months or per night booking and Consider each participant as booking is marked 198 return 0; 199 } 200 }).get(); 201 var available_slot = Math.min.apply(Math, available_slots); // for range values select min available slot 202 203 var available_slots_to_displays = $('.selected-date').map(function () { 204 var attr = $(this).attr('data-max'); 205 206 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 207 return parseInt($(this).attr('data-max')); 208 } else { 209 if ($(this).text() == '') return; // If try to book between months and Consider each participant as booking is marked 210 211 return 0; 212 } 213 }).get(); 214 var available_slots_to_display = Math.min.apply(Math, available_slots_to_displays); 215 var persons_as_booking = $('#persons_as_booking').val(); 216 217 if (persons_as_booking == 'yes') { 218 person_details_count = person_details.reduce(function (a, b) { 219 return a + b; 220 }, 0); 221 222 if (person_details_count > available_slot) { 223 var message = phive_booking_ajax.available_slot_message; 224 message = message.replace('%available_slot', available_slots_to_display); 225 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 226 $(".shipping-price-related").removeClass('input-disabled'); 227 $(".shipping-price-related").removeAttr("disabled"); 228 return false;
229 } 230 } 231 232 var total_numer_persons = 0; 233 $('.input-person').each(function () { 234 // total_numer_persons += parseInt($(this).val()); 235 Number.isInteger = Number.isInteger || function (value) { 236 return typeof value === 'number' && 237 isFinite(value) && 238 Math.floor(value) === value; 239 }; 240 if (Number.isInteger(parseInt($(this).val()))) { 241 total_numer_persons += parseInt($(this).val()); 242 } 243 }); 244 245 if (persons_as_booking != 'yes' && total_numer_persons > parseInt($('#phive_booking_maximum_number_of_allowed_participant').val()) && parseInt($('#phive_booking_maximum_number_of_allowed_participant').val()) != 'NaN') { 246 var message = phive_booking_ajax.maximum_participant_warning; 247 message = message.replace('%total', total_numer_persons); 248 message = message.replace('%max', parseInt($('#phive_booking_maximum_number_of_allowed_participant').val())); 249 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 250 $(".shipping-price-related").removeClass('input-disabled'); 251 $(".shipping-price-related").removeAttr("disabled"); 252 return false; 253 } 254 255 // if (persons_as_booking != 'yes' && total_numer_persons < parseInt($ 256 if (total_numer_persons < parseInt($('#phive_booking_minimum_number_of_required_participant').val()) && parseInt($('#phive_booking_minimum_number_of_required_participant').val()) != 'NaN') { 257 var message = phive_booking_ajax.minimum_participant_warning; 258 // message = message.replace('%total', total_numer_persons); 259 message = message.replace('%min', parseInt($('#phive_booking_minimum_number_of_required_participant').val())); 260 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 261 $(".shipping-price-related").removeClass('input-disabled'); 262 $(".shipping-price-related").removeAttr("disabled"); 263 return false; 264 } 265 266 resources_type = $('.resources_type').val(); 267 if (resources_type == 'single') { 268 resources_details = []; 269 selected_resources = $('.phive_book_resources').val(); 270 $(".phive_book_resources option").each(function (i) { 271 if ($(this).val() == '') 272 return true; 273 val = 'no'; 274 if (selected_resources == $(this).val()) { 275 val = 'yes'; 276 } 277 resources_details.push(val); 278 }); 279 } 280 else { 281 resources_details = []; 282 $('.input-resources').each(function () { 283 val = $(this).is(":checked") ? 'yes' : 'no'; 284 resources_details.push(val); 285 }); 286 } 287 288 product_id = jQuery("#phive_product_id").val(); 289 290 current_product_id = product_id; 291 292 // WPML Compatibility 293 if(jQuery("#product-addons-total")) 294 { 295 current_product_id = jQuery("#product-addons-total").attr('data-product-id'); 296 // console.log('current product id : ', current_product_id); 297 } 298 299 if (from.length === 0 || to.length === 0) { 300 return; 301 } 302 303 $(".ph_booking_addon_data").val(); 304 addon_data = jQuery('.addon').serialize(); 305 if (parseInt($(".wc-pao-addon-field").length) > 0) { 306 addon_data = jQuery('.wc-pao-addon-field').serialize(); 307 } 308 product_addon_data = ''; 309 if (parseInt($(".phive-addon-field").length) > 0) { 310 product_addon_data = jQuery('.phive-addon-field').serialize(); 311 } 312 custom_time_period = ''; 313 if ($(".cutome_time_period").length > 0) { 314 custom_time_period = $(".cutome_time_period").find(':selected').val(); 315 } 316 var data = { 317 action: 'phive_get_booked_price', 318 // security : phive_booking_ajax.security, 319 product_id: product_id, 320 book_from: from, 321 book_to: to, 322 person_details: person_details, 323 resources_details: resources_details, 324 addon_data: addon_data, 325 product_addon_data: product_addon_data, 326 asset: $(".input-assets").val(), 327 custom_fields: $(".custom_fields").val(), 328 custom_time_period: custom_time_period, 329 current_product_id: current_product_id 330 }; 331 jQuery(".ph-calendar-date").prop('disabled', true); 332 $.post(phive_booking_ajax.ajaxurl, data, function (res) { 333 result = jQuery.parseJSON(res); 334 jQuery(".ph-calendar-date").prop('disabled', false); // Confirm the response of last request. 335 // The price should updated only for last request incase another request send immediately 336 337 $(".shipping-price-related").removeClass('input-disabled'); 338 $(".shipping-price-related").removeAttr("disabled"); 339 $(".single_add_to_cart_button").removeClass("disabled"); 340 $(".callender-msg").html(''); 341 342 if (result.error_msg) { 343 if ($('#calendar_design').val() != '3') { 344 resetSelection(); 345 } 346 $('.booking-info-wraper').html(result.error_msg); 347 // $("#phive_booked_price").val(''); 348 $(".phive_booked_price").val(''); 349 // $(".phive_book_assets").val(asset); 350 } else { 351 if (to != '') { 352 var to_date_obj = new Date(to); 353 var from_date_obj = new Date(from); 354 355 if (from_date_obj.getTime() > to_date_obj.getTime()) { 356 resetSelection(); 357 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">Booking start date cannot be higher than end date.</span></p>'); 358 // $("#phive_booked_price").val(''); 359 $(".phive_booked_price").val(''); 360 $(".phive_book_assets").val(''); 361 } else { 362 // $(".price").html( result.price_html ); //to change the main product price 363 // $("#phive_booked_price").val(result.price); 364 $(".phive_booked_price").val(result.price); 365 $(".phive_book_assets").val(result.asset_id); //in the case of monthpicker, take last date of 'TO' month 366 var custom_messages = ''; 367 if (result.custom_messages) { 368 custom_messages = result.custom_messages; 369 } 370 371 if (result.product_addon_data) { 372 $(".ph_booking_product_addon_data").val(result.product_addon_data); 373 } 374 375 if (result.addon_data) { 376 $(".ph_booking_addon_data").val(result.addon_data); 377 } 378 /*if( (to.match(new RegExp("-", "g")) || []).length < 2 ){ 379 var date = new Date( to.replace(/-/g, "/") ); //Safari bowser will accept only with separator '/' 380 var LastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0); 381 to = to+"-"+LastDay.getDate(); 382 }*/ 383 384 booking_info_text = generate_booking_info_text(result.from_date, result.to_date, result.price_html, custom_messages, result); 385 $('.booking-info-wraper').html(booking_info_text).trigger('change'); 386 } 387 } 388 } 389 }); 390 } 391 392 // $('.time-picker-wraper #ph-calendar-days').on("click", ".ph-calendar-date", function () { 393 $('.time-picker-wraper .ph-ul-date').on("click", ".ph-calendar-date", function () { 394 var from = jQuery(".ph-date-from").val(); 395 var element_from_date = $('.element_from_date').val() 396 var to = jQuery(".ph-date-to").val(); 397 398 var loding_ico_url = $("#plugin_dir_url").val() + "/resources/icons/loading2.gif"; 399 $(".ph-ul-time").show(); 400 // $("#ph-calendar-time").html('<img class="loading-ico" align="middle" src="' + loding_ico_url + '">'); 401 $(".ph-ul-time").html('<img class="loading-ico" align="middle" src="' + loding_ico_url + '">'); 402 var product_id = jQuery("#phive_product_id").val(); 403 404 if ($is_booking_end_date_calendar_open && from != '') { 405 // When user clicks a To Date in Design 3 with all fields filled 406 $(".ph-calendar-overlay").show(); 407 from_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 408 $('.element_to_date').val(from_date); 409 $is_booking_end_date_clicked = true; 410 $('.element_to_time').val(''); 411 } 412 else if ($is_booking_end_date_calendar_open && from == '') { 413 // When user clicks a To Date in Design 3 and the previous selection was invali
413d 414 $(".ph-date-from").val($ph_date_from_previous_value); 415 $(".ph-calendar-overlay").show(); 416 $is_booking_end_date_clicked = true; 417 $('.element_to_date').val(''); 418 $('.element_to_time').val(''); 419 var current_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 420 $(".element_to_date").val(current_date); 421 $('.element_to_time').trigger('click'); 422 $('.element_to_time').focus(); 423 } 424 else if (from == '' || (from != '' && to != '')) { 425 $(".ph-calendar-overlay").show(); 426 from_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 427 $('.element_from_date').val(from_date).change(); 428 $('.element_from_time').val(''); 429 $('.element_from_time').scrollTop(); 430 $('.element_from_time').trigger('click'); 431 $('.element_from_time').focus(); 432 $('.element_to_date').val(''); 433 $('.element_to_time').val(''); 434 } else { 435 $(".ph-calendar-overlay").show(); 436 to_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 437 $('.element_to_date').val(to_date); 438 $('.element_to_time').val(''); 439 $('.element_to_time').scrollTop(); 440 $('.element_to_time').trigger('click'); 441 $('.element_to_time').focus(); 442 } 443 444 var data = { 445 action: 'phive_get_booked_datas_of_date', 446 product_id: product_id, 447 date: $('.timepicker-selected-date .callender-full-date').val(), 448 type: 'time-picker', 449 asset: $(".input-assets").val() 450 }; 451 // $is_booking_end_date_calendar_open = false; 452 453 jQuery(".ph-calendar-date").prop('disabled', true); 454 $.post(phive_booking_ajax.ajaxurl, data, function (res) { 455 456 $(".ph-calendar-overlay").hide(); 457 jQuery(".ph-calendar-date").prop('disabled', false); 458 // $("#ph-calendar-time").html(res).trigger('change'); 459 460 if ($('#calendar_design').val() == '3') { 461 $('.time-calendar-date-section').hide(); 462 $('.ph-calendar-container .time-picker').show(); 463 } 464 $(".ph-ul-time").html(res); 465 // change slot time as end time while showing time calendar for end time 466 if ($('#calendar_design').val() == '3') { 467 // if (from != '' && to == '') { 468 // This was inside IF earlier 469 if ($is_booking_end_date_calendar_open) { 470 $('.ph_calendar_time_start').hide(); 471 $('.ph_calendar_time_end').show(); 472 } 473 } 474 $('#ph-calendar-time').trigger('change'); 475 $(this).addClass("timepicker-selected-date"); 476 $(".booking-info-wraper").html(''); 477 $is_booking_end_date_calendar_open = false; 478 }); 479 480 }); 481 482 function convert_date_to_wp_format(date) { 483 var wp_date_format = jQuery("#ph_booking_wp_date_format").val(); 484 date = ph_convert_date_to_wp_date_format(wp_date_format, date); 485 return date; 486 } 487});
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.