1let childrenData; 2$(function () { 3 $.getJSON("/dist/phoenix/V1.0/phpActions/retrieveAirportsInfo.php", (results) => { 4 airports = results; 5 var display = []; 6 page = $("#currentpage").val(); 7 8 //end of manager date range picker 9 let defaultOrigin = ""; 10 let defaultDestination = ""; 11 if (page === "page_destination") { 12 const queryString = window.location.search; 13 var div = document.createElement('div'); 14 div.innerHTML = queryString 15 var decoded = div.firstChild.nodeValue; 16 const urlParams = new URLSearchParams(decoded); 17 console.log("urlParams=", urlParams) 18 const route = urlParams.get("route"); 19 20 if (route.split("-").length > 1) { 21 defaultOrigin = route.split("-")[0]; 22 defaultDestination = route.split("-")[1]; 23 } 24 } 25 $.getJSON("/dist/phoenix/V1.0/db/countries.json", function (data) { 26 if ($("#selectFrom_hotel").length) { 27 append_destination_json( 28 airports, 29 data, 30 "#selectFrom_hotel", 31 defaultOrigin 32 ); 33 } 34 35 if (defaultDestination !== "") { 36 if ($("#selectTo_hotel").length) { 37 append_destination_json( 38 airports.filter((x) => 39 fullDeals 40 .find((x) => x.city === defaultOrigin) 41 .routes.map((x) => x.city) 42 .includes(x.iata_code) 43 ), 44 data, 45 "#selectTo_hotel", 46 defaultDestination 47 ); 48 } 49 } 50 }) 51 }); 52 53 $(document).on("change", ".fromselection_hotel", function (event) { 54 console.log('page') 55 console.log(page) 56 console.log( 57 "fromselection change event.target.id=", 58 event.target.getAttribute("rel") 59 ); 60 var selectTo = 61 "#selectTo_hotel" + 62 (event.target.getAttribute("rel") === "0" 63 ? "" 64 : event.target.getAttribute("rel")); 65 console.log("selectTo=", "#selectTo_hotel" + selectTo); 66 $("#selectTo_hotel" + selectTo).html( 67 "<option value='' disabled >Select your Destination</option>" 68 ); 69 console.log("flightForm.js airports airports=>", airports); 70 console.log( 71 "flightForm.js fullDeals filtered=", 72 fullDeals.find((x) => x.city === this.value) 73 ); 74 console.log(this.value); 75 append_destination_json( 76 airports.filter((x) => 77 fullDeals 78 .find((x) => x.city === this.value) 79 .routes.map((x) => x.city) 80 .includes(x.iata_code) 81 ), 82 countries, 83 selectTo 84 ); 85 }); 86 87 var roomBody = ` 88<div class="ic pop animated bounceInDown col-xs-4 " id="roomPopup"> 89 <div id="roomContainer"> 90 <div id="room1" class="room"> 91 <div class="ic row"> 92 <div class="ic col-xs-4 col-xs-offset-1"> 93 <strong class="ic">Adults</strong><br> 94 <span class="ic">18 ++</span> 95 </div> 96 <div class="ic col-xs-6"> 97 <i class="ic fa fa-minus-square-o fa-3x form-inline" type="button" onclick="adjustOccupant('adult', 'Room1Adults', -1)"></i> 98 <input value="1" class="ic input-passenger form-group form-inline" type="number" id="numberOfRoom1Adults" readonly> 99 <i class="ic fa fa-plus-square-o fa-3x form-inline" type="button" onclick="adjustOccupant('adult', 'Room1Adults', 1)"></i> 100 </div> 101 </div> 102 <br> 103 <div class="ic row"> 104 <div class="ic col-xs-4 col-xs-offset-1"> 105 <strong class="ic">Children</strong><br>
106 <span class="ic">0-17</span> 107 </div> 108 <div class="ic col-xs-6"> 109 <i class="ic fa fa-minus-square-o fa-3x" type="button" onclick="adjustOccupant('child', 'Room1Children', -1)"></i> 110 <input value="0" class="ic input-passenger form-group" type="number" id="numberOfRoom1Children" readonly> 111 <i class="ic fa fa-plus-square-o fa-3x" type="button" onclick="adjustOccupant('child', 'Room1Children', 1)"></i> 112 </div> 113 </div> 114 <div id="Room1ChildrenAges" class="children-ages"></div> <!-- Container for children ages --> 115 <br> 116 </div> 117 </div> 118 <div class="ic row"> 119 <div class="col-xs-12"> 120 <button class="room-button" style="" onclick="addRoom()">Add Room</button> 121 <button class="popover-dismiss room-button" onclick="getTotalRoomsAndOccupants()">Done</button> 122 </div> 123 </div> 124</div> 125`; 126 127// Bootstrap Popover for Rooms 128 if (totalsDataRooms.length < 1) { 129 const roomPopover = new bootstrap.Popover( 130 document.querySelector("#roomButton"), 131 { 132 container: "body", 133 title: "Room Occupants", 134 html: true, 135 placement: "bottom", 136 sanitize: false, 137 content() { 138 return roomBody; 139 }, 140 } 141 ); 142 } 143 $("#roomButton").click(function (evt) { 144 let output = ''; 145 console.log(totalsDataRooms.length) 146 if (totalsDataRooms.length > 0) { 147 console.log(totalsDataRooms) 148 for (let i = 0; i < totalsDataRooms.length; i++) { 149 let childrenAges = totalsDataRooms[i].children_ages ?? []; 150 childrenAges.forEach((age, index) => { 151 $(`#Room${i}Child${index + 1}Age`).val(age); 152 }); 153 childrenData = childrenAges; 154 console.log(childrenAges); 155 output += ` 156 <div id="room${i}" class="room"> 157 <div class="ic row"> 158 <div class="ic col-xs-4 col-xs-offset-1"> 159 <strong class="ic">Adults</strong><br> 160 <span class="ic">18 ++</span> 161 </div> 162 <div class="ic col-xs-6"> 163 <i class="ic fa fa-minus-square-o fa-3x form-inline" type="button" onclick="adjustOccupant('adult', 'Room${i}Adults', -1)"></i> 164 <input value="${totalsDataRooms[i].adults}" class="ic input-passenger form-group form-inline" type="number" id="numberOfRoom${i}Adults" readonly> 165 <i class="ic fa fa-plus-square-o fa-3x form-inline" type="button" onclick="adjustOccupant('adult', 'Room${i}Adults', 1)"></i> 166 </div> 167 </div> 168 <br> 169 <div class="ic row"> 170 <div class="ic col-xs-4 col-xs-offset-1"> 171 <strong class="ic">Children</strong><br> 172 <span class="ic">0-17</span> 173 </div> 174 <div class="ic col-xs-6"> 175 <i class="ic fa fa-minus-square-o fa-3x" type="button" onclick="adjustOccupant('child', 'Room${i}Children', -1)"></i> 176 <input value="${childrenAges.length}" class="ic input-passenger form-group" type="number" id="numberOfRoom${i}Children" readonly> 177 <i class="ic fa fa-plus-square-o fa-3x" type="button" onclick="adjustOccupant('child', 'Room${i}Children', 1)"></i> 178 </div> 179 </div> 180 <div id="Room${i}ChildrenAges" class="children-ages">`; 181 for (let j = 0; j < childrenAges.length; j++) { 182 console.log(`Room ${i + 1}, Child ${j + 1}: Age ${childrenAges[j]}`); 183 output += `<div class="child-age-input"> 184 <label for="Room${i + 1}Child${i + 1}Age">Age of Child ${i + 1}:</label> 185 <input type="number" min="0" max="17" id="Room${i + 1}Child${i + 1}Age" style="width: 50px" value="${childrenAges[j]}" class="form-control child-age" required> 186 </div>` 187 } 188 output += ` </div> <!-- Container for children ages --> 189 <br> 190 </div>`; 191 } 192 $("#roomContainer").html(output); 193 } 194 }); 195 // 196 $("#DepartDate_hotel").each(function () { 197 $(this).on("changeDate", function (e) { 198 const CheckIn = $(this).datepicker("getDate"); 199 const CheckOut = moment(CheckIn).add(1, "day").toDate(); 200 201 // Update the min date for the arrival date picker 202 $("#ArrivalDate_hotel").datepicker("setStartDate", CheckOut); 203 204 // Automatically set and focus on the next valid arrival date 205 $("#ArrivalDate_hotel").datepicker("update", CheckOut).focus(); 206 }); 207 }); 208 209 // $("#DepartDate_hotel").each(function () { 210 // $(this).on("changeDate", function (e) { 211 // CheckIn = $(this).datepicker("getDate"); 212 // CheckOut = moment(CheckIn).add(1, "day").toDate(); 213 // $("#ArrivalDate_hotel").datepicker("update", CheckOut).focus(); 214 // }); 215 // }); 216 217 $(document).on("click", ".tripflow_hotel", (e) => { 218 e.preventDefault(); 219 // if (!$("#errorsContent-hotel").hasClass("d-none")) { 220 // // $("#errorsContent-hotel").addClass("d-none"); 221 // $("#errorsContent-hotel").show(); 222 // } 223 tripflow = e.target.getAttribute("rel"); 224 console.log("tripflow tripflow", tripflow); 225 if (tripflow === "oneWayTrip") { 226 $("#ArrivalDateWrapper_hotel").hide(); 227 console.log($("#ArrivalDate_hotel").parent().next(".validation").length); 228 if ($("#ArrivalDate_hotel").parent().next(".validation").length) { 229 $("#ArrivalDate_hotel").parent().next(".validation").hide(); 230 } else if ($("#DepartureDateWrapper_hotel").hasClass("col-md-6")) { 231 $("#DepartureDateWrapper_hotel").addClass("col-md-12"); 232 } 233 234 } else { 235 $("#ArrivalDateWrapper_hotel").show(); 236 if ($("#ArrivalDate_hotel").parent().next(".validation").length) { 237 $("#ArrivalDate_hotel").parent().next(".validation").show(); 238 } else if ($("#DepartureDateWrapper_hotel").hasClass("col-md-6")) { 239 $("#DepartureDateWrapper_hotel").removeClass("col-md-12"); 240 } 241 242 } 243 }); 244}) 245let roomCount = 1; 246 247function removeRoom(room) { 248 let room_id = $("#room" + room).remove(); 249 roomCount--; 250 const totals = getTotalRoomsAndOccupants(); 251 $("#roomButton").val(`${totals.totalRooms} Room, ${totals.totalOccupants} Adults, ${totals.totalChildren} Children`); 252} 253 254function addRoom() { 255 roomCount++; 256 const newRoom = ` 257 <div id="room${roomCount}" class="room"> 258 <button class="room-button" onclick="removeRoom(roomCount)">Remove Room</button> 259 <div class="ic row"> 260 <div class="ic col-xs-4 col-xs-offset-1"> 261 <strong class="ic">Adults</strong><br>
262 <span class="ic">18 ++</span> 263 </div> 264 <div class="ic col-xs-6"> 265 <i class="ic fa fa-minus-square-o fa-3x form-inline" type="button" onclick="adjustOccupant('adult', 'Room${roomCount}Adults', -1)"></i> 266 <input value="1" class="ic input-passenger form-group form-inline" type="number" id="numberOfRoom${roomCount}Adults" readonly> 267 <i class="ic fa fa-plus-square-o fa-3x form-inline" type="button" onclick="adjustOccupant('adult', 'Room${roomCount}Adults', 1)"></i> 268 </div> 269 </div> 270 <br> 271 <div class="ic row"> 272 <div class="ic col-xs-4 col-xs-offset-1"> 273 <strong class="ic">Children</strong><br> 274 <span class="ic">0-11</span> 275 </div> 276 <div class="ic col-xs-6"> 277 <i class="ic fa fa-minus-square-o fa-3x" type="button" onclick="adjustOccupant('child', 'Room${roomCount}Children', -1)"></i> 278 <input value="0" class="ic input-passenger form-group" type="number" id="numberOfRoom${roomCount}Children" readonly> 279 <i class="ic fa fa-plus-square-o fa-3x" type="button" onclick="adjustOccupant('child', 'Room${roomCount}Children', 1)"></i> 280 </div> 281 </div> 282 <div id="Room${roomCount}ChildrenAges" class="children-ages"></div> <!-- Container for children ages --> 283 <br> 284 </div>`; 285 $("#roomContainer").append(newRoom); // Append the new room HTML to the container 286 const totals = getTotalRoomsAndOccupants(); 287 $("#roomButton").val(`${totals.totalRooms} Room, ${totals.totalOccupants} Adults, ${totals.totalChildren} Children`); 288} 289 290function adjustOccupant(type, roomId, change) { 291 const roomNumber = roomId.match(/\d+/)[0]; 292 const targetField = $(`#numberOf${roomId}`); 293 const currentValue = parseInt(targetField.val()); 294 const newValue = currentValue + change; 295 const childrenAgesContainer = $(`#Room${roomNumber}ChildrenAges`); 296 console.log(childrenAgesContainer.children()); 297 298 if (newValue >= 0 && (type !== 'child' || newValue <= 9)) { 299 targetField.val(newValue); 300 301 if (type === 'child') { 302 const currentAgeInputs = childrenAgesContainer.children().length; 303 if (newValue > currentAgeInputs) { 304 // Add new age inputs 305 for (let i = currentAgeInputs; i < newValue; i++) { 306 childrenAgesContainer.append(` 307 <div class="child-age-input"> 308 <label for="Room${roomNumber}Child${i + 1}Age">Age of Child ${i + 1}:</label> 309 <input type="number" min="0" max="17" id="Room${roomNumber}Child${i + 1}Age" style="width: 50px" class="form-control child-age" required> 310 </div> 311 `); 312 } 313 } else if (newValue < currentAgeInputs) { 314 // Remove extra age inputs 315 for (let i = currentAgeInputs; i > newValue; i--) { 316 childrenAgesContainer.children().last().remove(); 317 } 318 } 319 } 320 // Update button label with totals 321 const totals = getTotalRoomsAndOccupants(); 322 $("#roomButton").val(`${totals.totalRooms} Room, ${totals.totalOccupants} Adults, ${totals.totalChildren} Children`); 323 } 324} 325 326let totalsDataRooms = []; 327 328function getTotalRoomsAndOccupants() { 329 const rooms = document.querySelectorAll('.room'); 330 let totalOccupants = 0; 331 let totalChildren = 0; 332 let occupancy = []; 333 const totalRooms = rooms.length; 334 335 rooms.forEach(room => { 336 const roomId = room.id.match(/\d+/)[0]; 337 const adultCount = parseInt($(`#numberOfRoom${roomId}Adults`).val()) || 1; 338 const childCount = parseInt($(`#numberOfRoom${roomId}Children`).val()) || 0; 339 340 // Gather ages of each child in the current room 341 const childrenAges = []; 342 console.log('childCount') 343 console.log(childCount) 344 for (let i = 1; i <= childCount; i++) { 345 const childAge = parseInt($(`#Room${roomId}Child${i}Age`).val()) || null; 346 if (childAge !== null) { 347 childrenAges.push(childAge); 348 } 349 } 350 console.log(childrenAges); 351 console.log(childrenData); 352 353 // Construct occupancy object for the room 354 const roomData = {adults: adultCount}; 355 if (childrenAges.length > 0) { 356 roomData.children_ages = childrenAges; 357 } 358 359 occupancy.push(roomData); 360 361 totalOccupants += adultCount; 362 totalChildren += childCount; 363 }); 364 totalsDataRooms = occupancy; 365 366 return {totalRooms, totalOccupants, totalChildren, occupancy}; 367} 368 369function populatePopover() { 370 const rooms = document.querySelectorAll('.room');
371 rooms.forEach(room => { 372 const roomId = room.id.match(/\d+/)[0]; 373 if (roomData[roomId]) { 374 const childrenAges = roomData[roomId].childrenAges || []; 375 childrenAges.forEach((age, index) => { 376 $(`#Room${roomId}Child${index + 1}Age`).val(age); 377 }); 378 } 379 }); 380} 381 382$(document).on("click", "#findFlightsAndHotels", (e) => { 383 e.preventDefault(); // Prevents redirect until validation passes 384 385 // Collect and validate inputs 386 let origin = $("#selectFrom_hotel").val(); 387 let destination = $("#selectTo_hotel").val(); 388 let departure_date = moment($(`#DepartDate_hotel`).datepicker("getDate")).format("YYYY-MM-DD"); 389 let return_date = moment($(`#ArrivalDate_hotel`).datepicker("getDate")).format("YYYY-MM-DD"); 390 let promo_code = $("#promoCode_hotel").val(); 391 let occupancy = JSON.stringify(totalsDataRooms); // Convert occupancy data to JSON format 392 393 //Validation check. 394 let errors = []; 395 396 if (!origin) errors.push("Origin is required."); 397 console.log(!origin) 398 if (!destination) errors.push("Destination is required."); 399 console.log(!destination) 400 if (!departure_date || !moment(departure_date, "YYYY-MM-DD", true).isValid()) errors.push("Valid departure date is required."); 401 402 if (!return_date || !moment(return_date, "YYYY-MM-DD", true).isValid()) errors.push("Valid return date is required."); 403 //if (!totalsDataRooms || !Array.isArray(totalsDataRooms) || totalsDataRooms.length === 0) errors.push("Occupancy data is required."); 404 totalsDataRooms = totalsDataRooms && Array.isArray(totalsDataRooms) && totalsDataRooms.length > 0 405 ? totalsDataRooms 406 : [{adults: 1}]; // Default to 1 room with 1 adult 407 if (errors.length > 0) { 408 let errorListHtml = errors.map(error => `<li>${error}</li>`).join(""); 409 $("#errorsList-hotel").html(errorListHtml); // Sets the error messages as list items 410 $("#errorsContent-hotel").show(); // Ensures the errors are visible 411 return; // Stops execution and prevents redirect 412 } 413 // console.log(occupancy); 414 // console.log(JSON.stringify(totalsDataRooms)); 415 // let redirect_url = `https://holidays.rwandair.com/online/packages/api/v1/search?departure_date=${departure_date}&lang=es&occupancy=${encodeURIComponent(occupancy)}&origin=${origin}&return_date=${return_date}&destination=${destination}&lang=en`; 416 let redirect_url = `https://holidays.rwandair.com/online/packages/api/v1/search?departure_date=${departure_date}&occupancy=${(JSON.stringify(totalsDataRooms))}&origin=${origin}&return_date=${return_date}&destination=${destination}&lang=en` 417 console.log(redirect_url); 418 window.location.href = redirect_url; 419}); 420 421document.addEventListener('input', (event) => { 422 if (event.target.matches('.child-age')) { 423 const input = event.target; 424 const max = parseInt(input.getAttribute('max'), 10); 425 if (input.value > max) { 426 input.value = max; 427 } 428 } 429}); 430
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.