1/* Minification failed. Returning unminified contents. 2(162,26-27): run-time error JS1003: Expected ':': ( 3(162,37-38): run-time error JS1100: Expected ',': { 4(163,20-21): run-time error JS1014: Invalid character: ` 5(163,22-23): run-time error JS1004: Expected ';': { 6(163,41-42): run-time error JS1004: Expected ';': { 7(163,51-52): run-time error JS1014: Invalid character: ` 8(164,10-11): run-time error JS1195: Expected expression: , 9(166,38-39): run-time error JS1004: Expected ';': { 10(203,27-28): run-time error JS1014: Invalid character: ` 11(203,29-30): run-time error JS1193: Expected ',' or ')': { 12(203,51-52): run-time error JS1014: Invalid character: ` 13(203,52-53): run-time error JS1195: Expected expression: ) 14(204,27-28): run-time error JS1014: Invalid character: ` 15(204,29-30): run-time error JS1193: Expected ',' or ')': { 16(204,48-49): run-time error JS1014: Invalid character: ` 17(204,49-50): run-time error JS1195: Expected expression: ) 18(205,27-28): run-time error JS1014: Invalid character: ` 19(205,48-49): run-time error JS1014: Invalid character: ` 20(205,49-50): run-time error JS1195: Expected expression: ) 21(206,23-27): run-time error JS1034: Unmatched 'else'; no 'if' defined: else 22(207,27-28): run-time error JS1014: Invalid character: ` 23(207,47-48): run-time error JS1002: Syntax error: } 24(207,48-49): run-time error JS1014: Invalid character: ` 25(208,81-82): run-time error JS1004: Expected ';': { 26(210,31-32): run-time error JS1014: Invalid character: ` 27(210,33-34): run-time error JS1193: Expected ',' or ')': { 28(210,55-56): run-time error JS1014: Invalid character: ` 29(210,56-57): run-time error JS1195: Expected expression: ) 30(211,31-32): run-time error JS1014: Invalid character: ` 31(211,52-53): run-time error JS1014: Invalid character: ` 32(211,53-54): run-time error JS1195: Expected expression: ) 33(211,59-60): run-time error JS1197: Too many errors. The file might not be a JavaScript file: ( 34 */ 35/// <reference path="../js/vendor/jquery.js" /> 36 37Define("dialog", { 38 display: function (msg, title, options) { 39 dialog.show(title, msg, options); 40 }, 41 42 show: function (title, content, options) { 43 var initialOptions = { 44 title: title, 45 buttons: 46 [{ 47 text: "OK", click: function () { $(this).dialog("close"); } 48 }], 49 modal: true 50 }; 51 $('#dialog').html(content).dialog($.extend(true, initialOptions, options)); 52 } 53}); 54function flightSearchDialog() { 55 return { 56 containerId: '', 57 dialogLocationId: '', 58 dialogSearchError: '', 59 departureDateId: '', 60 returnDateId: '', 61 currentMonthlyTableMonth: null, 62 currentMonthlyTableYear: null, 63 monthlyAutoNextTimer: null, 64 isLoading: false, 65 enableShowLowestPriceOnSearchBox: false, 66 vietnamCountryId: null, 67 validatesentmail: function () { 68 var isValidEmail = true; 69 var email = $('#emailCustomer').val(); 70 if (email == undefined || email == '' || (email != '' && !share.flight_search_dialog.isValidEmailCustom(email))) { 71 isValidEmail = false; 72 } 73 return isValidEmail; 74 }, 75 76 isValidEmailCustom: function (email) { 77 // var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 78 var re = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/; 79 return re.test(email); 80 }, 81 82 /* 83 * 84 * This function support switch DepartureCity and ArrivalCity 85 * 86 */ 87 switchLocations: function () { 88 var departureCity = $(this.wrapWithContainer('#DepartureCity')).val(); 89 $(this.wrapWithContainer('#DepartureCity')).val($(this.wrapWithContainer('#ArrivalCity')).val()); 90 $(this.wrapWithContainer('#ArrivalCity')).val(departureCity); 91 92 var departureCityCountry = $(this.wrapWithContainer('#DepartureCityCountry')).val(); 93 $(this.wrapWithContainer('#DepartureCityCountry')).val($(this.wrapWithContainer('#ArrivalCityCountry')).val()); 94 $(this.wrapWithContainer('#ArrivalCityCountry')).val(departureCityCountry); 95 $(this.wrapWithContainer('#departure-country')).val($(this.wrapWithContainer('#ArrivalCityCountry')).val()); 96 $(this.wrapWithContainer('#arrival-counry')).val(departureCityCountry); 97 98 departureCityName = $(this.wrapWithContainer('#DepartureCity-Holder')).val(); 99 $(this.wrapWithContainer('#DepartureCity-Holder')).val($(this.wrapWithContainer('#ArrivalCity-Holder')).val()); 100 $(this.wrapWithContainer('#ArrivalCity-Holder')).val(departureCityName); 101 }, 102 103 /* 104 * 105 * This function support updatePaxInfo 106 * 107 */ 108 updatePaxInfo: function () { 109 var adultNo = $(this.wrapWithContainer('[name="AdultNo"]')).val(); 110 var childNo = $(this.wrapWithContainer('[name="ChildNo"]')).val(); 111 var infantNo = $(this.wrapWithContainer('[name="InfantNo"]')).val(); 112 113 114 if ($(this.wrapWithContainer('#viewPassengerInfoContent #adultLabel')).length <= 0) { 115 var html = adultNo + ' ngưá»i lá»n, ' + childNo + ' trẻ em, ' + infantNo + ' sÆ¡ sinh'; 116 $(this.wrapWithContainer('#viewPassengerInfoContent')).html(html); 117 } 118 else { 119 $(this.wrapWithContainer('#viewPassengerInfoContent #adultLabel')).text(adultNo); 120 $(this.wrapWithContainer('#viewPassengerInfoContent #childLabel')).text(childNo); 121 $(this.wrapWithContainer('#viewPassengerInfoContent #infantLabel')).text(infantNo); 122 } 123 }, 124 125 initStepperChoosePassenger: function () { 126 var self = this; 127 if ($(self.wrapWithContainer('.btn-plus')).length > 0) { 128 // no infant for train 129 if (typeof productId != 'undefined') { 130 $(self.wrapWithContainer('[name="InfantNo"]')).val(0); 131 } 132 $(self.wrapWithContainer('#viewPassengerInfoContent_dropdownContent li[data-passenger="adult"]')).find('.step-number').text($(self.wrapWithContainer('[name="AdultNo"]')).val()); 133 $(self.wrapWithContainer('#viewPassengerInfoContent_dropdownContent li[data-passenger="child"]')).find('.step-number').text($(self.wrapWithContainer('[name="ChildNo"]')).val()); 134 $(self.wrapWithContainer('#viewPassengerInfoContent_dropdownContent li[data-passenger="infant"]')).find('.step-number').text($(self.wrapWithContainer('[name="InfantNo"]')).val()); 135 136 $(self.wrapWithContainer('.btn-plus')).click(function () { 137 var step = $(this).closest('li[data-passenger]').find('.step-number').text(); 138 var stepnum = parseInt(step); 139 var max = parseInt($(this).closest('li[data-passenger]').data('max')); 140 if (stepnum + 1 <= max) { 141 stepnum++; 142 143 var paxType = $(this).closest('li[data-passenger]').data('passenger'); 144 145 if (paxType == 'infant' && stepnum > $(self.wrapWithContainer('[name="AdultNo"]')).val()) { 146 return; 147 } 148 149 $(this).closest('li[data-passenger]').find('.step-number').text(stepnum); 150 151 if (paxType == 'adult') { 152 $(self.wrapWithContainer('[name="AdultNo"]')).val(stepnum); 153 } 154 else if (paxType == 'child') { 155 $(self.wrapWithContainer('[name="ChildNo"]')).val(stepnum); 156 } 157 else if (paxType == 'infant') { 158 $(self.wrapWithContainer('[name="InfantNo"]')).val(stepnum); 159 } 160 161 self.updatePaxInfo(); 162 } 163 }); 164 165 $(self.wrapWithContainer('.btn-minus')).click(function () { 166 167 var step = $(this).closest('li[data-passenger]').find('.step-number').text(); 168 var stepnum = parseInt(step); 169 var min = parseInt($(this).closest('li[data-passenger]').data('min')); 170 if (stepnum - 1 >= min) { 171 stepnum--; 172 173 var paxType = $(this).closest('li[data-passenger]').data('passenger'); 174 175 if (paxType == 'adult' && stepnum < $(self.wrapWithContainer('[name="InfantNo"]')).val()) { 176 return; 177 } 178 $(this).closest('li[data-passenger]').find('.step-number').text(stepnum); 179 180 if (paxType == 'adult') { 181 $(self.wrapWithContainer('[name="AdultNo"]')).val(stepnum); 182 } 183 else if (paxType == 'child') { 184 $(self.wrapWithContainer('[name="ChildNo"]')).val(stepnum); 185 } 186 else { 187 $(self.wrapWithContainer('[name="InfantNo"]')).val(stepnum); 188 } 189 190 self.updatePaxInfo(); 191 } 192 }); 193 } 194 }, 195 196 wrapWithContainer(selector) { 197 return `${this.containerId}${selector}`; 198 }, 199 200 load: function (containerId) { 201 var currentPathname = window.location.pathname.toLowerCase(); 202 if (currentPathname.indexOf('/ve-may-bay-vna') > -1 || currentPathname.indexOf('/airline-ticket-vna') > -1) { 203 sessionStorage.setItem('searchVNAOnly', 'true'); 204 } else if (currentPathname.indexOf('booking/selectflight') === -1 && currentPathname.indexOf('/tim-ve-may-bay') === -1) { 205 sessionStorage.removeItem('searchVNAOnly'); 206 } 207 208 if (containerId) { 209 this.containerId = containerId + ' '; 210 let uniqueId = Date.now().toString(36) + Math.random().toString(36).substring(2); 211 this.dialogLocationId = '#departure-location-dlg-' + uniqueId; 212 this.departureDateId = '#depatureDate-' + uniqueId; 213 this.returnDateId = '#returnDate-' + uniqueId; 214 this.dialogSearchError = '#search-error-dlg-' + uniqueId; 215 $(this.wrapWithContainer('#depatureDate')).attr("id", this.departureDateId.replace('#', '')); 216 $(this.wrapWithContainer('#returnDate')).attr("id", this.returnDateId.replace('#', '')); 217 $(this.wrapWithContainer('#search-error-dlg')).attr("id", this.dialogSearchError.replace('#', '')).addClass('search-error-dlg'); 218 } 219 else { 220 this.dialogLocationId = '#departure-location-dlg'; 221 this.departureDateId = '#depatureDate'; 222 this.returnDateId = '#returnDate'; 223 this.dialogSearchError = '#search-error-dlg'; 224 } 225 226 if ($(this.wrapWithContainer('#EnableShowLowestPriceOnSearchBox')).val() != undefined) { 227 if ($(this.wrapWithContainer('#EnableShowLowestPriceOnSearchBox')).val() != null && $(this.wrapWithContainer('#EnableShowLowestPriceOnSearchBox')).val() == 'true') 228 share.flight_search_dialog.enableShowLowestPriceOnSearchBox = true; 229 } 230 var theme = $('#Theme').val(); 231 232 var self = this; 233 $(this.wrapWithContainer("input[name=JourneyType]:radio")).on("change", function () { 234 235 if (theme != 'Globalink' && theme != 'HongNgocHa' && theme != 'HongNgocHa_V2') { 236 if ($(this).is(':checked') && $(this).attr('id') === 'radioOneWay') { 237 $(`${self.departureDateId}`).datepickerlunar("option", 'maxDate', null); 238 $(`${self.returnDateId}`).attr('disabled', 'disabled'); 239 $(`${self.returnDateId}`).val(''); 240 } else 241 $(`${self.returnDateId}`).removeAttr('disabled'); 242 if (self.containerId === '#quick-search-dialog-secondary ') { 243 if ($(this).is(':checked') && $(this).attr('id') === 'radioOneWaySecondary') { 244 $(`${self.departureDateId}`).datepickerlunar("option", 'maxDate', null); 245 $(`${self.returnDateId}`).attr('disabled', 'disabled'); 246 $(`${self.returnDateId}`).val(''); 247 } else 248 $(`${self.returnDateId}`).removeAttr('disabled'); 249 } 250 } else if (theme == 'HongNgocHa' || theme == 'HongNgocHa_V2') { 251 if ($(this).is(':checked') && $(this).attr('id') === 'radioOneWay') { 252 $(`${self.returnDateId}`).attr('disabled', 'disabled'); 253 } else 254 $(`${self.returnDateId}`).removeAttr('disabled'); 255 } 256 }); 257 258 this.initLocationCookie(theme); 259 260 $(this.wrapWithContainer('.mooncalendar')).bind('click', function () { 261 //var win = window.open('http://www.informatik.uni-leipzig.de/~duc/amlich/PHP/index.php', 'Tra cứu lá»ch âm', 'width=500,height=550'); 262 $(self.wrapWithContainer('#popup')) 263 .html("<iframe src='http://www.informatik.uni-leipzig.de/~duc/amlich/PHP/index.php\' width='500' height='600'></iframe>") 264 .dialog( 265 { 266 title: 've24h.vn', 267 width: 550, 268 height: 600, 269 modal: true 270 }).dialog("open"); 271 }); 272 273 $(this.wrapWithContainer('.dateicon')).bind('click', function () { 274 var $input = $(this).prev(); 275 if ($input.attr('disabled') !== 'disabled') 276 $input.datepicker('show'); 277 }); 278 279 $(this.wrapWithContainer('#flightSearchForm')).submit(function (event) { 280 var msg = ''; 281 var success = true; 282 var count = 0; 283 if ($(self.wrapWithContainer('#DepartureCity')).val() == '') { 284 msg += 'Vui lòng chá»n Äiá»m khá»i hà nh! <br />'; 285 success = false; 286 count++; 287 $(`${self.dialogSearchError}`).attr('data-error', '1'); 288 } 289 if ($(self.wrapWithContainer('#ArrivalCity')).val() == '') { 290 msg += 'Vui lòng chá»n Äiá»m Äến! <br />'; 291 success = false; 292 if (count == 0) { 293 count = 2; 294 $(`${self.dialogSearchError}`).attr('data-error', '2'); 295 } 296 } 297 if ($(`${self.departureDateId}`).val() == '') { 298 msg += 'Vui lòng chá»n ngà y Äi! <br />'; 299 success = false; 300 if (count == 0) { 301 count = 3; 302 $(`${self.dialogSearchError}`).attr('data-error', '3'); 303 } 304 } 305 306 if ($(self.wrapWithContainer('#radioRoundTrip')).is(':checked') && ($(`${self.returnDateId}`).val() == '' || $(`${self.returnDateId}`).val() == '')) { 307 if (theme != 'Globalink') { 308 msg += 'Vui lòng chá»n ngà y vá»! <br />'; 309 success = false; 310 if (count == 0) { 311 count = 4; 312 $(`${self.dialogSearchError}`).attr('data-error', '4'); 313 } 314 } 315 } 316 317 if ($(
317self.wrapWithContainer('#radioRoundTripSecondary')).is(':checked') && ($(`${self.returnDateId}`).val() == '' || $(`${self.returnDateId}`).val() == '')) { 318 if (theme != 'Globalink') { 319 msg += 'Vui lòng chá»n ngà y vá»! <br />'; 320 success = false; 321 if (count == 0) { 322 count = 4; 323 $(`${self.dialogSearchError}`).attr('data-error', '4'); 324 } 325 } 326 } 327 328 329 if (parseInt($(self.wrapWithContainer('select[name="InfantNo"]')).val()) > parseInt($(self.wrapWithContainer('select[name="AdultNo"]')).val())) { 330 msg += "Sá» khách em bé nhiá»u hÆ¡n sá» khách ngưá»i lá»n. Vui lòng chá»n lại! <br/>"; 331 success = false; 332 if (count == 0) { 333 count = 5; 334 $(`${self.dialogSearchError}`).attr('data-error', '5'); 335 } 336 } 337 338 if (!success) { 339 event.preventDefault(); 340 $(`${self.dialogSearchError} #errormessage`).html(msg); 341 //window.dialog.display(msg, 'Error'); 342 $dialogerorr.dialog('option', 'title', 'Lá»i phát sinh'); 343 //$dialogerorr.dialog('option', 'position', { my: "left top", at: "left bottom", of: e.target }); 344 $dialogerorr.dialog('open'); 345 } else { 346 self.saveLocationCookie(); 347 348 $(`${self.dialogSearchError} #errormessage`).html(""); 349 $(`${self.dialogSearchError}`).attr('data-error', '0'); 350 self.submitSearchFlightPrettyUrl(event); 351 } 352 }); 353 354 if ($(this.wrapWithContainer('#btn-switch')).length > 0) { 355 $(this.wrapWithContainer('#btn-switch')).click(function () { 356 self.switchLocations(); 357 }); 358 } 359 360 if ($(this.wrapWithContainer('#viewPassengerInfoContent')).length > 0) { 361 $(this.wrapWithContainer('select[name="AdultNo"]')).change(function () { 362 self.updatePaxInfo(); 363 }); 364 $(this.wrapWithContainer('select[name="ChildNo"]')).change(function () { 365 self.updatePaxInfo(); 366 }); 367 $(this.wrapWithContainer('select[name="InfantNo"]')).change(function () { 368 self.updatePaxInfo(); 369 }); 370 self.updatePaxInfo(); 371 } 372 373 this.initStepperChoosePassenger(); 374 375 if ($(this.wrapWithContainer('.sponsor-holder')).length) { 376 $(this.wrapWithContainer('.sponsor-holder')).carouFredSel({ 377 direction: 'right', 378 scroll: { 379 items: 1 380 }, 381 duration: 3000 382 }); 383 } 384 385 var choseLocationFromDialog = false; 386 $(this.wrapWithContainer('#departure-location-dlg')).attr("id", this.dialogLocationId.replace('#', '')).addClass('departure-location-dlg'); 387 388 var $dialog = $(`${this.dialogLocationId}`).dialog( 389 { 390 modal: false, 391 autoOpen: false, 392 resizable: true, 393 open: function () { 394 $("body").addClass("open-dialog"); 395 $(self.wrapWithContainer('#inter-city-departure')).focus(); 396 }, 397 close: function () { 398 $dialog.dialog('close'); 399 $("body").removeClass("open-dialog"); 400 401 //**************************************************************************************** 402 // Fix bugs: some do not auto popup the next component after selecting current component 403 // Note 22/01/2026: off auto popup when select location 404 //**************************************************************************************** 405 //var keySearch = $(self.wrapWithContainer("#UseSearchAutoFocusComponent")).val().toLowerCase(); 406 //if (keySearch == "true") { 407 // var mode = $(`${self.dialogLocationId}`).attr('data-mode'); 408 // if (mode == "Departure") { 409 // if ($(self.wrapWithContainer('#DepartureCity-Holder')).val() != "Äiá»m khá»i hà nh") { 410 // //$(this.wrapWithContainer('#ArrivalCity-Holder').select(); 411 // $(self.wrapWithContainer('#ArrivalCity-Holder')).click(); 412 // } else { 413 // $(self.wrapWithContainer('#DepartureCity-Holder')).focus(); 414 // } 415 // } else { 416 // if ($(self.wrapWithContainer('#ArrivalCity-Holder')).val() != "NÆ¡i Äến") { 417 // $(`${self.departureDateId}`).focus(); 418 // } else { 419 // $(self.wrapWithContainer('#ArrivalCity-Holder')).focus(); 420 // } 421 // } 422 //} 423 } 424 }); 425 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') { 426 $(`${this.dialogLocationId}`).dialog("option", "modal", true); 427 }; 428 var $dialog_domestic = $(this.wrapWithContainer('#departure-location-dlg-domestic')).dialog( 429 { 430 modal: false, 431 autoOpen: false, 432 resizable: true, 433 minWidth: 700, 434 open: function () { 435 $(self.wrapWithContainer('#inter-city-departure')).focus(); 436 $("body").addClass("open-dialog"); 437 }, 438 close: function () { 439 $dialog_domestic.dialog('close'); 440 $("body").removeClass("open-dialog"); 441 442 //**************************************************************************************** 443 // Fix bugs: some do not auto popup the next component after selecting current component 444 //**************************************************************************************** 445 //var keySearch = $(self.wrapWithContainer("#UseSearchAutoFocusComponent")).val().toLowerCase(); 446 //if (keySearch == "true") { 447 // var mode = $(self.wrapWithContainer('#departure-location-dlg-domestic')).attr('data-mode'); 448 // if (mode == "Departure") { 449 // if ($(self.wrapWithContainer('#DepartureCity-Holder-Domestic')).val() != "Äiá»m khá»i hà nh") { 450 // $(self.wrapWithContainer('#ArrivalCity-Holder')).select(); 451 // } else { 452 // $(self.wrapWithContainer('#DepartureCity-Holder-Domestic')).focus(); 453 // } 454 // } else { 455 // if ($(self.wrapWithContainer('#ArrivalCity-Holder')).val() != "NÆ¡i Äến") { 456 // $(`${self.departureDateId}`).focus(); 457 // } else { 458 // $(self.wrapWithContainer('#ArrivalCity-Holder')).focus(); 459 // } 460 // } 461 //} 462 } 463 }); 464 465 var $dialogerorr = $(`${self.dialogSearchError}`).dialog( 466 { 467 modal: false, 468 width: 300, 469 autoOpen: false, 470 resizable: false, 471 open: function () { 472 473 }, 474 close: function () { 475 $dialogerorr.dialog('close'); 476 var count = $(`${self.dialogSearchError}`).attr('data-error'); 477 switch (count) { 478 case '1': 479 $(self.wrapWithContainer('#DepartureCity-Holder')).focus(); 480 break; 481 case '2': 482 $(self.wrapWithContainer('#ArrivalCity-Holder')).focus(); 483 break; 484 case '3': 485 $(`${self.departureDateId}`).focus(); 486 break; 487 case '4': 488 $(`${self.returnDateId}`).focus(); 489 break; 490 } 491 } 492 }); 493 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') { 494 $(`${self.dialogSearchError}`).dialog("option", "modal", true); 495 }; 496 497 $(this.wrapWithContainer('#DepartureCity-Holder')).bind('click', function (e) { 498 $(`${self.dialogLocationId} .location-link`).each(function () { 499 $(this).show(); 500 }); 501 var theme = $('#Theme').val(); 502 //$(this.wrapWithContainer('#inter-city-departure')).val($(this.wrapWithContainer('#DepartureCity-Holder')).val()); 503 //$(this.wrapWithContainer("#inter-city-departure")).attr('data-locationId', $(this.wrapWithContainer('#DepartureCity')).val()); 504 505 if (theme == 'LienLucDia') { 506 507 $(self.wrapWithContainer('.location-link-domestic')).each(function () { 508 $(this).show(); 509 }); 510 511 $(self.wrapWithContainer('#departure-location-dlg-domestic')).attr('data-mode', 'Departure'); 512 var dataTitleDeparture = $(self.wrapWithContainer('#departure-location-dlg-domestic')).attr('data-title-departure'); 513 $dialog_domestic.dialog('option', 'title', dataTitleDeparture); 514 $dialog_domestic.dialog('option', 'width', 180); 515 $dialog_domestic.dialog('option', 'height', 550); 516 $dialog_domestic.dialog({ resizable: false, draggable: false }); 517 assignDialogSize($dialog_domestic);
518 $(self.wrapWithContainer('#departure-location-dlg-domestic')).parents().css("max-height", "150px"); 519 $dialog_domestic.dialog('option', 'position', { my: "left top", at: "left bottom", of: e.target }); 520 521 $(self.wrapWithContainer('#departure-location-dlg-domestic')).attr('data-id', this.id); 522 self.loadLocationByFlightConnection($(self.wrapWithContainer("#DepartureCity")).val()); 523 $dialog_domestic.dialog('open'); 524 } 525 else { 526 $(`${self.dialogLocationId}`).attr('data-mode', 'Departure'); 527 var dataTitleDeparture = $(`${self.dialogLocationId}`).attr('data-title-departure'); 528 $dialog.dialog('option', 'title', dataTitleDeparture); 529 assignDialogSize($dialog); 530 $dialog.dialog('option', 'position', { my: "left top", at: "left bottom", of: e.target }); 531 $dialog.dialog('option', 'z-index', 2); 532 $(`${self.dialogLocationId}`).attr('data-id', this.id); 533 534 if ($(self.wrapWithContainer('#IsUseInternationalAndDometicTab')).val() != undefined && $(self.wrapWithContainer('#IsUseInternationalAndDometicTab')).val().toLowerCase() == "true") { 535 536 ShowInternationalOrDomesticLocation(); 537 } 538 539 $dialog.dialog('open'); 540 } 541 }); 542 543 $(this.wrapWithContainer('#ArrivalCity-Holder')).bind('click', function (e) { 544 $(`${self.dialogLocationId} .location-link`).each(function () { 545 $(this).show(); 546 }); 547 548 var theme = $('#Theme').val(); 549 550 //$(this.wrapWithContainer('#inter-city-departure')).val($(this.wrapWithContainer('#ArrivalCity-Holder')).val()); 551 //$(this.wrapWithContainer("#inter-city-departure")).attr('data-locationId', $(this.wrapWithContainer('#ArrivalCity')).val()); 552 553 if (theme == 'LienLucDia') { 554 555 $(`${self.dialogLocationId} .location-link`).each(function () { 556 $(this).show(); 557 }); 558 } 559 560 var departureCity = $(self.wrapWithContainer('#DepartureCity')).val(); 561 var parentId = []; 562 if ($(self.wrapWithContainer("#filter-arrival-location")).val().toLowerCase() == 'true') { 563 var flightConnection = []; 564 $(self.wrapWithContainer('#FlightConnection > option')).each(function () { 565 var fconnection = $(this).val(); 566 if (fconnection == departureCity) { 567 flightConnection.push($(this).text()); 568 } 569 }); 570 571 $(`${self.dialogLocationId} .location-link`).each(function () { 572 573 var locationId = $(this).attr('data-code'); 574 var flag = false; 575 for (var i = 0; i < flightConnection.length; i++) { 576 if (locationId == flightConnection[i]) { 577 flag = true; 578 break; 579 } 580 } 581 if (flag == false) { 582 $(this).hide(); 583 } else { 584 $(this).show(); 585 } 586 }); 587 if (theme == 'LienLucDia') { 588 $(`${self.dialogLocationId} .location-link`).each(function () { 589 var locationId = $(this).attr('data-code'); 590 var flag = false; 591 for (var i = 0; i < flightConnection.length; i++) { 592 if (locationId == flightConnection[i]) { 593 flag = true; 594 break; 595 } 596 } 597 if (flag == false) { 598 $(this).hide(); 599 } else { 600 $(this).show(); 601 } 602 }); 603 } 604 605 } 606 607 // Remove selected departure city out of arrival list 608 $(`${self.dialogLocationId} .location-link`).each(function () { 609 var locationId = $(this).attr('data-code'); 610 if (locationId == departureCity) { 611 $(this).hide(); 612 } 613 else { 614 parentId.push($(this).attr('data-parentid')); 615 } 616 }); 617 $(self.wrapWithContainer('.countryTitle')).each(function () { 618 var flag = false; 619 var id = $(this).attr('data-parentid'); 620 for (var i = 0; i < parentId.length; i++) { 621 if (parentId[i] == id) { 622 flag = true; 623 } 624 } 625 if (flag == false) { 626 $(this).hide(); 627 } 628 //else { 629 // $(this).show(); 630 //} 631 }); 632 $(`${self.dialogLocationId}`).attr('data-mode', 'Arrival'); 633 var dataTitleArrival = $(`${self.dialogLocationId}`).attr('data-title-arrival'); 634 $dialog.dialog('option', 'title', dataTitleArrival); 635 assignDialogSize($dialog); 636 $dialog.dialog('option', 'position', { my: "left top", at: "left bottom", of: e.target }); 637 $(`${self.dialogLocationId}`).attr('data-id', this.id); 638 if (theme == "LienLucDia") { 639 $(`${self.dialogLocationId}`).parents().css("max-height", "150px"); 640 $dialog.dialog({ resizable: false, draggable: false }); 641 } 642 if ($(self.wrapWithContainer('#IsUseInternationalAndDometicTab')).val() != undefined && $(self.wrapWithContainer('#IsUseInternationalAndDometicTab')).val().toLowerCase() == "true") { 643 ShowInternationalOrDomesticLocation(); 644 } 645 646 $dialog.dialog('open'); 647 }); 648 649 function assignDialogSize(dialog) { 650 if (self.getSearchDialogWidth() > 0) { 651 dialog.dialog('option', 'width', self.getSearchDialogWidth()); 652 } 653 if (self.getSearchDialogHeight() > 0) { 654 dialog.dialog('option', 'height', self.getSearchDialogHeight()); 655 656 } 657 658 } 659 660 var thisDay = new Date(); 661 var monthOfCalendar = thisDay.getMonth() + 1; 662 var yearOfCalendar = thisDay.getFullYear(); 663 if (containerId) { 664 $(`${self.departureDateId}, ${self.returnDateId}`).datepickerlunar({ 665 dateFormat: 'dd/mm/yy', 666 defaultDate: "+0d",
667 changeMonth: false, 668 //numberOfMonths: displayNumberOfMonth, 669 minDate: 0, 670 autoclose: true, 671 onSelect: function (selectedDate) { 672 $("body").removeClass("open-dialog"); 673 var selectedDate = $(this).val(); 674 var option = this.id == self.departureDateId.replace('#', '') ? "minDate" : "maxDate", 675 instance = $(this).data("datepickerlunar"); 676 var date = $.datepickerlunar.parseDate( 677 instance.settings.dateFormat || 678 $.datepicker._defaults.dateFormat, 679 selectedDate, instance.settings); 680 monthOfCalendar = date.getMonth() + 1; 681 yearOfCalendar = date.getFullYear(); 682 if (this.id == self.departureDateId.replace('#', '')) { 683 $(`${self.returnDateId}`).datepickerlunar("option", 'minDate', date); 684 685 if ($(self.wrapWithContainer("input[name='JourneyType']:checked")).val() == '1') { 686 687 $(`${self.returnDateId}`).val(''); 688 } 689 } 690 else { 691 $(`${self.departureDateId}`).datepickerlunar("option", 'maxDate', date); 692 } 693 //************************************************************************************ 694 // Fix bugs: some do not auto popup the next component after selecting current component 695 //************************************************************************************ 696 var focusvalue = $('#ui-datepicker-div').attr('data-date-mode'); 697 var keySearch = $(self.wrapWithContainer("#UseSearchAutoFocusComponent")).val().toLowerCase(); 698 if (keySearch == "true") { 699 if (focusvalue == "depaturedatefocus") { 700 $("body").removeClass("open-dialog"); 701 if ($(self.wrapWithContainer("input[name='JourneyType']:checked")).val() == '2') { 702 $(`${self.returnDateId}`).focus(); 703 } 704 } 705 else { 706 $('#ui-datepicker-div').hide(); 707 $("body").removeClass("open-dialog"); 708 } 709 710 if (theme == 'HongNgocHa' && focusvalue != 'depaturedatefocus') { 711 if ($(self.wrapWithContainer("input[name='JourneyType']:checked")).val() == '1') { 712 $(`${self.returnDateId}`).focus(); 713 $(self.wrapWithContainer('label[for=radioRoundTrip]')).click();//lam cach nao de ko chay lai cai su kien click 714 $(self.wrapWithContainer('label[for=radioRoundTripSecondary]')).click(); 715 716 } 717 } 718 } 719 }, 720 onClose: function (selectedDate) { 721 $("body").removeClass("open-dialog"); 722 }, 723 onChangeMonthYear: function (year, month, inst) { 724 monthOfCalendar = month; 725 yearOfCalendar = year; 726 self.currentCalendarMonth = month; 727 self.currentCalendarYear = year; 728 if (share.flight_search_dialog.enableShowLowestPriceOnSearchBox) 729 self.showLowestPriceInCalendar(this.id == "depatureDate" ? true : false); 730 731 } 732 }); 733 } 734 else { 735 $("#depatureDate, #returnDate").datepickerlunar({ 736 dateFormat: 'dd/mm/yy', 737 defaultDate: "+0d",
738 changeMonth: false, 739 //numberOfMonths: displayNumberOfMonth, 740 minDate: 0, 741 autoclose: true, 742 onSelect: function (selectedDate) { 743 var selectedDate = $(this).val(); 744 var option = this.id == "depatureDate" ? "minDate" : "maxDate", 745 instance = $(this).data("datepickerlunar"); 746 var date = $.datepickerlunar.parseDate( 747 instance.settings.dateFormat || 748 $.datepicker._defaults.dateFormat, 749 selectedDate, instance.settings); 750 monthOfCalendar = date.getMonth() + 1; 751 yearOfCalendar = date.getFullYear(); 752 if (this.id == "depatureDate") { 753 $(self.wrapWithContainer("#returnDate")).datepickerlunar("option", 'minDate', date); 754 755 if ($(self.wrapWithContainer("input[name='JourneyType']:checked")).val() == '1') { 756 757 $(self.wrapWithContainer("#returnDate")).val('').addClass('ngay-ve'); 758 } 759 } 760 else { 761 $(self.wrapWithContainer("#depatureDate")).datepickerlunar("option", 'maxDate', date); 762 } 763 //************************************************************************************ 764 // Fix bugs: some do not auto popup the next component after selecting current component 765 //************************************************************************************ 766 //var focusvalue = $(self.wrapWithContainer('#ui-datepicker-div')).attr('data-date-mode'); 767 //var keySearch = $(self.wrapWithContainer("#UseSearchAutoFocusComponent")).val().toLowerCase(); 768 //if (keySearch == "true") { 769 770 // if (focusvalue == "depaturedatefocus") { 771 // $("body").removeClass("open-dialog"); 772 // if ($(self.wrapWithContainer("input[name='JourneyType']:checked")).val() == '2') { 773 // $(self.wrapWithContainer('#returnDate')).focus(); 774 // } 775 // } 776 // else { 777 // $(self.wrapWithContainer('#ui-datepicker-div')).hide(); 778 // $("body").removeClass("open-dialog"); 779 // } 780 781 // if (theme == 'HongNgocHa' && focusvalue != 'depaturedatefocus') { 782 // if ($(self.wrapWithContainer("input[name='JourneyType']:checked")).val() == '1') { 783 // $(self.wrapWithContainer('#returnDate')).focus(); 784 // $(self.wrapWithContainer('label[for=radioRoundTrip]')).click();//lam cach nao de ko chay lai cai su kien click 785 786 // } 787 // } 788 //} 789 }, 790 onClose: function (selectedDate) { 791 $("body").removeClass("open-dialog"); 792 }, 793 onChangeMonthYear: function (year, month, inst) { 794 monthOfCalendar = month; 795 yearOfCalendar = year; 796 self.currentCalendarMonth = month; 797 self.currentCalendarYear = year; 798 if (share.flight_search_dialog.enableShowLowestPriceOnSearchBox) 799 self.showLowestPriceInCalendar(this.id == "depatureDate" ? true : false); 800 801 } 802 }); 803 } 804 805 $(`${self.departureDateId}`).on('focus', function (e) { 806 $("body").addClass("open-dialog"); 807 $('#ui-datepicker-div').attr('data-date-mode', 'depaturedatefocus'); 808 }); 809 $(`${self.departureDateId}`).on('click', function (e) { 810 if (share.flight_search_dialog.enableShowLowestPriceOnSearchBox
810) { 811 var val = $(this).val(); 812 if (val) { 813 var parts = val.split('/'); 814 if (parts.length === 3) { 815 self.currentCalendarMonth = parseInt(parts[1]); 816 self.currentCalendarYear = parseInt(parts[2]); 817 } 818 } 819 self.showLowestPriceInCalendar(true); 820 } 821 822 }); 823 824 $(`${self.returnDateId}`).on('focus', function (e) { 825 //if (theme != 'HongNgocHa') { 826 $("body").addClass("open-dialog"); 827 $('#ui-datepicker-div').attr('data-date-mode', 'returndatefocus'); 828 //} 829 }); 830 $(`${self.returnDateId}`).on('click', function (e) { 831 if (share.flight_search_dialog.enableShowLowestPriceOnSearchBox) { 832 var val = $(this).val(); 833 if (val) { 834 var parts = val.split('/'); 835 if (parts.length === 3) { 836 self.currentCalendarMonth = parseInt(parts[1]); 837 self.currentCalendarYear = parseInt(parts[2]); 838 } 839 } 840 self.showLowestPriceInCalendar(false); 841 } 842 }); 843 /*$(this.wrapWithContainer('#returnDate').change( function (e) { 844 845 });*/ 846 847 /*dates.change(function (selectedDate) { 848 var selectedDate = $(this).val(); 849 var option = this.id == "depatureDate" ? "minDate" : "maxDate", 850 instance = $(this).data("datepickerlunar"); 851 var date = $.datepickerlunar.parseDate( 852 instance.settings.dateFormat || 853 $.datepicker._defaults.dateFormat, 854 selectedDate, instance.settings); 855 dates.not(this).datepickerlunar("option", option, date); 856 857 858 });*/ 859 860 $('#ui-datepicker-div').bind('mouseleave', function (e) { 861 //$(this.wrapWithContainer('#ui-datepicker-div').hide(); 862 }); 863 864 var theme = $('#Theme').val(); 865 $(this.wrapWithContainer('.location-link-domestic')).bind('click', function () { 866 var element = $(self.wrapWithContainer('#departure-location-dlg-domestic')).attr('data-id'); 867 $(self.wrapWithContainer('#' + element)).val($(this).attr('data-val')); 868 var valuedElement = element.split('-')[0]; 869 $(self.wrapWithContainer('#' + valuedElement)).val($(this).attr('data-code')); 870 $dialog_domestic.dialog('close'); 871 this.loadLocationByFlightConnection($(self.wrapWithContainer("#DepartureCity")).val()); 872 }); 873 874 $(`${this.dialogLocationId} .location-link`).bind('click', function () { 875 var element = $(`${self.dialogLocationId}`).attr('data-id'); 876 $(self.wrapWithContainer('#' + element)).val($(this).attr('data-val')); 877 var valuedElement = element.split('-')[0]; 878 $(self.wrapWithContainer('#' + valuedElement)).val($(this).attr('data-code')); 879 880 if (theme == 'HongNgocHa' || theme == 'CanhChimViet' || theme == 'HongNgocHa_V2' || theme == 'NuCuoiTravel') { 881 var dataMode = $(`${self.dialogLocationId}`).attr('data-mode'); 882 if (dataMode == 'Departure') { 883 $(self.wrapWithContainer("#DepartureCityCountry")).val($(this).attr('data-country')); 884 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') 885 $(self.wrapWithContainer("#departure-country")).text($(this).attr('data-country')); 886 } 887 if (dataMode == 'Arrival') { 888 $(self.wrapWithContainer("#ArrivalCityCountry")).val($(this).attr('data-country')); 889 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') 890 $(self.wrapWithContainer("#arrival-country")).text($(this).attr('data-country')); 891 } 892 } 893 $dialog.dialog('close'); 894 }); 895 896 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') { 897 $(this.wrapWithContainer('#inter-city-departure')).bind('change', function (event) { 898 $(this).attr('data-locationId', $(this).val()); 899 var dataMode = $(`${self.dialogLocationId}`).attr('data-mode'); 900 if (dataMode == 'Departure') { 901 $(self.wrapWithContainer("#DepartureCityCountry")).val($(self.wrapWithContainer("#selectCountry option:selected")).text()); 902 $(self.wrapWithContainer("#departure-country")).text($(self.wrapWithContainer("#selectCountry option:selected")).text()); 903 } 904 if (dataMode == 'Arrival') { 905 $(self.wrapWithContainer("#ArrivalCityCountry")).val($(self.wrapWithContainer("#selectCountry option:selected")).text()); 906 $(self.wrapWithContainer("#arrival-country")).text($(self.wrapWithContainer("#selectCountry option:selected")).text()); 907 } 908 }); 909 } 910 else { 911 $(`${this.dialogLocationId} #inter-city-departure`).autocomplete({ 912 delay: 100, 913 //source: '/Home/SearchLocation', 914 source: function (request, response) { 915 if (typeof productId !== 'undefined') { 916 $(`${self.dialogLocationId} #inter-city-departure`).attr('data-locationId', ''); 917 $.ajax({
918 url: '/Home/SearchRailwaysLocation', 919 type: 'GET', 920 data: { 921 term: request.term, 922 }, 923 success: function (data) { 924 response(data); 925 } 926 }); 927 } else { 928 $(`${self.dialogLocationId} #inter-city-departure`).attr('data-locationId', ''); 929 $.ajax({ 930 url: '/Home/SearchLocation', 931 type: 'GET', 932 data: { 933 term: request.term, 934 }, 935 success: function (data) { 936 response(data); 937 } 938 }); 939 } 940 }, 941 select: function (event, ui) { 942 console.log(ui); 943 $(`${self.dialogLocationId} #inter-city-departure`).val(ui.item.label); 944 $(`${self.dialogLocationId} #inter-city-departure`).attr('data-locationId', ui.item.value); 945 choseLocationFromDialog = true; 946 947 chooseLocation(); 948 return false; 949 }, 950 951 }); 952 $(this.wrapWithContainer("#inter-city-departure-text")).autocomplete({ 953 delay: 100, 954 source: '/Home/SearchLocation', 955 select: function (event, ui) { 956 $(`${self.dialogLocationId} #inter-city-departure`).val(ui.item.label); 957 $(self.wrapWithContainer("#inter-city-departure-text")).val(ui.item.label); 958 choseLocationFromDialog = true; 959 return false; 960 }, 961 }); 962 963 $(`${this.dialogLocationId} #inter-city-departure`).bind('keydown', function (event) { 964 965 if (event.which == 13 || event.keyCode == 13) { 966 var location = $(`${self.dialogLocationId} #inter-city-departure`); 967 var loc = location.val(); 968 969 if (loc.length > 0 && choseLocationFromDialog) { 970 var element = $(`${self.dialogLocationId}`).attr('data-id'); 971 972 $(self.wrapWithContainer('#' + element)).val(loc); 973 var valuedElement = element.split('-')[0]; 974 var locationId = loc.substring(loc.indexOf('(') + 1, loc.lastIndexOf(')')); 975 $(self.wrapWithContainer('#' + valuedElement)).val(locationId); 976 //('#inter-city-departure').val(''); 977 978 } 979 980 $dialog.dialog('close'); 981 } 982 }); 983 } 984 985 $(this.wrapWithContainer('#btnChooseLocation')).bind('click', function () { 986 chooseLocation(); 987 }); 988 989 990 $(this.wrapWithContainer('.show-detail-flight')).bind('click', function () { 991 var $link = $(this); 992 $(self.wrapWithContainer('#DepartureCity')).val($link.attr('data-departure-code')); 993 $(self.wrapWithContainer('#ArrivalCity')).val($link.attr('data-arrival-code')); 994 $(self.wrapWithContainer('#adultNo')).val(1); 995 $(self.wrapWithContainer('#childNo #infantNo')).val(0); 996 $(`${self.departureDateId}`).val($link.attr('data-date')); 997 $(self.wrapWithContainer('#radioOneWay')).click(); 998 $(self.wrapWithContainer('#radioOneWaySecondary')).click(); 999 $(self.wrapWithContainer('#IsDetailAction')).val(true); 1000 $(self.wrapWithContainer('form')).submit(); 1001 }); 1002 1003 $(this.wrapWithContainer('#btnSentEmail')).bind('click', function () { 1004 var email = $(self.wrapWithContainer('#emailCustomer')).val();
1005 var validationResult = share.flight_search_dialog.validatesentmail(); 1006 if (!validationResult) { 1007 var msg = "Nháºp Email không Äúng Äá»nh dạng!"; 1008 window.dialog.display(msg, 'Error'); 1009 return false; 1010 } else { 1011 var url = "/Home/SaveEmailRegistration"; 1012 var datasend = { 1013 Email: email 1014 }; 1015 $.ajax({ 1016 type: "POST", 1017 url: url, 1018 data: JSON.stringify(datasend), 1019 dataType: "json", 1020 contentType: "application/json;charset=utf-8", 1021 success: function (response) { 1022 if (response.Result) { 1023 window.dialog.display("ÄÄng ký Email thà nh công!", "Thông báo"); 1024 } else { 1025 const msg = response.ErrorMessage || "ÄÄng ký Email không thà nh công"; 1026 window.dialog.display(msg, "Lá»i phát sinh"); 1027 } 1028 }, 1029 complete: function () { 1030 $.unblockUI(); 1031 } 1032 }); 1033 } 1034 }); 1035 1036 function ShowInternationalOrDomesticLocation() { 1037 var isDemostic = $(self.wrapWithContainer("input[name='FlightType']:checked")).val().toLowerCase(); 1038 if (isDemostic == "true") { 1039 $dialog.dialog('option', 'width', $(self.wrapWithContainer('#search-dialog-domestic-width')).val()); 1040 $(self.wrapWithContainer('#international-location')).hide(); 1041 $(self.wrapWithContainer('#domestic-locaiton')).show(); 1042 } 1043 else { 1044 $dialog.dialog('option', 'width', $(self.wrapWithContainer('#search-dialog-international-width')).val()); 1045 $(self.wrapWithContainer('#international-location')).show(); 1046 $(self.wrapWithContainer('#domestic-locaiton')).hide(); 1047 } 1048 }; 1049 1050 function chooseLocation() { 1051 var theme = $('#Theme').val(); 1052 var locationIdDialog = $(`${self.dialogLocationId} #inter-city-departure`).attr('data-locationId'); 1053 if (!locationIdDialog) { 1054 return; 1055 } 1056 var location = $(`${self.dialogLocationId} #inter-city-departure`); 1057 var loc = location.val(); 1058 //if (location.prop('tagName') == 'SELECT') { 1059 if (loc == null || loc == '-1' || loc == '') 1060 return; 1061 //loc = $(this.wrapWithContainer('#inter-city-departure option:selected').text(); 1062 choseLocationFromDialog = true; 1063 //} 1064 if (loc.length > 0 && choseLocationFromDialog) { 1065 var element = $(`${self.dialogLocationId}`).attr('data-id'); 1066 var valuedElement = element.split('-')[0]; 1067 1068 if (valuedElement == 'DepartureCity') { 1069 if ($(`${self.dialogLocationId} #inter-city-departure`).attr('data-locationId') == $(self.wrapWithContainer('#ArrivalCity')).val()) { 1070 if (typeof productId == 'undefined') { 1071 $(`${self.dialogSearchError} #errormessage`).html("Không ÄÆ°á»£c chá»n sân bay giá»ng nhau. Vui lòng chá»n sân bay khác!"); 1072 } else { 1073 $(`${self.dialogSearchError} #errormessage`).html("Không ÄÆ°á»£c chá»n ga giá»ng nhau. Vui lòng chá»n ga khác!"); 1074 } 1075 $dialogerorr.dialog('option', 'title', 'Lá»i phát sinh'); 1076 $dialogerorr.dialog('open'); 1077 return; 1078 } 1079 } else if (valuedElement == 'ArrivalCity') { 1080 if ($(`${self.dialogLocationId} #inter-city-departure`).attr('data-locationId') == $(self.wrapWithContainer('#DepartureCity')).val()) { 1081 if (typeof productId == 'undefined') { 1082 $(`${self.dialogSearchError} #errormessage`).html("Không ÄÆ°á»£c chá»n sân bay giá»ng nhau. Vui lòng chá»n sân bay khác!"); 1083 } else { 1084 $(`${self.dialogSearchError} #errormessage`).html("Không ÄÆ°á»£c chá»n ga giá»ng nhau. Vui lòng chá»n ga khác!"); 1085 } 1086 $dialogerorr.dialog('option', 'title', 'Lá»i phát sinh'); 1087 $dialogerorr.dialog('open'); 1088 return; 1089 } 1090 } 1091 //var locationId = loc.substring(loc.indexOf('(') + 1, loc.lastIndexOf(')')); 1092 $(self.wrapWithContainer('#' + element)).val(loc); 1093 var locationId = location.val(); 1094 var locationCountry = ''; 1095 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') { 1096 locationId = location.val(); 1097 locationCountry = $(`${self.dialogLocationId} #inter-city-departure option:selected`).text(); 1098 $(self.wrapWithContainer('#' + valuedElement + '-Holder')).val(locationCountry); 1099 } else { 1100 locationId = location.attr('data-locationId'); 1101 locationCountry = loc.substring(loc.indexOf(',') + 1); 1102 } 1103 1104 $(self.wrapWithContainer('#' + valuedElement)).val(locationId); 1105 $(`${self.dialogLocationId} #inter-city-departure`).val(''); 1106 $(self.wrapWithContainer('#' + valuedElement + 'Country')).val(locationCountry); 1107 } 1108 $dialog.dialog('close'); 1109 }; 1110 if ($('#monthly-flight-price-widget').length > 0) { 1111 this.initMonthlyPriceTable(); 1112 } 1113 1114 if ($('.card-new-booking').length > 0) { 1115 this.initRecentBookingsPanel(); 1116 } 1117 }, 1118 1119 showNoteYearOldArticle: function (articleId) { 1120 // 1121 var $dialogNoteYearOld = $('#NoteYearOldDialog').dialog({ 1122 title: '', 1123 close: function () { 1124 $dialogNoteYearOld.dialog("destroy"); 1125 }, 1126 modal: true, 1127 autoOpen: false, 1128 width: 520 1129 }); 1130 $dialogNoteYearOld.dialog('open'); 1131 $('#YearOldDialogCondition').addClass('hide'); 1132 $('#YearOldDialogConditionContent').text(''); 1133 $.ajax({
1134 url: '/Home/GetNoteYearOldArticle', 1135 type: 'POST', 1136 data: { 1137 articleId: articleId 1138 }, 1139 //contentType: 'application/json; charset=UTF-8', 1140 success: function (response) { 1141 if (response.HasData) { 1142 $('#YearOldDialogCondition').removeClass('hide'); 1143 $('#YearOldDialogConditionContent').html(response.Content); 1144 } 1145 } 1146 }); 1147 }, 1148 1149 initLocationCookie(theme) { 1150 this.encodeUrlCookie(); 1151 1152 // Do not save cookie for mobile layout 1153 if ($(this.wrapWithContainer('#DepartureCity-Holder')).prop('tagName') == 'SELECT') 1154 return; 1155 1156 var languageId = $("#LanguageId").val(); 1157 1158 if ($.cookie('departureCity') == null) { 1159 var theme = $('#Theme').val(); 1160 1161 if (typeof productId !== 'undefined') { 1162 $.cookie('departureCityHolder', encodeURI('Ha Noi (HNO)'), { path: '/' }); 1163 $.cookie('departureCity', 'HNO_VNR', { path: '/' }); 1164 } else { 1165 if (theme == 'VietJet24') { 1166 $.cookie('departureCityHolder', encodeURI('Äiá»m khá»i hà nh (DD)'), { path: '/' }); 1167 } 1168 else { 1169 if (languageId != '' && languageId == 'vi') { 1170 $.cookie('departureCityHolder', encodeURI('Há» Chà Minh (SGN)'), { path: '/' }); 1171 } 1172 else { 1173 $.cookie('departureCityHolder', encodeURI('Ho Chi Minh (SGN)'), { path: '/' }); 1174 } 1175 } 1176 $.cookie('departureCity', 'SGN', { path: '/' }); 1177 } 1178 } 1179 1180 if ($.cookie('arrivalCity') == null) { 1181 if (typeof productId !== 'undefined') { 1182 $.cookie('arrivalCityHolder', encodeURI('Sai Gon (SGO)'), { path: '/' }); 1183 $.cookie('arrivalCity', 'SGO_VNR', { path: '/' }); 1184 } else { 1185 if (languageId != '' && languageId == 'vi') { 1186 $.cookie('arrivalCityHolder', encodeURI('Hà Ná»i (HAN)'), { path: '/' }); 1187 } 1188 else { 1189 $.cookie('arrivalCityHolder', encodeURI('Ha Noi (HAN)'), { path: '/' }); 1190 } 1191 $.cookie('arrivalCity', 'HAN', { path: '/' }); 1192 } 1193 } 1194 1195 if (theme == 'HongNgocHa' || theme == 'CanhChimViet' || theme == 'HongNgocHa_V2' || theme == 'NuCuoiTravel') { 1196 if ($.cookie('departureCityCountry') == null || $.cookie('departureCityCountry') == '') { 1197 if (languageId != '' && languageId == 'vi') { 1198 $.cookie('departureCityCountry', encodeURI('Viá»t Nam'), { path: '/' }); 1199 } 1200 else { 1201 $.cookie('departureCityCountry', encodeURI('Viet Nam'), { path: '/' }); 1202 } 1203 } 1204 if ($.cookie('arrivalCityCountry') == null || $.cookie('arrivalCityCountry') == '') { 1205 if (languageId != '' && languageId == 'vi') { 1206 $.cookie('arrivalCityCountry', encodeURI('Viá»t Nam'), { path: '/' }); 1207 } 1208 else { 1209 $.cookie('arrivalCityCountry', encodeURI('Viet Nam'), { path: '/' }); 1210 } 1211 } 1212 } 1213 1214 if (theme == 'HongNgocHa' || theme == 'HongNgocHa_V2') { 1215 $(this.wrapWithContainer('#DepartureCity-Holder')).val(decodeURI($.cookie('departureCityHolder')) + ', ' + decodeURI($.cookie('departureCityCountry'))); 1216 $(this.wrapWithContainer('#DepartureCity')).val($.cookie('departureCity')); 1217 $(this.wrapWithContainer('#DepartureCityCountry')).val(decodeURI($.cookie('departureCityCountry'))); 1218 1219 $(this.wrapWithContainer('#ArrivalCity-Holder')).val(decodeURI($.cookie('arrivalCityHolder')) + ', ' + decodeURI($.cookie('arrivalCityCountry'))); 1220 $(this.wrapWithContainer('#ArrivalCity')).val($.cookie('arrivalCity')); 1221 $(this.wrapWithContainer('#ArrivalCityCountry')).val(decodeURI($.cookie('arrivalCityCountry'))); 1222 } 1223 else { 1224 $(this.wrapWithContainer('#DepartureCity-Holder')).val(decodeURI($.cookie('departureCityHolder'))); 1225 $(this.wrapWithContainer('#DepartureCity')).val($.cookie('departureCity')); 1226 1227 $(this.wrapWithContainer('#ArrivalCity-Holder')).val(decodeURI($.cookie('arrivalCityHolder'))); 1228 $(this.wrapWithContainer('#ArrivalCity')).val($.cookie('arrivalCity')); 1229 if (theme == 'CanhChimViet' || theme == 'NuCuoiTravel') { 1230 $(this.wrapWithContainer('#DepartureCityCountry')).val(decodeURI($.cookie('departureCityCountry'))); 1231 $(this.wrapWithContainer('#ArrivalCityCountry')).val(decodeURI($.cookie('arrivalCityCountry'))); 1232 $(this.wrapWithContainer('#departure-country')).text(decodeURI($.cookie('departureCityCountry'))); 1233 $(this.wrapWithContainer('#arrival-country')).text(decodeURI($.cookie('arrivalCityCountry'))); 1234 } 1235 } 1236 1237 1238 if ($.cookie('journeyType') == null) { 1239 $.cookie('journeyType', '1'); 1240 } 1241 1242 var journeyType = $.cookie('journeyType'); 1243 1244 if (journeyType == 1) { 1245 $(this.wrapWithContainer("input[name=JourneyType][value=1]")).closest('label[for=radioOneWay]').click(); 1246 $(this.wrapWithContainer("input[name=JourneyType][value=1]")).closest('label[for=radioOneWaySecondary]').click(); 1247 } 1248 else { 1249 $(this.wrapWithContainer("input[name=JourneyType][value=2]")).closest('label[for=radioRoundTrip]').click(); 1250 $(this.wrapWithContainer("input[name=JourneyType][value=2]")).closest('label[for=radioRoundTripSecondary]').click(); 1251 1252 } 1253 1254 //$(this.wrapWithContainer('#DepartureCity-Holder')).val($.cookie('departureCityHolder')); 1255 //var departureLoc = $(this.wrapWithContainer('#DepartureCity-Holder')).val(); 1256 //var departureLocationId = departureLoc.substring(departureLoc.indexOf('(') + 1, departureLoc.lastIndexOf(')')); 1257 //$(this.wrapWithContainer('#DepartureCity')).val(departureLocationId); 1258 1259 1260 1261 // $(this.wrapWithContainer('#ArrivalCity-Holder')).val($.cookie('arrivalCityHolder')); 1262 //var arrivalLoc = $(this.wrapWithContainer('#ArrivalCity-Holder')).val(); 1263 //var arrivalLocationId = arrivalLoc.substring(arrivalLoc.indexOf('(') + 1, arrivalLoc.lastIndexOf(')')); 1264 //$(this.wrapWithContainer('#ArrivalCity')).val(arrivalLocationId); 1265 1266 if ($.cookie('depatureDate') != null) { 1267 console.log($.cookie('depatureDate')); 1268 $(`${this.departureDateId}`).val($.cookie('depatureDate')); 1269 } 1270 if (theme != 'Globalink' && $.cookie('returnDate') != null && $.cookie('journeyType') == '2') { 1271 $(`${this.returnDateId}`).val($.cookie('returnDate')); 1272 } 1273 1274 if ($.cookie('adultNo') != null && $.cookie('adultNo') != '') { 1275 $(this.wrapWithContainer('#adultNo')).val($.cookie('adultNo')); 1276 } else { 1277 $(this.wrapWithContainer('#adultNo')).val(1); 1278 } 1279 1280 if ($.cookie('childNo') != null && $.cookie('childNo') != '') { 1281 $(this.wrapWithContainer('#childNo')).val($.cookie('childNo')); 1282 } else { 1283 $(this.wrapWithContainer('#childNo')).val(0); 1284 } 1285 1286 if ($.cookie('infantNo') != null && $.cookie('infantNo') != '') { 1287 $(this.wrapWithContainer('#infantNo')).val($.cookie('infantNo')); 1288 } else { 1289 $(this.wrapWithContainer('#infantNo')).val(0); 1290 } 1291 }, 1292 1293 saveLocationCookie() { 1294 var theme = $('#Theme').val(); 1295 $.removeCookie('departureCityHolder', { path: '/Booking' }); 1296 $.removeCookie('arrivalCityHolder', { path: '/Booking' }); 1297 $.removeCookie('departureCity', { path: '/Booking' }); 1298 $.removeCookie('arrivalCity', { path: '/Booking' }); 1299 $.removeCookie('depatureDate', { path: '/Booking' }); 1300 $.removeCookie('returnDate', { path: '/Booking' }); 1301 $.removeCookie('adultNo', { path: '/Booking' }); 1302 $.removeCookie('childNo', { path: '/Booking' }); 1303 $.removeCookie('infantNo', { path: '/Booking' }); 1304 $.removeCookie('journeyType', { path: '/Booking' }); 1305 if (theme == 'HongNgocHa' || theme == 'CanhChimViet' || theme == 'HongNgocHa_V2' || theme == 'NuCuoiTravel') { 1306 $.removeCookie('arrivalCityCountry', { path: '/Booking' }); 1307 $.removeCookie('departureCityCountry', { path: '/Booking' }); 1308 } 1309 1310 //$.removeCookie('departureCityCountry', { path: '/Booking' }); 1311 //$.removeCookie('arrivalCityCountry', { path: '/Booking' }); 1312 1313 var departureCityHolder = $(this.wrapWithContainer('#DepartureCity-Holder')).val(); 1314 var arrivalCityHolder = $(this.wrapWithContainer('#ArrivalCity-Holder')).val(); 1315 1316 if (departureCityHolder.indexOf('%') < 0) { 1317 departureCityHolder = encodeURI(departureCityHolder); 1318 } 1319 if (arrivalCityHolder.indexOf('%') < 0) { 1320 arrivalCityHolder = encodeURI(arrivalCityHolder); 1321 } 1322 1323 1324 $.cookie('departureCityHolder', departureCityHolder, { path: '/' });
1325 $.cookie('arrivalCityHolder', arrivalCityHolder, { path: '/' }); 1326 $.cookie('departureCity', $(this.wrapWithContainer('#DepartureCity')).val(), { path: '/' }); 1327 $.cookie('arrivalCity', $(this.wrapWithContainer('#ArrivalCity')).val(), { path: '/' }); 1328 $.cookie('depatureDate', $(`${this.departureDateId}`).val(), { path: '/' }); 1329 $.cookie('returnDate', $(`${this.returnDateId}`).val(), { path: '/' }); 1330 $.cookie('adultNo', $(this.wrapWithContainer('#adultNo')).val(), { path: '/' }); 1331 $.cookie('childNo', $(this.wrapWithContainer('#childNo')).val(), { path: '/' }); 1332 $.cookie('infantNo', $(this.wrapWithContainer('#infantNo')).val(), { path: '/' }); 1333 $.cookie('journeyType', $(this.wrapWithContainer("input[name='JourneyType']:checked")).val(), { path: '/' }); 1334 1335 if (theme == 'HongNgocHa' || theme == 'CanhChimViet' || theme == 'HongNgocHa_V2' || theme == 'NuCuoiTravel') { 1336 var departureCityCountry = $(this.wrapWithContainer('#DepartureCityCountry')).val(); 1337 var arrivalCityCountry = $(this.wrapWithContainer('#ArrivalCityCountry')).val(); 1338 if (departureCityCountry.indexOf('%') < 0) { 1339 departureCityCountry = encodeURI(departureCityCountry); 1340 } 1341 if (arrivalCityCountry.indexOf('%') < 0) { 1342 arrivalCityCountry = encodeURI(arrivalCityCountry); 1343 } 1344 $.cookie('departureCityCountry', departureCityCountry, { path: '/' }); 1345 $.cookie('arrivalCityCountry', arrivalCityCountry, { path: '/' }); 1346 } 1347 }, 1348 1349 encodeUrlCookie() { 1350 1351 var departureCityHolder = $.cookie('departureCityHolder'); 1352 var arrivalCityHolder = $.cookie('arrivalCityHolder'); 1353 var departureCityCountry = $.cookie('departureCityCountry'); 1354 var arrivalCityCountry = $.cookie('arrivalCityCountry'); 1355 1356 if (departureCityHolder && departureCityHolder.indexOf('%') < 0) { 1357 $.cookie('departureCityHolder', encodeURI(departureCityHolder), { path: '/' }); 1358 } 1359 1360 if (arrivalCityHolder && arrivalCityHolder.indexOf('%') < 0) { 1361 $.cookie('arrivalCityHolder', encodeURI(arrivalCityHolder), { path: '/' }); 1362 } 1363 1364 if (departureCityCountry && departureCityCountry.indexOf('%') < 0) { 1365 $.cookie('departureCityCountry', encodeURI(departureCityCountry), { path: '/' }); 1366 } 1367 1368 if (arrivalCityCountry && arrivalCityCountry.indexOf('%') < 0) { 1369 $.cookie('arrivalCityCountry', encodeURI(arrivalCityCountry), { path: '/' }); 1370 } 1371 }, 1372 1373 submitSearchFlightPrettyUrl(event) { 1374 event.preventDefault(); 1375 var departureCity = $(this.wrapWithContainer('#DepartureCity')).val(); 1376 var arrivalCity = $(this.wrapWithContainer('#ArrivalCity')).val(); 1377 var departureDate = $(`${this.departureDateId}`).val().substring(6, 10) + $(`${this.departureDateId}`).val().substring(3, 5) + $(`${this.departureDateId}`).val().substring(0, 2); 1378 var arrivalDate = $(`${this.returnDateId}`).val().substring(6, 10) + $(`${this.returnDateId}`).val().substring(3, 5) + $(`${this.returnDateId}`).val().substring(0, 2); 1379 var journeyType = $(this.wrapWithContainer("input[name='JourneyType']:checked")).val() == undefined ? "1" : $(this.wrapWithContainer("input[name='JourneyType']:checked")).val(); 1380 var adultNo = $(this.wrapWithContainer('#adultNo option:selected')).val() == undefined ? "1" : $(this.wrapWithContainer('#adultNo option:selected')).val(); 1381 var childNo = $(this.wrapWithContainer('#childNo option:selected')).val() == undefined ? "0" : $(this.wrapWithContainer('#childNo option:selected')).val(); 1382 var infantNo = $(this.wrapWithContainer('#infantNo option:selected')).val() == undefined ? "0" : $(this.wrapWithContainer('#infantNo option:selected')).val(); 1383 var productId = $(this.wrapWithContainer('#productId')).val(); 1384 var theme = $('#Theme').val(); 1385 if (theme == 'NamThanh' || theme == "CanhChimViet" || theme == 'HongNgocHa_V2' || theme == 'NuCuoiTravel' || theme == 'BaseVeMayBay') { 1386 adultNo = $(this.wrapWithContainer('#adultNo')).val(); 1387 childNo = $(this.wrapWithContainer('#childNo')).val(); 1388 infantNo = $(this.wrapWithContainer('#infantNo')).val(); 1389 } 1390 1391 /*if (theme == 'NamThanh') { 1392 var dateNow = new Date(); 1393 var date = new Date(departureDate.substr(0, 4) + "-" + departureDate.substr(4, 2) + "-" + departureDate.substr(6)); 1394 departureDate = Math.round((date - dateNow) / (1000 * 60 * 60 * 24)) + 'D'; 1395 1396 if (journeyType != 1) { 1397 date = new Date(arrivalDate.substr(0, 4) + "-" + arrivalDate.substr(4, 2) + "-" + arrivalDate.substr(6)); 1398 arrivalDate = Math.round((date - dateNow) / (1000 * 60 * 60 * 24)) + 'D'; 1399 } 1400 }*/ 1401 1402 var paramSearchString = departureCity + "-" + arrivalCity + "-" + departureDate; 1403 if (journeyType == 1) { 1404 paramSearchString += '-' + adultNo + childNo + infantNo; 1405 } else { 1406 paramSearchString += '-' + arrivalDate + '-' + adultNo + childNo + infantNo; 1407 } 1408 1409 if (productId != null && productId != '') { 1410 var urlSearchString = `${getLanguageRouting(URLs.searchFlightUrl)}/${paramSearchString}?productId=${productId}`; 1411 } else { 1412 var urlSearchString = `${getLanguageRouting(URLs.searchFlightUrl)}/${paramSearchString}`; 1413 } 1414 location.href = urlSearchString; 1415 }, 1416 1417 loadLocationByFlightConnection(_depatureCity) { 1418 var theme = $('#Theme').val(); 1419 var departureCity = _depatureCity; 1420 if (theme == 'LienLucDia') { 1421 var flightConnection = [];
1422 $(this.wrapWithContainer('#FlightConnection > option')).each(function () { 1423 var fconnection = $(this).val(); 1424 if (fconnection == departureCity) { 1425 flightConnection.push($(this).text()); 1426 } 1427 }); 1428 var parentId = []; 1429 $(`${this.dialogLocationId} .location-link`).each(function () { 1430 var locationId = $(this).attr('data-code'); 1431 var flag = false; 1432 for (var i = 0; i < flightConnection.length; i++) { 1433 if (locationId == flightConnection[i]) { 1434 flag = true; 1435 break; 1436 } 1437 } 1438 if (flag == false) { 1439 $(this).hide(); 1440 } else { 1441 parentId.push($(this).attr('data-parentid')); 1442 $(this).show(); 1443 } 1444 }); 1445 $(this.wrapWithContainer('.countryTitle')).each(function () { 1446 var flag = false; 1447 var id = $(this).attr('data-parentid'); 1448 for (var i = 0; i < parentId.length; i++) { 1449 if (parentId[i] == id) { 1450 flag = true; 1451 } 1452 } 1453 if (flag == false) { 1454 $(this).hide(); 1455 } 1456 else { 1457 $(this).show(); 1458 } 1459 }); 1460 } 1461 }, 1462 1463 getSearchDialogWidth() { 1464 if ($(this.wrapWithContainer('#FullSearchDialog')) != null && $(this.wrapWithContainer('#FullSearchDialog')).val() == '1') { 1465 if ($(this.wrapWithContainer('#international-search-dialog-width')) != null) { 1466 return $(this.wrapWithContainer('#international-search-dialog-width')).val(); 1467 } 1468 } else { 1469 if ($(this.wrapWithContainer('#search-dialog-width')) != null) 1470 return $(this.wrapWithContainer('#search-dialog-width')).val(); 1471 } 1472 1473 return 0; 1474 }, 1475 1476 getSearchDialogHeight() { 1477 if ($(this.wrapWithContainer('#FullSearchDialog')) != null && $(this.wrapWithContainer('#FullSearchDialog')).val() == '1') { 1478 if ($(this.wrapWithContainer('#international-search-dialog-height')) != null) 1479 return $(this.wrapWithContainer('#international-search-dialog-height')).val(); 1480 } else { 1481 if ($(this.wrapWithContainer('#search-dialog-height')) != null) 1482 return $(this.wrapWithContainer('#search-dialog-height')).val(); 1483 } 1484 1485 return 0; 1486 }, 1487 1488 showLowestPriceInCalendar(isDepartureDate) { 1489 let departureCity = $(this.wrapWithContainer("#DepartureCity")).val(); 1490 let arrivalCity = $(this.wrapWithContainer("#ArrivalCity")).val(); 1491 if (isDepartureDate == false) { 1492 departureCity = $(this.wrapWithContainer("#ArrivalCity")).val(); 1493 arrivalCity = $(this.wrapWithContainer("#DepartureCity")).val(); 1494 } 1495 1496 if (!departureCity || !arrivalCity) return; 1497 1498 var thisDay = new Date(); 1499 var monthOfCalendar = this.currentCalendarMonth || (thisDay.getMonth() + 1); 1500 var yearOfCalendar = this.currentCalendarYear || thisDay.getFullYear(); 1501 1502 var datasend = { 1503 DepartureCity: departureCity, 1504 ArrivalCity: arrivalCity, 1505 Month: monthOfCalendar, 1506 Year: yearOfCalendar 1507 }; 1508 var self = this; 1509 $.ajax({
1510 type: "POST", 1511 url: "/Booking/GetCheapestFlightInMonth", 1512 data: datasend, 1513 success: function (response) { 1514 $('.ui-datepicker-calendar .price-in-calendar').remove(); 1515 1516 if (!response || response.length === 0) return; 1517 1518 let currentCalendarDays = $('.ui-datepicker-day'); 1519 1520 response.forEach(function (item) { 1521 if (!item.Fare || item.Fare <= 0) return; 1522 1523 let dateData = new Date(item.Date); 1524 let dayNum = dateData.getDate(); 1525 let monthNum = dateData.getMonth() + 1; 1526 let yearNum = dateData.getFullYear(); 1527 1528 if (monthNum !== monthOfCalendar || yearNum !== yearOfCalendar) return; 1529 1530 let dayHasLowestPrice = currentCalendarDays.toArray().filter(function (x) { 1531 return parseInt($(x).text()) === dayNum; 1532 }); 1533 1534 if (dayHasLowestPrice.length > 0) { 1535 let priceStr = self.formatCheapestPrice(item.Fare); 1536 if (priceStr) { 1537 let flightPriceHtml = `<span class='price-in-calendar'>${priceStr}</span>`; 1538 $(dayHasLowestPrice[0]).parent().append(flightPriceHtml); 1539 } 1540 } 1541 }); 1542 } 1543 }); 1544 }, 1545 1546 formatCheapestPrice(price) { 1547 if (price >= 1000) { 1548 const inK = (price / 1000).toFixed(0); 1549 const formatted = Number(inK).toLocaleString('en-US'); 1550 return formatted + 'K'; 1551 } 1552 return price.toString(); 1553 }, 1554 1555 renderMonthlyPriceTable: function (data, month, year, departureCity, arrivalCity) { 1556 var self = this; 1557 var firstDay = new Date(year, month - 1, 1); 1558 var lastDay = new Date(year, month, 0); 1559 1560 var totalDays = lastDay.getDate(); 1561 1562 var startDay = firstDay.getDay(); 1563 startDay = (startDay === 0) ? 6 : startDay - 1; 1564 1565 var priceMap = {}; 1566 1567 data.forEach(function (item) { 1568 if (!item || !item.Date) return; 1569 1570 var d = new Date(item.Date); 1571 var day = d.getDate(); 1572 1573 priceMap[day] = { 1574 fare: item.Fare, 1575 airline: item.AirlineId, 1576 date: d 1577 }; 1578 }); 1579 1580 var html = ''; 1581 var day = 1; 1582 1583 for (var i = 0; i < 6; i++) { 1584 html += '<tr>'; 1585 1586 for (var j = 0; j < 7; j++) { 1587 if ((i === 0 && j < startDay) || day > totalDays) { 1588 html += '<td></td>'; 1589 } else { 1590 var item = priceMap[day]; 1591 var priceHtml = ''; 1592 var logoHtml = ''; 1593 var cellClass = ''; 1594 var clickAttr = ''; 1595 1596 if (item && item.fare > 0) { 1597 var formattedPrice = self.formatCheapestPrice(item.fare); 1598 var logoAirline = item.airline.toLowerCase(); 1599 1600 priceHtml = '<div class="day-price">' + formattedPrice + '</div>'; 1601 1602 logoHtml = '<img class="air-logo" src="/Content/images/' + logoAirline + '.png" width="20" alt="">'; 1603 1604 cellClass = 'has-price'; 1605 1606 var dateStr = year + '-' + ('0' + month).slice(-2) + '-' + ('0' + day).slice(-2); 1607 clickAttr = ' data-date="' + dateStr + '" data-departure="' + departureCity + '" data-arrival="' + arrivalCity + '" '; 1608 } 1609 1610 html += '<td class="' + cellClass + '"' + clickAttr + '>'; 1611 html += priceHtml; 1612 html += '<div class="day-meta">'; 1613 html += logoHtml; 1614 html += '<div class="day-number">' + day + '</div>'; 1615 html += '</div>'; 1616 html += '</td>'; 1617 1618 day++; 1619 } 1620 } 1621 html += '</tr>'; 1622 if (day > totalDays) break; 1623 } 1624 $('#price-table-body').html(html); 1625 }, 1626 1627 initMonthlyMonthOptions: function () { 1628 var now = new Date(); 1629 var $month = $('#monthlyMonth'); 1630 if ($month.length == 0) return; 1631 1632 $month.empty(); 1633 1634 for (var i = 0; i < 12; i++) { 1635 var day = new Date(now.getFullYear(), now.getMonth() + i, 1);
1636 var month = ('0' + (day.getMonth() + 1)).slice(-2); 1637 var year = day.getFullYear().toString().slice(-2); 1638 var value = day.getFullYear() + '-' + ('0' + (day.getMonth() + 1)).slice(-2); 1639 $month.append('<option value = "' + value + '">' + month + '/' + year + '</option>'); 1640 } 1641 1642 this.currentMonthlyTableMonth = now.getMonth() + 1; 1643 this.currentMonthlyTableYear = now.getFullYear(); 1644 }, 1645 1646 loadMonthlyPriceTable: function () { 1647 var self = this; 1648 var departureCity = $('#monthlyDepartureCity').val() || $('#DepartureCity').val() || 'SGN'; 1649 var arrivalCity = $('#monthlyArrivalCity').val() || $('#ArrivalCity').val() || 'HAN'; 1650 var monthValue = $('#monthlyMonth').val(); 1651 1652 if (!monthValue) return; 1653 var sameRouteMsg = $('#locale-data').data('same-route'); 1654 if (departureCity === arrivalCity) { 1655 $('#price-table-body').html('<tr><td colspan="7">' + sameRouteMsg + '</td></tr>'); 1656 return; 1657 } 1658 1659 var parts = monthValue.split('-'); 1660 var year = parseInt(parts[0], 10); 1661 var month = parseInt(parts[1], 10); 1662 1663 this.currentMonthlyTableMonth = month; 1664 this.currentMonthlyTableYear = year; 1665 var noDataMsg = $('#locale-data').data('data-available'); 1666 var datasend = { 1667 DepartureCity: departureCity, 1668 ArrivalCity: arrivalCity, 1669 Month: month, 1670 Year: year 1671 }; 1672 1673 $.ajax({
1674 type: "POST", 1675 url: "/Booking/GetCheapestFlightInMonth", 1676 data: datasend, 1677 success: function (response) { 1678 self.renderMonthlyPriceTable(response || [], month, year, departureCity, arrivalCity); 1679 }, 1680 error: function () { 1681 $('#price-table-body').html('<tr><td colspan="7">' + noDataMsg + '</td></tr>'); 1682 } 1683 }); 1684 }, 1685 1686 redirectToSearchFromMonthlyTable: function (departureCity, arrivalCity, dateStr) { 1687 if (!departureCity || !arrivalCity || !dateStr) return; 1688 1689 var parts = dateStr.split('-'); 1690 var departureDate = parts[0] + parts[1] + parts[2]; 1691 1692 var adultNo = '1'; 1693 var childNo = '0'; 1694 var infantNo = '0'; 1695 1696 var paramSearchString = departureCity + "-" + arrivalCity + "-" + departureDate + "-" + adultNo + childNo + infantNo; 1697 var urlSearchString = getLanguageRouting(URLs.searchFlightUrl) + "/" + paramSearchString; 1698 1699 location.href = urlSearchString; 1700 }, 1701 1702 initMonthlyPriceTable: function () { 1703 var self = this; 1704 1705 if ($('#monthly-flight-price-widget').length === 0) return; 1706 1707 self.initMonthlyMonthOptions(); 1708 self.initMonthlyLocationOptions(); 1709 1710 $('#monthlyDepartureCity, #monthlyArrivalCity').each(function () { 1711 $(this).data('previous-value', $(this).val()); 1712 }); 1713 1714 $('#monthlyDepartureCity, #monthlyArrivalCity') 1715 .off('.monthlyRoute') 1716 .on('focus.monthlyRoute mousedown.monthlyRoute', function () { 1717 $(this).data('previous-value', $(this).val()); 1718 }) 1719 .on('change.monthlyRoute', function () { 1720 var $departure = $('#monthlyDepartureCity'); 1721 var $arrival = $('#monthlyArrivalCity'); 1722 var dep = $departure.val(); 1723 var arr = $arrival.val(); 1724 var sameRouteMsg = $('#locale-data').data('same-route'); 1725 var $changedField = $(this); 1726 var previousValue = $changedField.data('previous-value'); 1727 1728 if (!dep || !arr) return; 1729 1730 if (dep === arr) { 1731 alert(sameRouteMsg); 1732 if (previousValue !== undefined) { 1733 $changedField.val(previousValue); 1734 } 1735 return; 1736 } 1737 1738 $changedField.data('previous-value', $changedField.val()); 1739 self.loadMonthlyPriceTable(); 1740 }); 1741 1742 $('#monthlyMonth') 1743 .off('change.monthlyMonth') 1744 .on('change.monthlyMonth', function () { 1745 self.loadMonthlyPriceTable(); 1746 }); 1747 1748 $(document) 1749 .off('click.monthlyPriceCell', '#price-table-body td.has-price') 1750 .on('click.monthlyPriceCell', '#price-table-body td.has-price', function () { 1751 var departure = $(this).data('departure'); 1752 var arrival = $(this).data('arrival'); 1753 var date = $(this).data('date'); 1754 1755 self.redirectToSearchFromMonthlyTable(departure, arrival, date); 1756 }); 1757 }, 1758 1759 initMonthlyLocationOptions: function () { 1760 var self = this; 1761 var $departure = $('#monthlyDepartureCity'); 1762 var $arrival = $('#monthlyArrivalCity'); 1763 1764 if ($departure.length === 0 || $arrival.length === 0) return; 1765 1766 $departure.empty(); 1767 $arrival.empty(); 1768 1769 self.getCountryId(function (countryId) { 1770 if (!countryId) { 1771 var currentDeparture = $('#DepartureCity').val() || 'SGN'; 1772 var currentArrival = $('#ArrivalCity').val() || 'HAN'; 1773 var currentDepartureText = ($('#DepartureCity-Holder').val() || currentDeparture).replace(/\s*\([^)]*\)\s*/g, '').trim(); 1774 var currentArrivalText = ($('#ArrivalCity-Holder').val() || currentArrival).replace(/\s*\([^)]*\)\s*/g, '').trim(); 1775 1776 if (currentDeparture) { 1777 $departure.append('<option value="' + currentDeparture + '">' + currentDepartureText + '</option>'); 1778 $arrival.append('<option value="' + currentDeparture + '">' + currentDepartureText + '</option>'); 1779 } 1780 1781 if (currentArrival && currentArrival !== currentDeparture) { 1782 $departure.append('<option value="' + currentArrival + '">' + currentArrivalText + '</option>'); 1783 $arrival.append('<option value="' + currentArrival + '">' + currentArrivalText + '</option>'); 1784 } 1785 1786 $departure.val(currentDeparture); 1787 $arrival.val(currentArrival); 1788 self.loadMonthlyPriceTable(); 1789 return; 1790 } 1791 1792 self.getLocationsByCountry(countryId, function (locations) { 1793 var map = {}; 1794 var normalizedLocations = []; 1795
1796 (locations || []).forEach(function (item) { 1797 var code = (item.Value || item.value || item.Code || item.code || item.Id || '').toString().trim(); 1798 var text = (item.Text || item.text || item.Name || item.name || item.Label || '').toString().trim(); 1799 1800 if (!code || !text) return; 1801 1802 if (text.indexOf('(') > -1) { 1803 text = text.substring(0, text.lastIndexOf('(')).trim(); 1804 } 1805 1806 if (!map[code]) { 1807 map[code] = true; 1808 normalizedLocations.push({ 1809 code: code, 1810 text: text 1811 }); 1812 } 1813 }); 1814 var noLocationMsg = $('#locale-data').data('location-list-available'); 1815 if (normalizedLocations.length === 0) { 1816 $('#price-table-body').html('<tr><td colspan="7">' + noLocationMsg + '</td></tr>'); 1817 return; 1818 } 1819 1820 normalizedLocations.sort(function (a, b) { 1821 return a.text.localeCompare(b.text, 'vi'); 1822 }); 1823 1824 normalizedLocations.forEach(function (item) { 1825 $departure.append('<option value="' + item.code + '">' + item.text + '</option>'); 1826 $arrival.append('<option value="' + item.code + '">' + item.text + '</option>'); 1827 }); 1828 1829 var selectedDeparture = $('#DepartureCity').val() || 'SGN'; 1830 var selectedArrival = $('#ArrivalCity').val() || 'HAN'; 1831 1832 $departure.val(selectedDeparture); 1833 $arrival.val(selectedArrival); 1834 1835 if ($departure.val() === $arrival.val()) { 1836 $arrival.find('option').each(function () { 1837 if ($(this).val() !== $departure.val()) { 1838 $arrival.val($(this).val()); 1839 return false; 1840 } 1841 }); 1842 } 1843 1844 self.loadMonthlyPriceTable(); 1845 }); 1846 }); 1847 }, 1848 1849 getCountryId: function (callback) { 1850 var self = this; 1851 1852 if (self.vietnamCountryId) { 1853 callback(self.vietnamCountryId); 1854 return; 1855 } 1856 1857 $.ajax({
1858 url: '/PopulateCategory/GetCountries', 1859 type: 'GET', 1860 dataType: 'json', 1861 success: function (countries) { 1862 var vietnamId = null; 1863 1864 (countries || []).forEach(function (item) { 1865 var value = (item.Value || item.value || item.Id || item.id || '').toString().trim(); 1866 var text = (item.Text || item.text || item.Name || item.name || '').toString().trim().toLowerCase(); 1867 if (text === 'viá»t nam' || text === 'viet nam' || text === 'vietnam') { 1868 vietnamId = value; 1869 } 1870 }); 1871 1872 self.vietnamCountryId = vietnamId; 1873 callback(vietnamId); 1874 }, 1875 error: function () { 1876 callback(null); 1877 } 1878 }); 1879 }, 1880 1881 getLocationsByCountry: function (countryId, callback) { 1882 if (!countryId || countryId === 'select') { 1883 callback([]); 1884 return; 1885 } 1886 1887 $.ajax({
1888 url: '/PopulateCategory/GetLocationByCountry', 1889 type: 'GET', 1890 dataType: 'json', 1891 data: { countryId: countryId }, 1892 success: function (locations) { 1893 callback(locations || []); 1894 }, 1895 error: function () { 1896 callback([]); 1897 } 1898 }); 1899 }, 1900 1901 initRecentBookingsPanel: function () { 1902 // Load recent bookings 1903 const localeData = (key) => $('#locale-data').data(key); 1904 $.ajax({ 1905 url: '/Booking/GetRecentBookings', 1906 type: 'GET', 1907 success: function (data) { 1908 var container = $('.list-new-booking'); 1909 if (data && data.length > 0) { 1910 container.empty(); 1911 container.css({ 'max-height': '520px', 'overflow': 'hidden' }); 1912 1913 data.forEach(function (item) { 1914 if (!item.Flights || item.Flights.length === 0) return; 1915 1916 var departureFlight = item.Flights[0]; 1917 var returnFlight = item.Flights.length > 1 ? item.Flights[1] : null; 1918 var isRoundTrip = returnFlight != null; 1919 var adult = item.AdultNo || 1; 1920 var child = item.ChildNo || 0; 1921 var infant = item.InfantNo || 0; 1922 1923 var depDateObj = new Date(parseInt(departureFlight.Date.substr(6))); 1924 var depDay = ("0" + depDateObj.getDate()).slice(-2); 1925 var depMonth = ("0" + (depDateObj.getMonth() + 1)).slice(-2); 1926 var depYear = depDateObj.getFullYear(); 1927 var depDateStr = depDay + '/' + depMonth; 1928 var depDateQueryStr = depYear + depMonth + depDay; 1929 1930 var retDateHtml = ''; 1931 var retDateQueryStr = ''; 1932 if (isRoundTrip) { 1933 var retDateObj = new Date(parseInt(returnFlight.Date.substr(6))); 1934 var retDay = ("0" + retDateObj.getDate()).slice(-2); 1935 var retMonth = ("0" + (retDateObj.getMonth() + 1)).slice(-2); 1936 var retYear = retDateObj.getFullYear(); 1937 var retDateStr = retDay + '/' + retMonth; 1938 retDateQueryStr = '-' + retYear + retMonth + retDay; 1939 1940 retDateHtml = ` 1941 <div class="return"> 1942 <span class="space">•</span> ${localeData('return')} 1943 <img class="logo-airlines" 1944 src="/Content/images/${(returnFlight.AirlineCode ? returnFlight.AirlineCode.toLowerCase() : 'vj')}.jpg" 1945 onerror="this.src='/Themes/NamThanh/Content/images/image-default.jpg'" 1946 alt="" /> 1947 <span class="value">${retDateStr}</span> 1948 </div>`; 1949 } 1950 1951 var searchParam = item.DepartureCity + '-' + item.ReturnCity + '-' + depDateQueryStr + retDateQueryStr + '-' + adult + child + infant; 1952 var detailUrl = '/tim-ve-may-bay/' + searchParam; 1953 1954 var sumFareStr = item.SumFare ? item.SumFare.toLocaleString('en-US') + 'Ä' : $('#locale-data').data('processing'); 1955 var totalPax = adult + child + infant; 1956 var airlineImg = '<img class="logo-airlines" src="/Content/images/' + (departureFlight.AirlineCode ? departureFlight.AirlineCode.toLowerCase() : 'vj') + '.jpg" onerror="this.src=\'/Themes/NamThanh/Content/images/image-default.jpg\'" alt="" />'; 1957 1958 var html = ` 1959 <div class="new-booking-item"> 1960 <img class="icon-loading" src="/Themes/NamThanh/Content/images/ico_loading.gif" /> 1961 <div class="info-top"> 1962 <div class="text">${localeData('new-booking')} ${totalPax} ${localeData('ticket')}</div> 1963 <div class="trip">${localeData('from')} <span class="value">${item.DepartureCityName || item.DepartureCity}</span> <b class="icon">➞</b> <span class="value">${item.ReturnCityName || item.ReturnCity}</span></div> 1964 </div> 1965 <div class="info-bottom"> 1966 <div class="date"> 1967 <div class="departure">${localeData('departure')} ${airlineImg} <span class="value">${depDateStr}</span></div> 1968 ${retDateHtml} 1969 </div> 1970 <div class="price">${localeData('ticket-price')}: <span class="value">${sumFareStr}</span> <a href="${detailUrl}">${localeData('detail')} »</a></div> 1971 </div> 1972 </div> 1973 `; 1974 container.append(html); 1975 }); 1976 1977 // Continuous scrolling effect 1978 if (data.length > 8) { 1979 setInterval(function () { 1980 var $firstChild = container.children().first(); 1981 var height = $firstChild.outerHeight(true); 1982 $firstChild.animate({ marginTop: -height }, 500, function () { 1983 $firstChild.css('marginTop', '').appendTo(container); 1984 }); 1985 }, 3000); 1986 } 1987 } else { 1988 container.html(`<div class="text-center" style="padding: 15px;">${$('#locale-data').data('data-available')}</div>`); 1989 } 1990 }, 1991 error: function () { 1992 $('.list-new-booking').html(`<div class="text-center" style="padding: 15px;">${$('#locale-data').data('data-available')}</div>`); 1993 } 1994 }); 1995 } 1996 } 1997} 1998 1999Define("share.flight_search_dialog", flightSearchDialog()) 2000Define("share.flight_search_dialog_secondary", flightSearchDialog());
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.