1/** 2 * >= Business Medium ... 3 */ 4 5 /** 6 * Save initial values of days selection for later use in conditional day logic. Load it, when start the page. 7 * 8 * @param resource_id 9 */ 10 function wpbc__conditions__SAVE_INITIAL__days_selection_params__bm( resource_id ){ 11 12 // Save it only ONCE initial values of variables: ... 13 if ( _wpbc.calendar__is_defined( resource_id ) ){ 14 15 _wpbc.calendar__set_param_value( resource_id, 'saved_variable___days_select_initial' 16 , { 17 'dynamic__days_min' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__days_min' ), 18 'dynamic__days_max' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__days_max' ), 19 'dynamic__days_specific' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__days_specific' ), 20 'dynamic__week_days__start' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__week_days__start' ), 21 22 'fixed__days_num' : _wpbc.calendar__get_param_value( resource_id, 'fixed__days_num' ), 23 'fixed__week_days__start' : _wpbc.calendar__get_param_value( resource_id, 'fixed__week_days__start' ) 24 } 25 ); 26 } 27 } 28 29 30 /** 31 * Define First selected date for start conditional dates selection 32 * 33 * @param all_dates date object | string 34 * @param resource_id int | string e.g. '1' 35 * @returns {boolean} 36 */ 37 function wpbc__conditions__for_range_days__first_date__bm( all_dates, resource_id ){ 38 39 if ( '' == all_dates ) { return false; } // If no days selections so then skip all. 40 41 if ( ( 'dynamic' != _wpbc.calendar__get_param_value( resource_id, 'days_select_mode' ) ) 42 && ( 'fixed' != _wpbc.calendar__get_param_value( resource_id, 'days_select_mode' ) ) 43 ) { return false; } // This conditional logic is possible only if the range days selection 44 45 var selected_first_day = all_dates; 46 47 if ( typeof (all_dates) == 'object' ){ // H I G H L I G H T // If this parameter is object (Date), then we highlight the dates 48 49 all_dates = document.getElementById( 'date_booking' + resource_id ).value; // Get dates from the textarea date booking to '' 50 if ( all_dates != '' ){ // If some date is selected 51 var first_date = get_first_day_of_selection( all_dates ); // So we are NOT MAKE changing of highlighting if its was first click. 52 var last_date = get_last_day_of_selection( all_dates ); 53 if ( 54 ( 'fixed' !== _wpbc.calendar__get_param_value( resource_id, 'days_select_mode' ) ) 55 && ( first_date == last_date ) 56 ){ // FixIn: 8.4.4.8. 57 return false; 58 } 59 } 60 } else { // S E L E C T 61 var first_date = get_first_day_of_selection( all_dates ); 62 var last_date = get_last_day_of_selection( all_dates ); 63 if ( first_date != last_date ){ 64 return false; // We are clicked second time 65 } 66 var date_sections = first_date.split( "." ); 67 selected_first_day = new Date; 68 selected_first_day.setFullYear( parseInt( date_sections[ 2 ] - 0 ), parseInt( date_sections[ 1 ] - 1 ), parseInt( date_sections[ 0 ] - 0 ) ); 69 } 70 71 wpbc__conditions__set_NUMBER_OF_DAYS_TO_SELECT__depend_on_date__bm( selected_first_day, resource_id ); 72 } 73 74 75 /** 76 * Update dates selection parameters ( NUMBER_OF_DAYS_TO_SELECT) depends on belong current date to specific week 77 * day or season 78 * 79 * @param selected_first_date date, which we check for conditions 80 * @param resource_id booking resource ID 81 * @returns {boolean} 82 */ 83 function wpbc__conditions__set_NUMBER_OF_DAYS_TO_SELECT__depend_on_date__bm( selected_first_date, resource_id ){ 84 85 var is_condition_applied = false; 86 87 var class_day = wpbc__get__td_class_date( selected_first_date ); 88 var sql_class_date = wpbc__get__sql_class_date( selected_first_date ); 89 90 if ( jQuery( '#calendar_booking' + resource_id + ' .datepick-days-cell.cal4date-' + class_day ).length <= 0 ){ 91 return false; // This date is not exist :( Why ? 92 } 93 var css_classes_date_arr = jQuery( '#calendar_booking' + resource_id + ' .datepick-days-cell.cal4date-' + class_day ).attr( 'class' ).split( /\s+/ ); 94 95 96 /** 97 * S E A S O N C O N D I T I O N S - 2.0 98 * 99 * _wpbc.calendar__get_param_value(3,'conditions')['select-day']['season'] [0]['for'] = 100 * 'september_2023' <- season name to check 101 * _wpbc.calendar__get_param_value(3,'conditions')['select-day']['season'] [0]['value'] = 102 * '3,4,5' <- number of days to select 103 */ 104 var conditions = _wpbc.calendar__get_param_value( resource_id, 'conditions' ); 105 var single_css_date_class; 106 var days_arr; 107 if ( 108 ( null !== conditions ) 109 && ( 'undefined' !== typeof (conditions[ 'select-day' ]) ) 110 && ( 'undefined' !== typeof (conditions[ 'select-day' ]['season']) ) 111 && ( conditions[ 'select-day' ][ 'season' ].length > 0 ) 112 ){ 113 for ( var i = 0; i < css_classes_date_arr.length; i++ ){ 114 115 single_css_date_class = css_classes_date_arr[i]; 116 117 // S E A S O N F I L T E R C O N D I T I O N S - checking 118 if ( single_css_date_class.indexOf( 'wpdevbk_season_' ) >= 0 ){ 119 120 single_css_date_class = single_css_date_class.replace( 'wpdevbk_season_', '' ); 121 122 for ( var j = 0; j < conditions[ 'select-day' ][ 'season' ].length; j++ ){ 123 124 if ( single_css_date_class === conditions[ 'select-day' ][ 'season' ][ j ][ 'for' ] ){ // Ok season in condition == season in a day 125 126 days_arr = conditions[ 'select-day' ][ 'season' ][ j ][ 'value' ].split( ',' ); 127 128 // Update real vars 129 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_specific', days_arr ); 130 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_min', days_arr[ 0 ] ); 131 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_max', days_arr[ (days_arr.length - 1) ] ); 132 _wpbc.calendar__set_param_value( resource_id, 'fixed__days_num', days_arr[ 0 ] ); 133 134 is_condition_applied = true; 135 } 136 } 137 } 138 } 139 } 140 141 142 /** 143 * W E E K D A Y S C O N D I T I O N S - 2.0 144 * 145 * _wpbc.calendar__get_param_value(3,'conditions')['select-day']['weekday'] [0]['for'] = 146 * '5' <- number of Week day 147 * _wpbc.calendar__get_param_value(3,'conditions')['select-day']['weekday'] [0]['value'] = 148 * '3,7' <- number of days to select 149 */ 150 if ( 151 ( null !== conditions ) 152 && ( 'undefined' !== typeof (conditions[ 'select-day' ]) ) 153 && ( 'undefined' !== typeof (conditions[ 'select-day' ]['weekday']) ) 154 && ( conditions[ 'select-day' ][ 'weekday' ].length > 0 ) 155 ){ 156 157 for ( var j = 0; j < conditions[ 'select-day' ][ 'weekday' ].length; j++ ){ 158 159 if ( selected_first_date.getDay() == conditions[ 'select-day' ][ 'weekday' ][ j ][ 'for' ] ){ // Ok weekday condition == a week day of day 160 161 days_arr = conditions[ 'select-day' ][ 'weekday' ][ j ][ 'value' ].split( ',' ); 162 163 // Update real vars 164 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_specific', days_arr ); 165 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_min', days_arr[ 0 ] ); 166 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_max', days_arr[ (days_arr.length - 1) ] ); 167 _wpbc.calendar__set_param_value( resource_id, 'fixed__days_num', days_arr[ 0 ] ); 168 169 is_condition_applied = true; 170 } 171 } 172 } 173 174 175 /** 176 * D A T E S C O N D I T I O N S - New 177 * 178 * _wpbc.calendar__get_param_value(3,'conditions')['select-day']['date'][0]['for'] = 179 * '2023-08-22' <- Date 180 * _wpbc.calendar__get_param_value(3,'conditions')['select-day']['date'][0]['value'] = 181 * '3,7' <- number of days to select 182 */ 183 if ( 184 ( null !== conditions ) 185 && ( 'undefined' !== typeof (conditions[ 'select-day' ]) ) 186 && ( 'undefined' !== typeof (conditions[ 'select-day' ]['date']) ) 187 && ( conditions[ 'select-day' ][ 'date' ].length > 0 ) 188 ){ 189 190 for ( var j = 0; j < conditions[ 'select-day' ][ 'date' ].length; j++ ){ 191 192 if ( sql_class_date == conditions[ 'select-day' ][ 'date' ][ j ][ 'for' ] ){ // Ok date condition == a date of selected day 193 194 days_arr = conditions[ 'select-day' ][ 'date' ][ j ][ 'value' ].split( ',' ); 195 196 // Update real vars 197 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_specific', days_arr ); 198 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_min', days_arr[ 0 ] ); 199 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_max', days_arr[ (days_arr.length - 1) ] ); 200 _wpbc.calendar__set_param_value( resource_id, 'fixed__days_num', days_arr[ 0 ] ); 201 202 is_condition_applied = true; 203 } 204 } 205 } 206 207 208 // Reset to the global, if conditional parameters was not applied 209 if ( false === is_condition_applied ) { 210 211 var saved_variable___days_select_initial = _wpbc.calendar__get_param_value( resource_id, 'saved_variable___days_select_initial' ); 212 213 // Update real vars 214 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_specific', saved_variable___days_select_initial['dynamic__days_specific'] ); 215 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_min', saved_variable___days_select_initial['dynamic__days_min'] ); 216 _wpbc.calendar__set_param_value( resource_id, 'dynamic__days_max', saved_variable___days_select_initial['dynamic__days_max'] ); 217 _wpbc.calendar__set_param_value( resource_id, 'fixed__days_num', saved_variable___days_select_initial['fixed__days_num'] ); 218 } 219 220 } 221 222 223 /** 224 * Update dates selection parameters ( START_WEEK_DAY) depends on belong current date to specific season 225 * 226 * @param resource_id int 227 * @param selected_first_date JS date 228 * @param is_start_or_end 'start' | 'end' 229 * @returns {boolean} 230 */
231 function wpbc__conditions__set_START_WEEK_DAY__depend_on_season__bm( resource_id, selected_first_date, is_start_or_end ){ 232 233 if ( 'start' == is_start_or_end ){ 234 235 var class_day = wpbc__get__td_class_date( selected_first_date ); 236 // var sql_class_date = wpbc__get__sql_class_date( selected_first_date ); 237 238 if ( jQuery( '#calendar_booking' + resource_id + ' .datepick-days-cell.cal4date-' + class_day ).length <= 0 ){ 239 return false; // This date is not exist :( Why ? 240 } 241 var css_classes_date_arr = jQuery( '#calendar_booking' + resource_id + ' .datepick-days-cell.cal4date-' + class_day ).attr( 'class' ).split( /\s+/ ); 242 243 244 /** 245 * START_WEEK_DAY from S E A S O N - 2.0 246 * 247 * _wpbc.calendar__get_param_value(3,'conditions')['start-day']['season'][0]['for'] = 248 * 'september_2023' <- season name to check 249 * _wpbc.calendar__get_param_value(3,'conditions')['start-day']['season'][0]['value'] = 250 * '2,5,6' <- Week Days to start selection 251 */ 252 var conditions = _wpbc.calendar__get_param_value( resource_id, 'conditions' ); 253 var single_css_date_class; 254 var days_arr; 255 if ( 256 ( null !== conditions ) 257 && ( 'undefined' !== typeof (conditions[ 'start-day' ]) ) 258 && ( 'undefined' !== typeof (conditions[ 'start-day' ]['season']) ) 259 && ( conditions[ 'start-day' ][ 'season' ].length > 0 ) 260 ){ 261 for ( var i = 0; i < css_classes_date_arr.length; i++ ){ 262 263 single_css_date_class = css_classes_date_arr[i]; 264 265 // S E A S O N F I L T E R C O N D I T I O N S - checking 266 if ( single_css_date_class.indexOf( 'wpdevbk_season_' ) >= 0 ){ 267 268 single_css_date_class = single_css_date_class.replace( 'wpdevbk_season_', '' ); 269 270 for ( var j = 0; j < conditions[ 'start-day' ][ 'season' ].length; j++ ){ 271 272 if ( single_css_date_class === conditions[ 'start-day' ][ 'season' ][ j ][ 'for' ] ){ // Ok season in condition == season in a day 273 274 days_arr = conditions[ 'start-day' ][ 'season' ][ j ][ 'value' ].split( ',' ); 275 276 // Update real vars 277 _wpbc.calendar__set_param_value( resource_id, 'dynamic__week_days__start' , days_arr ); 278 _wpbc.calendar__set_param_value( resource_id, 'fixed__week_days__start' , days_arr ); 279 } 280 } 281 } 282 } 283 } 284 } 285 286 287 // START_WEEK_DAY Back to INITIAL params 288 if ( 'end' == is_start_or_end ){ 289 290 var saved_variable___days_select_initial = _wpbc.calendar__get_param_value( resource_id, 'saved_variable___days_select_initial' ); 291 _wpbc.calendar__set_param_value( resource_id, 'dynamic__week_days__start', saved_variable___days_select_initial[ 'dynamic__week_days__start' ] ); 292 _wpbc.calendar__set_param_value( resource_id, 'fixed__week_days__start', saved_variable___days_select_initial[ 'fixed__week_days__start' ] ); 293 } 294 295 } 296 297 298/** 299 * Calendar Day Cell Bottom - Get daily cost for specific date 300 * 301 * usually used for showing daily cost in bottom of calendar date cell 302 * 303 * @param param_calendar_id {string} ID of calendar - booking resource 304 * @param my_thisDateTime {Date} JavaScript date 305 * @returns {string} Cost - formatted - like "$ 95.99" 306 */ 307function wpbc_show_day_cost_in_date_bottom( param_calendar_id, my_thisDateTime ) { 308 309 var resource_id = parseInt( param_calendar_id.replace( "calendar_booking", '' ) ); 310 311 // console.log( _wpbc.bookings_in_calendar__get( resource_id ) ); // for debug 312 313 // 1. Get child booking resources or single booking resource that exist in dates : [1] | [1,14,15,17] 314 // var child_resources_arr = wpbc_clone_obj( _wpbc.booking__get_param_value( resource_id, 'resources_id_arr__in_dates' ) ); 315 316 // '2023-08-21' 317 var sql_date = wpbc__get__sql_class_date( new Date( my_thisDateTime ) ); 318 319 var hint__in_day__cost = ''; 320 321 var get_for_date_obj = _wpbc.bookings_in_calendar__get_for_date( resource_id, sql_date ); 322 323 if ( false !== get_for_date_obj ){ 324 325 if ( 326 (undefined != get_for_date_obj[ 'summary' ]) 327 && (undefined != get_for_date_obj[ 'summary' ].hint__in_day__cost) 328 ){ 329 hint__in_day__cost = get_for_date_obj[ 'summary' ].hint__in_day__cost; // "25.00£" 330 } 331 332 } 333 334 return hint__in_day__cost; 335} 336 337 338/** 339 * Admin Panel - Booking > Settings > Form page -- Delete custom form 340 * 341 * @param form_name 342 * @param user_id 343 * @returns {boolean} 344 */
345function wpbc_delete_custom_booking_form( form_name, user_id ){ 346 347 wpbc_admin_show_message_processing( 'deleting' ); 348 349 jQuery.ajax({ // Start Ajax Sending 350 url: wpbc_url_ajax, 351 type:'POST', 352 success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );}, 353 error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {console.error( 'Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}}, 354 // beforeSend: someFunction, 355 data:{ 356 action : 'DELETE_BK_FORM', 357 formname : form_name, 358 user_id: user_id, 359 wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce').value 360 } 361 }); 362 return false; 363} 364 365 366/** 367 * Admin Panel - Booking > Settings > Form page -- Change custom form 368 * 369 * @param selectObj 370 */ 371function wpbc_change_custom_booking_form_in_url__and_reload(selectObj){ 372 373 var idx = selectObj.selectedIndex; 374 var my_form = selectObj.options[idx].value; 375 376 var loc = location.href; 377 if (loc.substr((loc.length-1),1)=='#') { 378 loc = loc.substr(0,(loc.length-1) ); 379 } 380 381 if ( loc.indexOf('booking_form=') == -1 ) { 382 loc = loc + '&booking_form=' +my_form;} 383 else { // Alredy have this paremeter at URL 384 var start = loc.indexOf('&booking_form='); 385 var fin = loc.indexOf('&', (start+15)); 386 if (fin == -1) {loc = loc.substr(0,start) + '&booking_form=' +my_form;} // at the end of row 387 else { // at the middle of the row 388 var loc1 = loc.substr(0,start) + '&booking_form=' +my_form;//alert(loc) 389 loc = loc1 + loc.substr(fin); 390 } 391 } 392 location.href = loc; 393} 394 395 396/** 397 * Show mini Spin Loaders in All Hint Elements in specific booking form 398 * 399 * @param resource_id 400 */ 401function wpbc__spin_loader__mini__in_all_elements_of_booking_form__show( resource_id ){ 402 403 var submit_form = document.getElementById( 'booking_form' + resource_id ); 404 var element; 405 var i; 406 var count; 407 408 if ( submit_form != null ){ 409 410 count = submit_form.elements.length; 411 412 for ( i = 0; i < count; i++ ){ 413 element = submit_form.elements[ i ]; 414 // Calculation in process ... 415 416 wpbc__spin_loader__mini__show( 'bookinghint_' + element.id, {'show_here': {'where': 'inside'}} ); 417 wpbc__spin_loader__mini__show( 'class_bookinghint_' + element.id, { 418 'show_here': { 419 'where' : 'inside', 420 'jq_node': '.bookinghint_' + element.id 421 } 422 } ); 423 424 } 425 } 426} 427 428 429/** 430 * Get Values from all form fields in booking form and convert it to String 431 * 432 * @param resource_id 433 * @returns {string} 434 */ 435function wpbc_get__booking_form__fields_val__as_string( resource_id ) { 436 437 var submit_form = document.getElementById( 'booking_form' + resource_id ); 438 var formdata = ''; 439 440 if ( submit_form != null ) { 441 442 var form_fields_count = submit_form.elements.length; 443 var inp_value; 444 var element; 445 var el_type; 446 447 // Serialize form here 448 for ( var i = 0; i < form_fields_count; i++ ) { 449 450 element = submit_form.elements[ i ]; 451 452 // Skip buttons and hidden elements and calendar textarea 453 if ( 454 (element.type !== 'button') && 455 (element.type !== 'hidden') && 456 (element.name !== ('date_booking' + resource_id)) && 457 (element.name !== ('captcha_input' + resource_id) ) 458 ){ 459 460 // Element Value --------------------------------------------------------------------------------------- 461 if ( element.type == 'checkbox' ) { 462 463 if ( '' === element.value ) { 464 inp_value = element.checked; 465 } else { 466 inp_value = (element.checked) ? element.value : ''; 467 } 468 469 } else if ( element.type == 'radio' ) { 470 471 if ( element.checked ) { 472 inp_value = element.value; 473 } else { 474 continue; 475 } 476 477 } else { 478 inp_value = element.value; 479 } 480 481 // Get value in select-box of multiple selection 482 if ( (element.type == 'selectbox-multiple') || (element.type == 'select-multiple') ) { 483 inp_value = jQuery( '[name="' + element.name + '"]' ).val(); 484 if ( (inp_value == null) || (inp_value.toString() == '') ) { 485 inp_value = ''; 486 } 487 } 488 489 // Element Type ---------------------------------------------------------------------------------------- 490 el_type = element.type; 491 492 el_type = (element.className.indexOf( 'wpdev-validates-as-email' ) !== -1) ? 'email' : el_type; 493 el_type = (element.className.indexOf( 'wpdev-validates-as-coupon' ) !== -1) ? 'coupon' : el_type; 494 el_type = ('select-one' == el_type) ? 'selectbox-one' : el_type; 495 el_type = ('select-multiple' == el_type) ? 'selectbox-multiple' : el_type; 496 497 498 // Next field element 499 if ( formdata !== '' ) { 500 formdata += '~'; 501 } 502 formdata += el_type + '^' + element.name + '^' + inp_value; 503 } 504 } 505 } 506 507 return formdata; 508} 509 510 511/** 512 * Send Ajax Request to show cost/dates == H I N T S == in the booking form 513 * 514 * @param resource_id 515 * @returns {boolean} 516 */
517function wpbc_send_ajax__show_cost_hints( resource_id ){ 518 519 jQuery( ".booking_form_div" ).trigger( "before_show_cost_hints", [resource_id] ); 520 521 // It's means that we get cost hint clicking at additional calendar 522 if ( document.getElementById( 'parent_of_additional_calendar' + resource_id ) !== null ) { 523 resource_id = document.getElementById( 'parent_of_additional_calendar' + resource_id ).value; // Get parent bk type from additional calendar 524 } 525 526 if ( 0 === jQuery( '#booking_form' + resource_id ).find( '.wpbc_field_hint' ).length ) { // FixIn: 9.9.0.20. 527 return false; 528 } 529 530 var all_dates = jQuery( '#date_booking' + resource_id ).val(); 531 var formdata = wpbc_get__booking_form__fields_val__as_string( resource_id ); 532 533 // Calculation in process ... Spinner start 534 wpbc__spin_loader__mini__in_all_elements_of_booking_form__show( resource_id ); 535 536 // Known Hint shortcodes 537 var elements_arr = [ 538 'booking_hint', 539 'estimate_booking_day_cost_hint', 540 'estimate_booking_night_cost_hint', 541 'additional_booking_hint', 542 'original_booking_hint', 543 'deposit_booking_hint', 544 'coupon_discount_booking_hint', 545 'balance_booking_hint', 546 'cancel_date_hint_tip', 547 'pre_checkin_date_hint_tip', 548 'check_in_date_hint_tip', 549 'check_out_date_hint_tip', 550 'check_out_plus1day_hint_tip', 551 'start_time_hint_tip', 552 'end_time_hint_tip', 553 'selected_dates_hint_tip', 554 'selected_timedates_hint_tip', 555 'selected_short_dates_hint_tip', 556 'selected_short_timedates_hint_tip', 557 'days_number_hint_tip', 558 'nights_number_hint_tip' 559 ]; 560 561 for ( let el_i = 0; el_i < elements_arr.length; el_i++ ) { 562 wpbc__spin_loader__micro__show__inside( elements_arr[ el_i ] + resource_id, 563 '#' + elements_arr[ el_i ] + resource_id + 564 ',.' + elements_arr[ el_i ] + resource_id ); 565 } 566 567 if ( 'dynamic' === _wpbc.calendar__get_param_value( resource_id, 'days_select_mode' ) ) { 568 var inst = wpbc_calendar__get_inst( resource_id ); 569 jQuery( '.wpbc_select_check_out_date_message' ).remove(); 570 if ( 571 ( null !== inst ) 572 && (inst.stayOpen === true) 573 ) { 574 // jQuery('#date_booking' + resource_id).after( '<div class="wpbc_select_check_out_date_message wpbc_front_end__message_container_left0"><div class="wpbc_front_end__message wpbc_fe_message_info">' + 'Please click on check out day to finish days selection' + '</div></div>'); 575 576 // Comment these 2 lines, if we need to show cost hints, if selected only 1 day 577 jQuery( '.wpbc_ajax_loader,.wpbc_field_hint' ).html( '...' ); 578 return false; 579 } 580 } 581 582 var my_booking_form_name = ''; 583 if ( document.getElementById( 'booking_form_type' + resource_id ) != undefined ) { 584 my_booking_form_name = document.getElementById( 'booking_form_type' + resource_id ).value; 585 } 586 587 var ajax_type_action = 'CALCULATE_THE_COST'; 588 var ajax_request_data = { 589 action : ajax_type_action, 590 form : formdata, 591 all_dates : all_dates, 592 bk_type : resource_id, 593 booking_form_type : my_booking_form_name, 594 wpdev_active_locale: _wpbc.get_other_param( 'locale_active' ), 595 wpbc_nonce : document.getElementById( 'wpbc_nonce' + ajax_type_action + resource_id ).value 596 }; 597 jQuery( document ).trigger( 'wpbc_before_cost_request', [ resource_id, ajax_request_data ] ); 598 599 jQuery.ajax({ // Start Ajax Sending 600 url : wpbc_url_ajax, 601 type : 'POST', 602 success: function ( data, textStatus ) { 603 if ( textStatus == 'success' ) { 604 jQuery( '#ajax_respond_insert' + resource_id ).html( data ); 605 } 606 jQuery( ".booking_form_div" ).trigger( "after_show_cost_hints", [resource_id] ); 607 }, 608 error: function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {console.error( 'Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}}, 609 data: ajax_request_data 610 }); 611 jQuery( ".booking_form_div" ).trigger( "show_cost_hints", [resource_id] ); // FixIn: 7.0.1.53. 612 jQuery( ".booking_form_div" ).trigger( "wpbc_booking_date_or_option_selected", [resource_id] ); 613 return false;
614} 615 616 617// FixIn: 10.8.1.3. 618/** 619 * Send request after few seconds (usually after 0,25 sec) 620 * Closure function. It's useful for not sending too many Ajax requests... 621 * 622 * $resource_id=4; 623 * wpbc_show_cost_hints_after_few_seconds( $resource_id 624 * ); // Send after 0.25 seconds 625 * wpbc_show_cost_hints_after_few_seconds( $resource_id, 0 626 * ); // Immediate Send 627 */ 628var wpbc_show_cost_hints_after_few_seconds = function (){ 629 630 var closed_timer = 0; 631 632 return function ( resource_id, timer_delay ){ 633 634 // Get default value of "timer_delay", if parameter was not passed into the function. 635 timer_delay = typeof timer_delay !== 'undefined' ? timer_delay : 250; 636 637 clearTimeout( closed_timer ); // Clear previous timer 638 639 // Start new Timer 640 closed_timer = setTimeout( wpbc_send_ajax__show_cost_hints.bind( null, resource_id ), timer_delay ); 641 } 642}(); 643 644jQuery( 'body' ).on( 645 'wpbc_calendar_ajx__loaded_data', 646 function (event, loaded_resource_id) { 647 wpbc_show_cost_hints_after_few_seconds( loaded_resource_id ); 648 } 649); 650 651// Legacy function support. 652function showCostHintInsideBkForm(resource_id) { 653 wpbc_show_cost_hints_after_few_seconds( resource_id ); 654}
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.