1 2 3if (document.LDSSearch == undefined) { document.LDSSearch = {}; } 4 5jQuery(document).ready(function($) { 6 7 8 var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0) 9 if (!touchsupport){ // browser doesn't support touch 10 document.documentElement.className += " non-touch" 11 } 12 13 // Make sure submit button isn't disabled if the user navigates back in firefox 14 $('#LDSSearch-submit button').prop('disabled', false).removeClass('disabled'); 15 16 Date.prototype.toLDSDate = function() { 17 var year = this.getFullYear(); 18 var day = this.getDate() + 1; 19 var month = this.getMonth() + 1; 20 21 return year + "-" + month + "-" + day; 22 } 23 24 25 /* do fade panel for client logins or whatever to fade/slide in when the panel is hovered over */ 26 if ($(".levartFadePanel").length) { 27 28 $(".levartFadePanel").each(function() { 29 if ($(this).hasClass("levartFadeSlide")) { 30 $(this).attr("originalHeight", $(this).innerHeight()); 31 $(this).css('height', 0); 32 } 33 }); 34 35 $("#LDSSearch").on('mouseenter', function() { 36 $(".levartFadePanel").each(function() { 37 if ($(this).hasClass("levartFadeSlide")) { 38 $(this).stop().show().animate({'height': $(this).attr("originalHeight")}); 39 } else 40 $(this).stop().fadeTo(600, 1); 41 }); 42 }); 43 $("#LDSSearch").on('mouseleave', function() { 44 $(".levartFadePanel").each(function() { 45 if ($(this).hasClass("levartFadeSlide")) { 46 $(this).stop().animate({'height': 0}, 400, function() { 47 $(this).hide(); 48 }); 49 } else 50 $(this).stop().fadeTo(600, 0); 51 }); 52 }); 53 } 54 /* End: Fade panel code */ 55 56 57 // GENERAL THINGS WE FIND ON A CALENDAR INITIALIZATION... (EG DATES, NIGHTS SELECTOR ETC.) 58 var arriveMinObj = new Date($('#LDSSearch input[name=propertyDate]').val()); 59 if ($("input[name=fromDateActual]").val() == "") { 60 $("input[name=fromDateActual]").val(arriveMinObj.toLDSDate()); 61 62 var newToDate = new Date(arriveMinObj); 63 newToDate.setDate(arriveMinObj.getDate() + 1); 64 $("input[name=toDateActual]").val(newToDate.toLDSDate()); 65 66 } 67 68 69 70 var monthsDisplay = 2 71 if ($(window).width() < 1030) { 72 monthsDisplay = 1; 73 $(".LDS-popup-close.closeBtn").show(); 74 } 75 76 77 const CLOSED_FLAG = 1, 78 CA_FLAG = 2, 79 CD_FLAG = 4, 80 DATE_FORMAT = 'yy-mm-dd'; 81 82 // Local helper functions (always available, even if $.datepicker loads late) 83 function parseDateISO(date) { 84 return $.datepicker.parseDate(DATE_FORMAT, date); 85 } 86 function formatDateISO(date) { 87 return $.datepicker.formatDate(DATE_FORMAT, date); 88 } 89 function getFromDate() { 90 return parseDateISO($("input[name=fromDateActual]").val()); 91 } 92 function getToDate() { 93 return parseDateISO($("input[name=toDateActual]").val()); 94 } 95 function getPropertyDate() { 96 return document.LDSSearch.propertyDate; 97 } 98 function isValidRange(arrival, departure) { 99 if (!arrival) { 100 return [false, 'No arrival date']; 101 } 102 if (!departure) { 103 return [false, 'No departure date']; 104 } 105 106 var today = getPropertyDate(), 107 arrivalFormatted = formatDateISO(arrival), 108 departureFormatted = formatDateISO(departure), 109 propAvail = document.LDSSearch.propAvail, 110 nights = (departure.getTime() - arrival.getTime()) / (1000 * 86400); 111 112 if (arrival < today) { 113 return [false, 'Arrival must be earlier than today']; 114 } 115 if (departure <= arrival) { 116 return [false, 'Departure must be after arrival date']; 117 } 118 119 if (typeof propAvail?.[arrivalFormatted]?.[0] === 'undefined' || typeof propAvail?.[departureFormatted]?.[0] === 'undefined') { 120 return [false, 'Incorrect dates selected. Please try again.']; 121 } 122 123 if (propAvail[arrivalFormatted][0] & CA_FLAG) { 124 return [false, 'Arrival not permitted on ' + $.datepicker.formatDate('d MM yy', arrival)]; 125 } 126 if (propAvail[departureFormatted][0] & CD_FLAG) { 127 return [false, 'Departure not permitted on ' + $.datepicker.formatDate('d MM yy', departure)]; 128 } 129 130 var loop = new Date(arrival); 131 while (loop < departure){ 132 var dateFormatted = formatDateISO(loop); 133 var mlos = propAvail[dateFormatted][1]; 134 135 if (propAvail[dateFormatted][0] & CLOSED_FLAG) { 136 return [false, $.datepicker.formatDate('d MM yy', loop) + ' is currently sold out']; 137 } 138 139 if (mlos > nights) { 140 return [false, $.datepicker.formatDate('d MM yy', loop) + ' has a minimum stay of '+ mlos + ' nights']; 141 } 142 143 loop.setDate(loop.getDate() + 1); 144 } 145 146 return [true, '']; 147 } 148 149 // Extend $.datepicker with custom methods (for backward compatibility) 150 if ($.datepicker) { 151 $.datepicker._updateDatepicker_original = $.datepicker._updateDatepicker; 152 $.datepicker._updateDatepicker = function(inst) { 153 $.datepicker._updateDatepicker_original(inst); 154 var afterShow = this._get(inst, 'afterShow'); 155 if (afterShow) { 156 afterShow.apply((inst.input ? inst.input[0] : null)); // trigger custom callback 157 } 158 } 159 160 $.datepicker.parseDateISO = parseDateISO; 161 $.datepicker.formatDateISO = formatDateISO; 162 $.datepicker.getFromDate = getFromDate; 163 $.datepicker.getToDate = getToDate; 164 $.datepicker.getPropertyDate = getPropertyDate; 165 $.datepicker.isValidRange = isValidRange; 166 } 167 168 169 $("#LDSSearch #fromDate").on('click', function() { 170 if ($('.ui-datepicker').hasClass('datepicker-package')) { 171 $('.ui-datepicker').removeClass('datepicker-package') 172 } 173 $('.ui-datepicker').show(); 174 }); 175 176 $("#LDSSearch #toDate").on('click', function () { 177 if ($('.ui-datepicker').hasClass('datepicker-package')) { 178 $('.ui-datepicker').removeClass('datepicker-package') 179 } 180 // #toDate is not a datepicker â drive the shared picker via #fromDate so the popup 181 // is materialised on first click (lazily created by jQuery UI on .datepicker('show')). 182 // .datepicker('show') steals focus to #fromDate; restore it to #toDate so the user's 183 // focus tracks the field they actually clicked (and no focus ring on arrival). 184 $("#LDSSearch #fromDate").datepicker("show"); 185 $("#LDSSearch #toDate").trigger("focus"); 186 return false;
187 }); 188 189 $("#LDSSearch #fromDate").datepicker({ 190 minDate: arriveMinObj, 191 maxDate: "2y -1d", 192 dateFormat: "d M yy", 193 selectMultiple: true, 194 displayClose: true, 195 inline: true, 196 firstDay: 1, 197 showButtonPanel: true, 198 numberOfMonths: [1, monthsDisplay], 199 onChangeMonthYear: function () { 200 201 }, 202 beforeShow: function(input, inst) { 203 // Guard against offset() returning undefined (hidden/detached elements) - Fixes LEVART-2X 204 if (!$(input).is(':visible') || !$(input).offset()) { 205 return false; 206 } 207 $('.bookingPanel').css({ 208 'position': 'relative', 209 'z-index' : '9999' 210 }); 211 }, 212 beforeShowDay: function (date) { 213 var availClass = '', 214 propAvail = document.LDSSearch.propAvail, 215 dateFormatted = formatDateISO(date), 216 today = getPropertyDate(), 217 fromDate = getFromDate(), 218 toDate = getToDate(); 219 220 if (propAvail[dateFormatted] != undefined) { 221 222 var flags = propAvail[dateFormatted][0], 223 mlos = propAvail[dateFormatted][1]; 224 225 var isArrivalDay = toDate && toDate.getTime() == date.getTime(), 226 isDepartureDay = fromDate && fromDate.getTime() == date.getTime(), 227 idDuringStay = fromDate && toDate && date > fromDate && date < toDate; 228 229 var isClosed = Boolean(flags & CLOSED_FLAG), 230 isCA = Boolean(flags & CA_FLAG), 231 isCD = Boolean(flags & CD_FLAG); 232 233 if (isClosed) { 234 availClass = availClass + ' sold'; 235 } else { 236 if (isCA) { 237 availClass = availClass + ' CTA'; 238 } 239 if (isCD) { 240 availClass = availClass + ' CTD'; 241 } 242 if (mlos > 1) { 243 availClass = availClass + ' mlos mlos-'+mlos; 244 } 245 } 246 247 if (isArrivalDay) { 248 availClass = availClass + ' checkOut'; 249 } else if (isDepartureDay) { 250 availClass = availClass + ' checkIn'; 251 } else if (idDuringStay) { 252 availClass = availClass + ' hover'; 253 } 254 255 var debug = (isClosed ? 'Sold Out':'') + 256 (isCA && isCD ? ' Closed to Arrivals and Departures':'') + 257 (isCA && !isCD ? ' Closed to Arrivals':'') + 258 (isCD && !isCA ? ' Closed to Departures':'') + 259 (mlos > 1 ? ' Min. Stay ' + mlos + ' nights' : ''); 260 261 return [true, availClass.trim(), debug.trim()]; 262 } else { 263 return [false, 'unavailable ui-state-disabled sold', 'Not Available']; 264 } 265 266 267 }, 268 altFormat: "yy-mm-dd", 269 showAnim: 'fadeIn', 270 onSelect: function(selectedDate, el) { 271 272 var drawMonth = $(this).data().datepicker.drawMonth; 273 274 var arrival = getFromDate(), 275 departure = getToDate(); 276 277 var instance = $(this).data("datepicker"); 278 var selectedDate = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings); 279 var selectedDateFormatted = formatDateISO(selectedDate); 280 281 $(this).data('datepicker').inline = true; 282 283 if (!arrival || selectedDate <= arrival || departure) { // New Arrival Date 284 $("#LDSSearch input[name=fromDateActual]").val(selectedDateFormatted); 285 $("#LDSSearch input[name=toDateActual], #LDSSearch input[name=toDate]").val(''); 286 287 288 } else { 289 $("#LDSSearch #fromDate").datepicker("setDate", arrival); 290 $("#LDSSearch input[name=toDateActual]").val(selectedDateFormatted); 291 $("#LDSSearch input[name=toDate]").val( $.datepicker.formatDate('d M yy', selectedDate)); 292 293 var valid = isValidRange(arrival, selectedDate); 294 if (valid[0]) { 295 $(".ui-datepicker").hide(); 296 } else { 297 $('.ui-datepicker-current').text(valid[1]); 298 $('.ui-datepicker-current').addClass('warning'); 299 $('#ui-datepicker-div').addClass('fullwarning'); 300 } 301 } 302 303 $("input[name=fromDateActual]").trigger("change"); 304 305 $(this).data().datepicker.drawMonth = drawMonth; 306 }, 307 afterShow: function () { 308 309 $('.ui-datepicker-close').remove(); 310 $('.ui-datepicker-current').off('click'); 311 312 var arrival = getFromDate(), 313 departure = getToDate(); 314 315 if (arrival && departure) { 316
317 var valid = isValidRange(arrival, departure); 318 if (valid[0]) { 319 $('#ui-datepicker-div').removeClass('fullwarning'); 320 $('.ui-datepicker-current').removeClass('warning'); 321 $('.ui-datepicker-current').text('Arrival: ' + $.datepicker.formatDate('d MM yy', arrival) + ' Departure: ' + $.datepicker.formatDate('d MM yy', departure)); 322 } else { 323 $('.ui-datepicker-current').text(valid[1]); 324 $('.ui-datepicker-current').addClass('warning'); 325 $('#ui-datepicker-div').addClass('fullwarning'); 326 } 327 328 } else if (arrival && !departure) { 329 330 $('.ui-datepicker-calendar td a').each(function(i) { 331 332 var $parent = $(this).parent("td"); 333 334 //$parent.css({'background-color': ''}); 335 $parent.removeClass('unavailable'); 336 337 var month = parseInt($parent.data("month")) + 1; 338 if (month < 10) { 339 month = "0" + month 340 } 341 342 var dateStr = $parent.data("year") + "-" + month + "-" + $(this).html(); 343 var dateIter = parseDateISO(dateStr); 344 345 346 347 if (dateIter > arrival) { 348 var valid = isValidRange(arrival, dateIter); 349 if (valid[0]) { 350 //$parent.css({'background-color': '#0f0'}); 351 //$parent.addClass('available'); 352 353 } else { 354 //$parent.css({'background-color': '#f00'}); 355 $parent.addClass('unavailable'); 356 } 357 358 } 359 360 361 }); 362 363 } 364 365 // In Progress Hover Selection 366 $('.ui-datepicker-calendar td a').off("mouseenter"); 367 $('.ui-datepicker-calendar td a').on("mouseenter", function() { 368 if ($("input[name=toDateActual]").val() == "") { 369 $('.ui-datepicker-calendar td').removeClass('hover'); 370 $('.ui-datepicker-calendar td').removeClass('checkOut'); 371 var dateStr = $(this).parent("td").data("year") + "-" + (parseInt($(this).parent("td").data("month")) + 1) + "-" + $(this).html(); 372 var finishDate = parseDateISO(dateStr); 373 $('.ui-datepicker-calendar td a').each(function(i) { 374 var dateStr = $(this).parent("td").data("year") + "-" + (parseInt($(this).parent("td").data("month")) + 1) + "-" + $(this).html(); 375 var dateIter = parseDateISO(dateStr); 376 377 if (dateIter > arrival && dateIter < finishDate) { 378 $(this).parent().addClass('hover'); 379 } else if (dateIter.getTime() == finishDate.getTime()) { 380 $(this).parent().addClass('checkOut'); 381 } 382 383 }); 384 385 var valid = isValidRange(arrival, finishDate); 386 387 if (valid[0]) { 388 $('.ui-datepicker-current').text('Arrival: ' + $.datepicker.formatDate('d MM yy', arrival) + ' Departure: ' + $.datepicker.formatDate('d MM yy', finishDate)); 389 $('.ui-datepicker-current').removeClass('warning'); 390 $('#ui-datepicker-div').removeClass('fullwarning'); 391 } else if (arrival.getTime() == finishDate.getTime()) { 392 393 $('.ui-datepicker-current').removeClass('warning'); 394 $('#ui-datepicker-div').removeClass('fullwarning'); 395 $('.ui-datepicker-current').text("Select your departure date."); 396 397 } else { 398 $('.ui-datepicker-current').text(valid[1]); 399 $('.ui-datepicker-current').addClass('warning'); 400 $('#ui-datepicker-div').addClass('fullwarning'); 401 } 402 } 403 }); 404 405 406 407 } 408 }); 409 410 if ($("#LDSSearch #fromDate").length) { 411 $(document).mouseup(function(e) { 412 var container = $(".ui-datepicker"); 413 var containerDiv = $(".ui-datepicker-div"); 414 if (containerDiv.css("display") == "block" && !container.is(e.target) && container.has(e.target).length === 0) { 415 $('body .cover').hide(); 416 $(container).hide(); 417 } 418 }); 419 } 420 421 422 $('#ui-datepicker-div').addClass('notranslate'); 423 424 $("#LDSSearch #fromDateOpen").on('click', function () { 425 $("#LDSSearch #fromDate").datepicker("show"); 426 }); 427 428 $("#LDSSearch #toDateOpen").on('click', function () { 429 $("#LDSSearch #toDate").datepicker("show"); 430 }); 431 432 $("#LDSSearch .toDate-cal a").on('click', function() { 433 $('#LDSSearch #toDate').datepicker('show'); 434 return false;
435 }); 436 437 $("#LDSSearch .fromDate-cal a").on('click', function() { 438 $('#LDSSearch #fromDate').datepicker('show'); 439 return false; 440 }); 441 442 443 // if we have a # nights field... 444 if ($('#LDSSearch [name="nights"]').length > 0) { 445 446 var nightsInput = $('#LDSSearch [name="nights"]'); 447 448 $('#LDSSearch [name="fromDateActual"]').on('change', function() { 449 nightsInput.trigger('change'); 450 }); 451 452 nightsInput.on('change', function() { 453 var fromDate = $.datepicker.parseDate('yy-mm-dd',$('#LDSSearch input[name=fromDateActual]').val()); 454 455 var daysToAdd = parseInt(nightsInput.val(),10); 456 fromDate.setDate(fromDate.getDate()+daysToAdd); 457 458 $('#LDSSearch input[name=toDateActual]').val($.datepicker.formatDate('yy-mm-dd',fromDate)); 459 }); 460 461 } 462 463 464 465 // if we have our own form then submit it directly 466 $('#LDSSearch form').on('submit', function(event) { 467 return _submitLevartPanel(event); 468 }); 469 470 // if theres a form already inserted before our panel 471 if ($('#LDSSearch').closest('form').length > 0 || $('#LDSSearch form').length == 0) { 472 $('#LDSSearch #LDSSearch-submit button').on('click', function(event) { 473 return _submitLevartPanel(event); 474 }); 475 } 476 477 478 // if we can't find a form in the popup we need to attach handle for ASPX workaround 479 $('#LDSPopup .LDSPopup-form').each(function() { 480 if ($(this).find('form') > 0) 481 return false; 482 483 var formDiv = $('.LDSPopup-formelement', this); 484 $('.LDSPopup-submit',this).on('click', function(event) { 485 var inputs = ''; 486 $(':input[name]', formDiv).each(function(){ 487 inputs += '<input type="hidden" name="'+ $(this).attr('name') +'" value="'+ $(this).val() +'" />'; 488 }); 489 //Add if this id=modification then inputs+= stuff. 490 if($(this).attr('id')=="LDSPopup-modify-submit") inputs += "<input type='hidden' value='1' name='isModify' />"; 491 492 var _actionUrl = $(formDiv).attr('action'); 493 var _method = $(formDiv).attr('method'); 494 if (_method == undefined) 495 _method = "POST"; 496 497 $('<form action="'+ _actionUrl +'" method="'+_method+'">'+inputs+'</form>') 498 .appendTo('body').submit(); //.remove() 499 500 return false; 501 }); 502 503 }); // end .LDSPopup-form each 504 505 506 function _trackSubmit() { 507 var eventCategory = 'Quick Booking Widget'; 508 var eventAction = 'Successful Submit Button Click'; 509 var eventLabel = $('#searchSelectedFrom').val(); 510 if (eventLabel != undefined && !eventLabel.length) { 511 eventLabel = 'Pre-Populated'; 512 } 513 514 try {
515 window._gaq.push(['_trackEvent', eventCategory, eventAction, eventLabel]); 516 } catch (e) { } 517 518 try { 519 dataLayer.push({ 520 'event': 'gaTriggerEvent', 521 'gaEventCategory': eventCategory, 522 'gaEventAction': eventAction, 523 'gaEventLabel': eventLabel 524 }); 525 } catch (e) { } 526 } 527 528 529 530 function _submitLevartPanel(event) { 531 532 var fromValue = $('#LDSSearch :input[name=fromDateActual]').val(); 533 var toValue = $('#LDSSearch :input[name=toDateActual]').val(); 534 535 var startDate = new Date(fromValue.replace(/-/g, '/')); 536 var endDate = new Date(toValue.replace(/-/g, '/')); 537 var timeDiff = endDate - startDate; 538 daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24)); 539 540 541 // if nights is hidden just disable it... (if overriding you should be setting toDateActual anyway) 542 if ($("#LDSSearch :input[name='nights']").is(':hidden')) { 543 $("#LDSSearch :input[name='nights']").attr('disabled','disabled'); 544 } 545 546 547 var valid = isValidRange(startDate, endDate); 548 if (!valid[0]) { 549 $("#LDSSearch #fromDate").datepicker("show"); 550 return false; 551 } 552 553 if (document.LDSSearch.maxDays > 0 && daysDiff > document.LDSSearch.maxDays) { 554 alert(document.LDSSearch.maxDaysMessage); 555 return false; 556 } 557 558 if ($("#LDSSearch #rooms").val() > 1 && $("#LDSPopup-roomassign").data('readytosubmit') != true) { 559 showMultiRoomPopup(); 560 return false; 561 } 562 $("#LDSPopup-roomassign").data('readytosubmit', false); 563 564 565 _trackSubmit(); 566 567 // Disbale button to prevent double submits 568 $('#LDSSearch-submit button').attr('disabled', 'disabled').addClass('disabled'); 569 $(window).on("unload", function(e) { 570 $('#LDSSearch-submit button').prop('disabled', false).removeClass('disabled'); 571 }); 572 573 574 // make sure the form action is the right one 575 if ($('#LDSSearch').closest('form').length > 0 || $('#LDSSearch form').length == 0) { 576 event.preventDefault(); 577 // we have a form underneath us, make a new form and put our bits in it 578 var inputs = ''; 579 $('#LDSSearch :input[name]').each(function(){ 580 inputs += `<input type="hidden" name="${$(this).attr('name')}" value="${$(this).val()}" />`; 581 }); 582 583 var _actionUrl = $("#LDSSearch-form").attr('action'); 584 if (_actionUrl == undefined) 585 _actionUrl = document.LDSSearch.actionUrl; 586 587 $('<form action="'+ _actionUrl +'" method="get" onclick="try{var _gaq = window._gaq || []; _gaq.push([\'_linkByPost\', this, true]);}catch(e){}">'+inputs+'</form>').appendTo('body').submit(); //.remove() 588 589 // _gaDecorateBookingPanelForm($form); 590 // $form.appendTo('body').submit(); 591 592 return false; 593 } 594 595 596 // _gaDecorateBookingPanelForm($("#LDSSearch-form")); 597 598 return true; 599 } 600 601 602 603 604 605 606 607 // MUTLI ROOM STUFF... 608 609 function showMultiRoomPopup() { 610 611 const displayInfants = ($("#LDSSearch #infants").length > 0 && $("#LDSSearch #infants").is(':visible')) 612 || ($("#LDSSearch .LDSSearch-infants").length > 0 && $("#LDSSearch .LDSSearch-infants").is(':visible')); 613 614 var numRooms = parseInt($("#LDSSearch #rooms").val()), 615 adults = parseInt($("#LDSSearch #adults").val()), 616 children = parseInt($("#LDSSearch #children").val()), 617 infants = parseInt($("#LDSSearch #infants").val()); 618 619 if (typeof infants === 'undefined' || isNaN(infants)) { 620 infants = 0; 621 } 622 623 624 // add rooms in that don't exist yet... 625 for (var room = 1; room <= numRooms; room++) { 626 if ($(".assignRow[data-roomrow='"+room+"']").length == 0) { 627 var assignRow = $('<tr class="assignRow" data-roomrow="'+room+'"></tr>'); 628 assignRow.append('<td>'+room+'</td>'); 629 630 // if first and last name capture enabled in bookingPanelSetup 631 if ($('table#LDSRoomAssignRows').hasClass('show-first-and-last')) { 632 let alias = `roomAssign[${room}][alias]`; 633 634 let names = `<div> 635 <input type="text" class="guestFirstName" name="guestFirstName" maxlength="20" placeholder="First name" value="" /> 636 <input type="text" class="guestLastName" name="guestLastName" maxLength="20" placeholder="Last name" value="" /> 637 <input type="hidden" class="roomAliasAssign" name="${alias}" value="" /> 638 </div>`; 639 640 assignRow.append('<td class="guests-name">' + names + '</td>'); 641 642 } 643 else { 644 assignRow.append('<td><input type="text" class="roomAliasAssign" name="roomAssign[' + room + '][alias]" maxlength="20" placeholder="Guest Name"></td>'); 645 } 646 647 assignRow.append('<td class="adultAssignCell"><input type="text" class="adultAssign" name="roomAssign['+room+'][adults]" min="1"></td>'); 648 assignRow.append('<td class="childrenAssignCell"><input type="text" class="childrenAssign" name="roomAssign['+room+'][children]"></td>'); 649 if (displayInfants) { 650 assignRow.append('<td class="infantsAssignCell"><input type="text" class="infantsAssign" name="roomAssign['+room+'][infants]"></td>'); 651 } 652 $("#LDSRoomAssignRows tbody").append(assignRow); 653 } 654 } 655 // remove excess rows... 656 $("#LDSRoomAssignRows tbody .assignRow").each(function() { 657 if ($(this).data('roomrow') > numRooms) 658 $(this).remove(); 659 }); 660 661 662 var assignmentKey = adults+'.'+children+'.'+numRooms; 663 var assignments = null; 664 665 try { 666 document.LDSSearch.roomAssignments = JSON.parse(sessionStorage.LDSSearchRoomAssignments); 667 assignments = document.LDSSearch.roomAssignments[assignmentKey]; 668 } catch(e) {} 669 670 671 if (assignments == null) { 672 673 document.LDSSearch.roomAssignments = {}; 674 assignments = {}; 675 676 // if we are assigning more adults than rooms then we can split them 677 if (adults >= numRooms) { 678 679 // attempt to assign them... 680 var patrons = adults + children + infants; 681 var assigned = 0; 682 683 while (assigned < patrons) { 684 685 var patronType = 'infants'; 686 if (assigned < adults) { 687 patronType = 'adults'; 688 } else if (assigned < adults + children) { 689 patronType = 'children'; 690 } 691 692 var roomNumber = (numRooms+assigned)%numRooms+1; 693 694 if (assignments[roomNumber] == undefined) { 695 assignments[roomNumber] = { 696 'adults': 0, 697 'children': 0, 698 'infants': 0 699 } 700 } 701 702 assignments[roomNumber][patronType]++; 703 assigned++; 704 } 705 706 } 707 // else we want to just assign adults + children to each room as they are 708 else { 709 for (var roomNumber = 1; roomNumber <= numRooms; roomNumber++) { 710 assignments[roomNumber] = { 711 'adults': adults, 712 'children': children, 713 'infants': infants 714 }; 715 } 716 } 717 718 } // end if... 719 720 721 722 for (var room = 1; room <= numRooms; room++) { 723 var row = $(".assignRow[data-roomrow='"+room+"']"); 724 $('.adultAssign', row).val(assignments[room]['adults']); 725 $('.childrenAssign', row).val(assignments[room]['children']); 726 $('.infantsAssign', row).val(assignments[room]['infants']); 727 728 // if we have an alias from before lets reuse it...
729 try { $('.roomAliasAssign', row).val(document.LDSSearch.roomAssignments['aliases'][room-1]); } catch (e) { } 730 } 731 732 733 $('#LDSPopup > div').hide(); 734 $('#LDSPopup-roomassign').show().trigger('show'); 735 $('#LDSPopup').fadeIn('fast'); 736 return false; 737 } // end func show multiroom 738 739 740 $("#roomAssignForm #roomAssignSubmit").on('click', function() { 741 742 // validate... 743 var error = false; 744 $("#LDSPopup-roomassign .adultAssign").each(function() { 745 var adultsInRoom = parseInt($(this).val()); 746 if (adultsInRoom !== adultsInRoom || adultsInRoom < 1) { 747 error = true; 748 return false; 749 } 750 }); 751 752 if (error) { 753 alert("Must have more than 1 adult in each room."); 754 return false; 755 } 756 757 $("#LDSPopup-roomassign").hide(); 758 759 760 // set new data into session based on what they entered in.... 761 var assignmentKey = $("#LDSSearch #adults").val()+'.'+$("#LDSSearch #children").val()+'.'+$("#LDSSearch #rooms").val(); 762 var newAssign = {}; 763 var newAliases = []; 764 let showFAL = $('#LDSRoomAssignRows').hasClass('show-first-and-last'); 765 766 $("#LDSRoomAssignRows tbody tr").each(function(idx,row) { 767 newAssign[idx+1] = { 768 'adults': parseInt($(".adultAssign",row).val()), 769 'children': parseInt($(".childrenAssign",row).val()), 770 'infants': parseInt($(".infantsAssign",row).val()) 771 }; 772 773 // if first and last name capture enabled in bookingPanelSetup 774 if (showFAL) { 775 let fName = $(row).find('.guestFirstName').val(); 776 let lName = $(row).find('.guestLastName').val(); 777 // get guest full name 778 let fullName = fName + " " +lName; 779 780 $(row).find('.roomAliasAssign').val(fullName); 781 782 newAliases.push(fName); 783 newAliases.push(lName); 784 } 785 else { 786 newAliases.push($(".roomAliasAssign",row).val()); 787 } 788 789 }); 790 document.LDSSearch.roomAssignments[assignmentKey] = newAssign; 791 document.LDSSearch.roomAssignments['aliases'] = newAliases; 792 if(typeof(Storage) !== "undefined") { 793 try { sessionStorage.LDSSearchRoomAssignments = JSON.stringify(document.LDSSearch.roomAssignments); } catch (e) { } 794 } 795 796 797 $("#LDSRoomAssignRows tbody :input").each(function() { 798 $(this).hide(); 799 $("#LDSSearch-form").append(this); 800 }); 801 802 803 // Get min adults, assign to `#adults` dropdown. 804 // Solves bug with multi rooms which applies adult count to each room. 805 var minAdults = $("#LDSSearch-form .adultAssign:first").val(); 806 $("#LDSSearch-form .adultAssign").each(function() { 807 if($(this).val() < minAdults) { 808 minAdults = $(this).val(); 809 } 810 }); 811 $("#LDSSearch-form #adults").val(minAdults); 812 813 $("#LDSPopup-roomassign").data('readytosubmit', true); 814 815 $('#LDSSearch .LDSSearch-submit button').trigger('click'); 816 $('#LDSPopup > div').hide(); 817 $('#LDSPopup').fadeOut(); 818 return false; 819 }); // end roomassign form submit 820 821 822 823 824 825 $('#LDSPopup').appendTo($('body')); 826 827 $('#LDSPopup, .LDSPopup-close').on('click', function() { 828 $('#LDSPopup').fadeOut('fast'); 829 }); 830 831 $("#LDSPopup .LDSPopup").on('click', function(e) { e.stopPropagation();}); 832 833 834 var loginLink = $('#LDSSearch .LDSSearch-login a').attr('href'); 835 if (loginLink != '#') { 836 // We have a logout link. 837 $('#LDSClientLoginLink').text('Logout').attr('href', loginLink); 838 } 839 840 $('#LDSSearch .LDSSearch-login a, #LDSClientLoginLink').on('click', function(e) { 841 e.preventDefault(); 842 if (loginLink == '#') { 843 console.log("Clicked Login"); 844 $('#LDSPopup > div').hide(); 845 $('#LDSPopup-login').show(); 846 $('#LDSPopup').fadeIn('fast'); 847 return false; 848 } else { 849 console.log("Clicked Logout"); 850 var extraFields = ""; 851 // if( $(this).hasClass("logoutX") ) { 852 extraFields = extraFields + "&propertyDate=" + $("input[name=propertyDate]").val(); 853 extraFields = extraFields + "&fromDateActual=" + $("input[name=fromDateActual]").val(); 854 extraFields = extraFields + "&toDateActual=" + $("input[name=toDateActual]").val(); 855 extraFields = extraFields + "&Adults=" + $("#adults").val(); 856 extraFields = extraFields + "&Children=" + $("#children").val(); 857 858 if ($("#children").length > 0) { 859 extraFields += "&Infants=" + $("#infants").val(); 860 } 861 862 if($("#search-id").length) { 863 extraFields = extraFields + "&searchId=" + $("#search-id").val(); 864 extraFields = extraFields + "&searchPulldown=" + $("#search-id").val(); 865 } 866 // } 867 window.location = loginLink+extraFields; 868 } 869 }); 870 871 // if #client-login lives on url, we want to do the above! 872 if (window.location.hash.slice(1) == 'client-login') { 873 $('#LDSPopup > div').hide(); 874 $('#LDSPopup-login').show(); 875 $('#LDSPopup').fadeIn('fast'); 876 } 877 878 // booking cancellations box 879 $('#LDSSearch .LDSSearch-cancel a, #LDSCancellationLink').on('click', function() { 880 $('#LDSPopup > div').hide(); 881 $('#LDSPopup-cancel').show(); 882 $('#LDSPopup').fadeIn('fast'); 883 return false;
884 }); 885 886 // if #cancellation lives on url, we want to do the above! 887 if (window.location.hash.slice(1) == 'cancellation') { 888 $('#LDSPopup > div').hide(); 889 $('#LDSPopup-cancel').show(); 890 $('#LDSPopup').fadeIn('fast'); 891 } 892 893});
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.