1$(document) 2 .ready( 3 function() { 4 var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", 5 "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; 6 7 var captchaConfig = "0"; 8 $("#submitPnrNo").attr("disabled", false); 9 var trainNo; 10 11 var isError = "false"; 12 var ChartButtonMsg = $('#ChartButtonMsg').val(); 13 var SubmitButton = $('#SubmitButton').val(); 14 var ClearButton = $('#ClearButton').val(); 15 var CaptchaInputLabel = $('#CaptchaInputLabel').val(); 16 var CaptchaQuestionLabel = $('#CaptchaQuestionLabel').val(); 17 var GetSchedule = $('#GetSchedule').val(); 18 var PnrResultHeading = $('#PnrResultHeading').val(); 19 var BlankCaptchaError = $('#BlankCaptchaError').val(); 20 var BlankPNRError = $('#BlankPNRError').val(); 21 var PNRLengthError = $('#PNRLengthError').val(); 22 var ErrorLabel = $('#ErrorLabel').val(); 23 var PleaseWait = $('#PleaseWait').val(); 24 var language = $('#language').val(); 25 var TrainRoute = $('#TrainRoute').val(); 26 var TrainNumber = $('#TrainNumber').val(); 27 var TrainName = $('#TrainName').val(); 28 var RunsFromSource = $('#RunsFromSource').val(); 29 var RunsOn = $('#RunsOn').val(); 30 var MON = $('#MON').val(); 31 var TUE = $('#TUE').val(); 32 var WED = $('#WED').val(); 33 var THU = $('#THU').val(); 34 var FRI = $('#FRI').val(); 35 var SAT = $('#SAT').val(); 36 var SUN = $('#SUN').val(); 37 var SNo = $('#SNo').val(); 38 var StationCode = $('#StationCode').val(); 39 var StationName = $('#StationName').val(); 40 var RouteNo = $('#RouteNo').val(); 41 var ArrivalTime = $('#ArrivalTime').val(); 42 var DepartureTime = $('#DepartureTime').val(); 43 var HaltTime = $('#HaltTime').val(); 44 var Distance = $('#Distance').val(); 45 var StationStatus = $('#StationStatus').val(); 46 var Day = $('#Day').val(); 47 var Source = $('#Source').val(); 48 49 loadunloadData(); 50 51 function loadunloadData() { 52 $ 53 .ajax({ 54 url : "../CaptchaConfig", 55 async : false, 56 success : function(response) { 57 captchaConfig = response; 58 if (captchaConfig != '0') { 59 document 60 .getElementById('firstCaptcha').innerHTML = ' <div class="modal fade" id="myModal" role="dialog">' 61 + ' <div class="modal-dialog">' 62 + ' <div class="modal-content">' 63 + ' <div class="modal-header">' 64 + ' <button type="button" class="close" data-dismiss="modal">×</button>' 65 + ' </div>' 66 + ' <div class="modal-body">' 67 + ' <div class="row form-group">' 68 + ' <div class="col-md-12">' 69 + ' <div class="alert alert-danger hidden container col-md-12"' 70 + ' id="errorResultmodal">' 71 + ' <p id="errorMessagemodal"></p>' 72 + ' </div>' 73 + ' </div>' 74 + ' </div>' 75 + ' <div class="row form-group">' 76 + ' <div class="col-md-12">' 77 + ' <div class="col-md-6 text-center label_text" id="CaptchaLabel"' 78 + ' align="center">' 79 + ' <label>' 80 + CaptchaQuestionLabel 81 + '</label>' 82 + ' </div>' 83 + ' <div class="col-md-6" style="margin-left:auto !important;margin-right:auto !important;" align="center">' 84 + ' <img id="CaptchaImgID" class="captcha_style"' 85 + ' src="" /> <img id="refreshCaptcha"' 86 + ' src="../images/refresh.jpg" width="30" height="30"' 87 + ' title="Refresh Captcha" />' 88 + ' </div>' 89 + ' </div>' 90 + ' </div>' 91 + ' <div class="row form-group">' 92 + ' <div class="col-md-12">' 93 + ' <div class="col-md-6 text-left" align="center"></div>' 94 + ' <div class="col-md-6" style="margin-left:auto !important;margin-right:auto !important;" align="center">' 95 + ' <input class="form-control_custom input_text_custom"' 96 + ' type="text" id="inputCaptcha" value=""' 97 + ' placeholder="' 98 + CaptchaInputLabel 99 + '">' 100 + ' </div>' 101 + ' </div>' 102 + ' </div>' 103 + ' <div class="row form-group">' 104 + ' <div class="col-md-12" align="center" style="margin-left:auto !important;margin-right:auto !important;">' 105 + ' <input id="flagLabel" type="hidden"/>' 106 + ' </div>' 107 + ' </div>' 108 + ' <div class="row form-group">' 109 + ' <div class="col-md-12" align="center" style="margin-left:auto !important;margin-right:auto !important;">' 110 + ' <input type="button" style="margin-top: 10px; cursor: auto"' 111 + ' class="btn btn-primary btn-md" value="' 112 + SubmitButton 113 + '" id="submitPnrNo"></input>' 114 + ' </div>' 115 + ' </div>' 116 + ' </div>' 117 + ' </div>' 118 + ' </div>' 119 + ' </div>'; 120 121 document 122 .getElementById('firstCondition').innerHTML = '<input type="button" style="margin-top: 10px; cursor: auto"' 123 + ' class="btn btn-primary btn-md" value="' 124 + SubmitButton 125 + '" id="modal1" ></input> ' 126 + ' <input type="reset" style="margin-top: 10px; cursor: auto" class="btn btn-primary btn-md"' 127 + ' id="clearPnrNo" value="' 128 + ClearButton 129 + '"></input>'; 130 document 131 .getElementById('secondCondition').innerHTML = '<input type="button" class="btn btn-primary btn-md"' 132 + ' id="getTrainSchedule1" value="' 133 + GetSchedule 134 + '"></input>'; 135 136 } else { 137 document 138 .getElementById('firstCondition').innerHTML = '<input type="button" style="margin-top: 10px; cursor: auto"' 139 + ' class="btn btn-primary btn-md" value="' 140 + SubmitButton 141 + '" id="submitPnrNo"></input> ' 142 + ' <input type="reset" style="margin-top: 10px; cursor: auto" class="btn btn-primary btn-md"' 143 + ' id="clearPnrNo" value="' 144 + ClearButton 145 + '"></input>'; 146 document 147 .getElementById('secondCondition').innerHTML = '<input type="button" class="btn btn-primary btn-md"' 148 + ' id="getTrainSchedule" value="' 149 + GetSchedule 150 + '"></input>'; 151 } 152 }, 153 error : function(xhr, status) { 154 console 155 .log("CaptchaConfig Error in Pnr for Internal Use." 156 + JSON.stringify(xhr) 157 + status) 158 159 } 160 }); 161 } 162 163 // captchaConfig = $("#captchaConfig").val(); 164 165 function checkValidation() { 166 167 if ($('#inputPnrNo').val() == null 168 || $('#inputPnrNo').val() == '') { 169 isError = "true"; 170 errorMessage = BlankPNRError; 171 } 172 173 else if ($('#inputPnrNo').val() != null 174 && $('#inputPnrNo').val() != '' 175 && $('#inputPnrNo').val().length < 10) { 176 isError = "true"; 177 errorMessage = PNRLengthError; 178 } else if (captchaConfig != '0') { 179 if ($('#inputCaptcha').val() == null 180 || $('#inputCaptcha').val() == '') { 181 isError = "true"; 182 errorMessage = BlankCaptchaError; 183 } 184 } 185 186 } 187 188 $("#secondCondition") 189 .on( 190 'click', 191 '#getTrainSchedule', 192 function() { 193 $("#getTrainSchedule").val(PleaseWait); 194 $("#getTrainSchedule").attr("disabled", 195 false); 196 if (captchaConfig == '0') { 197 nextCaptchaResult(); 198 $("#getTrainSchedule").val( 199 GetSchedule); 200 $("#getTrainSchedule").attr( 201 "disabled", false); 202 } else { 203 if ($('#inputCaptcha').val() == '') 204 205 { 206 $("#errorResult2").removeClass( 207 'hidden'); 208 $("#errorMessage2") 209 .text( 210 ErrorLabel 211 + BlankCaptchaError); 212 // $('#CaptchaImgID').attr('src','captchaDraw.png?'+ 213 // new Date().getTime()); 214 } 215 216 else { 217 nextCaptchaResult(); 218 } 219 $("#getTrainSchedule").val( 220 GetSchedule); 221 $("#getTrainSchedule").attr( 222 "disabled", false); 223 } 224 225 }); 226 227 $("#predictionDiv") 228 .on( 229 'click', 230 '#PNRPredictionBtn', 231 function() { 232 document 233 .getElementById('PNRPredictionModalHeader').innerHTML = ""; 234 document 235 .getElementById('PNRPredictionModalBody').innerHTML = ""; 236 getConfirmationPrediction(); 237 }); 238 239 $("#firstCondition").on('click', '#clearPnrNo', function() { 240 // $("#clearPnrNo").bind("click",function() { 241 document.getElementById("inputPnrNo").value = ''; 242 if (captchaConfig != '0') { 243 document.getElementById("inputCaptcha").value = ''; 244 } 245 246 }); 247 248 function nextCaptchaResult() { 249 var url = "TrainSchedulePopup.html?trainNo=" + trainNo; 250 $ 251 .ajax({ 252 url : '../CommonCaptcha', 253 data : { 254 inputCaptcha : $('#inputCaptcha').val(), 255 inputPage : 'PNR_SCHEDULE_CALL', 256 trainNo : trainNo, 257 language : language 258 259 }, 260 success : function(response) { 261 var resp = jQuery.parseJSON(JSON 262 .stringify(response)); 263 if (resp.errorMessage == null 264 || resp.errorMessage == '') { 265 if (resp.flag == 'NO') { 266 $("#errorResultmodal") 267 .removeClass('hidden'); 268 $("#errorMessagemodal") 269 .text( 270 "ERROR! Please enter Correct Captcha"); 271 272 // $("#errorResult2").removeClass('hidden'); 273 if (captchaConfig != '0') { 274 document 275 .getElementById("inputCaptcha").value = ''; 276 } // $("#errorMessage2").text("ERROR! 277 // Please 278 // enter 279 // Correct 280 // Captcha"); 281 // $('#CaptchaImgID').attr('src', 282 // 'captchaDraw.png?' 283 // + 284 // new 285 // Date().getTime()); 286 } else { // $('#CaptchaImgID').attr('src', 287 // 'captchaDraw.png?' 288 // + 289 // new 290 // Date().getTime());
291 $('#myModal').modal('hide'); 292 document 293 .getElementById("curDate").innerHTML = resp.generatedTimeStamp.day 294 + "-" 295 + monthNames[resp.generatedTimeStamp.month - 1] 296 + "-" 297 + resp.generatedTimeStamp.year 298 + " [" 299 + resp.generatedTimeStamp.hour 300 + ":" 301 + resp.generatedTimeStamp.minute 302 + ":" 303 + resp.generatedTimeStamp.second 304 + " IST]"; 305 306 loadunloadData(); 307 $("#errorResult2").addClass( 308 'hidden'); 309 $("#errorMessage2").text(""); 310 if (captchaConfig != '0') { 311 document 312 .getElementById("inputCaptcha").value = ''; 313 } 314 315 var dispTable = "<div class='col-md-12'>" 316 + "" 317 + "<h3 class='text-center bg-primary'>" 318 + "" 319 + TrainRoute 320 + "</h3>" 321 + "" 322 + "<div class='row'>" 323 + "<div class='col-md-12 table-responsive'>" 324 + "<table border='1' class='table table-bordered' style='border-collapse:collapse;font-size:14px;'>" 325 + "<thead>" 326 + "<tr>" 327 + "<th rowspan='2' style='font-weight: bold;'>" 328 + TrainNumber 329 + "</th>" 330 + "<th rowspan='2' style='font-weight: bold;'>" 331 + TrainName 332 + "</th>" 333 + "<th rowspan='2' style='font-weight: bold;'>" 334 + RunsFromSource 335 + "</th>" 336 + "<th colspan='7' style='text-align: center;font-weight: bold;'>" 337 + RunsOn 338 + "</th>" 339 + "</tr>" 340 + "<tr>" 341 + "<th>" 342 + MON 343 + "</th>" 344 + "<th>" 345 + TUE 346 + "</th>" 347 + "<th>" 348 + WED 349 + "</th>" 350 + "<th>" 351 + THU 352 + "</th>" 353 + "<th>" 354 + FRI 355 + "</th>" 356 + "<th>" 357 + SAT 358 + "</th>" 359 + "<th>" 360 + SUN 361 + "</th>" 362 + "</tr>" 363 + "</thead>" 364 + "<tr>" 365 + "<td>" 366 + resp.trainNumber 367 + "</td>" 368 + "<td>" 369 + resp.trainName 370 + "</td>" 371 + "<td>" 372 + resp.stationFrom 373 + "</td>" 374 + "<td>" 375 + resp.trainRunsOnMon 376 + "</td>" 377 + "<td>" 378 + resp.trainRunsOnTue 379 + "</td>" 380 + "<td>" 381 + resp.trainRunsOnWed 382 + "</td>" 383 + "<td>" 384 + resp.trainRunsOnThu 385 + "</td>" 386 + "<td>" 387 + resp.trainRunsOnFri 388 + "</td>" 389 + "<td>" 390 + resp.trainRunsOnSat 391 + "</td>" 392 + "<td>" 393 + resp.trainRunsOnSun 394 + "</td></tr>" 395 + "</table></div></div>" 396 + "<div class='row'>" 397 + "<div class='col-md-12 table-responsive'>" 398 + "<table border='1' class='table table-bordered' style='border-collapse:collapse;font-size:14px;'>"; 399 dispTable = dispTable 400 + "<thead>" 401 + "<tr>" 402 + "<th style='font-weight: bold;'>" 403 + SNo 404 + "</th>" 405 + "<th style='font-weight: bold;'>" 406 + StationCode 407 + "</th>" 408 + "<th style='font-weight: bold;'>" 409 + StationName 410 + "</th>" 411 + "<th style='font-weight: bold;'>" 412 + RouteNo 413 + "</th>" 414 + "<th style='font-weight: bold;'>" 415 + ArrivalTime 416 + "</th>" 417 + "<th style='font-weight: bold;'>" 418 + DepartureTime 419 + "</th>" 420 + "<th style='font-weight: bold;'>" 421 + HaltTime 422 + "</th>" 423 + "<th style='font-weight: bold;'>" 424 + Distance 425 + "</th>" 426 + "<th style='font-weight: bold;'>" 427 + Day + "</th>" 428 + "</tr></thead>"; 429 for (let i = 0; i < resp.stationList.length; i++) { 430 const rowData = resp.stationList[i]; 431 432 // Determine status text 433 let statusText = "Active"; 434 if (rowData.stationStatus === "D") statusText = "Deleted"; 435 else if (rowData.stationStatus === "R") statusText = "Diverted"; 436 else if (rowData.stationStatus === "P") statusText = "Via Station"; 437 438 // Add -- before and after status text 439 statusText = "-- " + statusText + " --"; 440 441 // Determine row color based on status 442 let rowColor = ""; 443 if (rowData.stationStatus === "D") rowColor = "style='color:red;'"; 444 else if (rowData.stationStatus === "R") rowColor = "style='color:orange;'"; 445 else if (rowData.stationStatus === "P") rowColor = "style='color:#999966;'"; 446 447 // Prepare merged or normal timing columns 448 let timingColumns = ""; 449 if (["D", "R", "P"].includes(rowData.stationStatus)) { 450 // Merge timing columns into a single cell 451 timingColumns = `<td colspan='3' style='text-align:center; font-weight:bold;'>${statusText}</td>`;
452 } else { 453 // Normal timing columns 454 if (rowData.stnSerialNumber == "1") { 455 timingColumns = 456 `<td>${Source}</td>` + 457 `<td>${rowData.departureTime}</td>` + 458 `<td>${rowData.haltTime}</td>`; 459 } else { 460 timingColumns = 461 `<td>${rowData.arrivalTime}</td>` + 462 `<td>${rowData.departureTime}</td>` + 463 `<td>${rowData.haltTime}</td>`; 464 } 465 } 466 467 // Build row 468 dispTable += 469 `<tr ${rowColor}> 470 <td>${i + 1}</td> 471 <td>${rowData.stationCode}</td> 472 <td>${rowData.stationName}</td> 473 <td>${rowData.routeNumber}</td> 474 ${timingColumns} 475 <td>${rowData.distance}</td> 476 <td>${rowData.dayCount}</td> 477 </tr>`; 478 } 479 dispTable = dispTable 480 + "</table></div></div></div>"; 481 $("#myModal2 .modal-body") 482 .html(dispTable); 483 $("#myModal2").modal("show"); 484 // DispWin 485 // = 486 // window.open('','TrainSchedule', 487 // 'toolbar=no,status=no,width=500,height=500') 488 // DispWin.document.write(dispTable); 489 } 490 491 } else { 492 493 var errorTemp = resp.errorMessage 494 .split("-", 2); 495 if (resp.errorMessage == 'Captcha not matched') { 496 $("#errorResultmodal") 497 .removeClass('hidden'); 498 $("#errorMessagemodal") 499 .text( 500 ErrorLabel 501 + resp.errorMessage); 502 $('#CaptchaImgID') 503 .attr( 504 'src', 505 '../captchaDraw.png?' 506 + new Date() 507 .getTime()); 508 509 } else { 510 511 $('#myModal').modal('hide'); 512 document 513 .getElementById("curDate").innerHTML = resp.generatedTimeStamp.day 514 + "-" 515 + monthNames[resp.generatedTimeStamp.month - 1] 516 + "-" 517 + resp.generatedTimeStamp.year 518 + " [" 519 + resp.generatedTimeStamp.hour 520 + ":" 521 + resp.generatedTimeStamp.minute 522 + ":" 523 + resp.generatedTimeStamp.second 524 + " IST]"; 525 526 loadunloadData(); 527 528 $("#errorResult2").removeClass( 529 'hidden'); 530 $("#errorMessage2") 531 .text( 532 ErrorLabel 533 + resp.errorMessage); 534 535 } 536 // $("#errorResult2").removeClass('hidden'); 537 // $("#errorMessage2").text("ERROR! 538 // "+ 539 // errorTemp[0]); 540 541 if (captchaConfig != '0') { 542 document 543 .getElementById("inputCaptcha").value = ''; 544 } 545 } 546 547 }, 548 error : function(xhr, status) { 549 $('#myModal').modal('hide'); 550 551 $("#errorResult2") 552 .removeClass('hidden'); 553 $("#errorMessage2") 554 .text( 555 "Train Schedule from PNR Error for Internal Use."); 556 if (captchaConfig != '0') { 557 document 558 .getElementById("inputCaptcha").value = ''; 559 } 560 561 } 562 }); 563 } 564 565 $('#pnrOutputDiv').hide(); 566 $("#firstCaptcha").on( 567 'click', 568 '#refreshCaptcha', 569 function() { 570 571 $('#CaptchaImgID').attr( 572 'src', 573 '../captchaDraw.png?' 574 + new Date().getTime()); 575 }); 576 577 function mainsubmitfunction() { 578 $("#errorResultmodal").addClass('hidden'); 579 $("#errorMessagemodal").text(''); 580 581 $("#submitPnrNo").attr("disabled", true); 582 $("#submitPnrNo").val(PleaseWait); 583 $("#errorResult1").addClass('hidden'); 584 isError = "false"; 585 checkValidation(); 586 if (isError == "false") { 587 $ 588 .ajax({ 589 url : '../CommonCaptcha', 590 data : { 591 inputCaptcha : $('#inputCaptcha') 592 .val(), 593 inputPnrNo : $('#inputPnrNo').val(), 594 inputPage : 'PNR', 595 language : language 596 // captchaFlag 597 // : 598 // captchaConfig 599 }, 600 success : function(response) { 601 602 $("#submitPnrNo").val(SubmitButton); 603 $("#submitPnrNo").attr("disabled", 604 false); 605 ; 606 var resp = jQuery.parseJSON(JSON 607 .stringify(response)); 608 609 if (resp.flag == 'NO') { 610 $("#errorResult1").removeClass( 611 'hidden'); 612 $("#errorMessage") 613 .text( 614 "Error! Please enter correct captcha."); 615 } else { 616 if (resp.errorMessage == null 617 || resp.errorMessage == '') {
618 $('#myModal').modal('hide'); 619 loadunloadData(); 620 $("#sample_bottom_div") 621 .hide(); 622 document 623 .getElementById("curDate").innerHTML = resp.generatedTimeStamp.day 624 + "-" 625 + monthNames[resp.generatedTimeStamp.month - 1] 626 + "-" 627 + resp.generatedTimeStamp.year 628 + " [" 629 + resp.generatedTimeStamp.hour 630 + ":" 631 + resp.generatedTimeStamp.minute 632 + ":" 633 + resp.generatedTimeStamp.second 634 + " IST]"; 635 636 showPnr(resp); 637 } else { 638 639 if (resp.errorMessage == 'Captcha not matched') { 640 $("#errorResultmodal") 641 .removeClass( 642 'hidden'); 643 $("#errorMessagemodal") 644 .text( 645 "Error! " 646 + resp.errorMessage); 647 $('#CaptchaImgID') 648 .attr( 649 'src', 650 '../captchaDraw.png?' 651 + new Date() 652 .getTime()); 653 654 } else { 655 656 $('#myModal').modal( 657 'hide'); 658 document 659 .getElementById("curDate").innerHTML = resp.generatedTimeStamp.day 660 + "-" 661 + monthNames[resp.generatedTimeStamp.month - 1] 662 + "-" 663 + resp.generatedTimeStamp.year 664 + " [" 665 + resp.generatedTimeStamp.hour 666 + ":" 667 + resp.generatedTimeStamp.minute 668 + ":" 669 + resp.generatedTimeStamp.second 670 + " IST]"; 671 672 loadunloadData(); 673 $("#errorResult1") 674 .removeClass( 675 'hidden'); 676 $("#errorMessage") 677 .text( 678 ErrorLabel 679 + resp.errorMessage); 680 681 } 682 683 var errorTemp = resp.errorMessage 684 .split("-", 2); 685 // $('#inputCaptcha_refill').attr('src', 686 // 'captchaDraw.png?' 687 // + 688 // new 689 // Date().getTime()); 690 // $("#errorResult1").removeClass('hidden'); 691 // $("#errorMessage").text("ERROR! 692 // "+ 693 // errorTemp[0]); 694 695 } 696 } 697 }, 698 error : function(xhr, status) { 699 $('#CaptchaImgID').attr( 700 'src', 701 '../captchaDraw.png?' 702 + new Date() 703 .getTime()); 704 $("#submitPnrNo").val(SubmitButton); 705 $("#submitPnrNo").attr("disabled", 706 false); 707 $("#errorResult1").removeClass( 708 'hidden'); 709 $("#errorMessage") 710 .text( 711 "Error! Internal Error. Please try after sometime."); 712 } 713 }); 714 715 } else { 716 $("#submitPnrNo").val(SubmitButton); 717 $("#submitPnrNo").attr("disabled", false); 718 $("#errorResultmodal").removeClass('hidden'); 719 $("#errorMessagemodal").text( 720 ErrorLabel + errorMessage); 721 722 if (captchaConfig == '0') { 723 $("#errorResult1").removeClass('hidden'); 724 $("#errorMessage").text( 725 ErrorLabel + errorMessage); 726 } 727 728 // $("#errorResult1").removeClass('hidden'); 729 // $("#errorMessage").text("Error! " + 730 // errorMessage); 731 // $('#CaptchaImgID').attr('src', 'captchaDraw.png?' 732 // + new Date().getTime()); 733 734 } 735 } 736 737 $("#firstCondition").on('click', '#submitPnrNo', 738 function() { 739 740 mainsubmitfunction(); 741 742 }); 743 $("#firstCaptcha") 744 .on( 745 'click', 746 '#submitPnrNo', 747 function() { 748 if (document 749 .getElementById("flagLabel").value == 'PNR') { 750 751 mainsubmitfunction(); 752 } 753 if (document 754 .getElementById("flagLabel").value == 'TRAIN') { 755 756 if (captchaConfig == '0') { 757 nextCaptchaResult(); 758 } else { 759 if ($('#inputCaptcha').val() == '') 760 761 { 762 $("#errorResultmodal") 763 .removeClass( 764 'hidden'); 765 $("#errorMessagemodal") 766 .text( 767 ErrorLabel 768 + BlankCaptchaError); 769 // $("#errorResult2").removeClass('hidden'); 770 // $("#errorMessage2").text("ERROR! 771 // Please enter Captcha to 772 // Proceed."); 773 // $('#CaptchaImgID').attr('src','captchaDraw.png?'+ 774 // new Date().getTime()); 775 } 776 777 else { 778 nextCaptchaResult(); 779 } 780 } 781 } 782 }); 783 784 $("#firstCondition") 785 .on( 786 'click', 787 '#modal1', 788 function() { 789 $("#modal1").val(PleaseWait); 790 $("#modal1").attr("disabled", true); 791 document.getElementById("inputCaptcha").value = ''; 792 793 $("#errorResult1").addClass('hidden'); 794 $("#errorMessage").text(''); 795 if ($('#inputPnrNo').val() == null 796 || $('#inputPnrNo').val() == '') { 797 isError = "true"; 798 errorMessage = BlankPNRError; 799 } 800 801 else if ($('#inputPnrNo').val() != null 802 && $('#inputPnrNo').val() != '' 803 && $('#inputPnrNo').val().length < 10) { 804 isError = "true"; 805 errorMessage = PNRLengthError; 806 } 807 808 else { 809 isError = "false"; 810 errorMessage = "" 811 } 812 813 if (isError == "false") { 814 $('#CaptchaImgID').attr( 815 'src', 816 '../captchaDraw.png?' 817 + new Date() 818 .getTime());
819 $('#myModal').modal('show'); 820 document 821 .getElementById("flagLabel").value = 'PNR'; 822 823 $("#errorResultmodal").addClass( 824 'hidden'); 825 $("#errorMessagemodal").text(''); 826 if (captchaConfig != '0') { 827 document 828 .getElementById("inputCaptcha").value = ''; 829 } 830 831 $("#modal1").val(SubmitButton); 832 $("#modal1") 833 .attr("disabled", false); 834 } else { 835 $("#errorResult1").removeClass( 836 'hidden'); 837 $("#errorMessage").text( 838 ErrorLabel + errorMessage); 839 840 } 841 842 $("#modal1").val(SubmitButton); 843 $("#modal1").attr("disabled", false); 844 }); 845 846 $("#secondCondition") 847 .on( 848 'click', 849 '#getTrainSchedule1', 850 function() { 851 $("#getTrainSchedule1").val(PleaseWait); 852 $("#getTrainSchedule1").attr( 853 "disabled", true); 854 855 $("#errorResultmodal").addClass( 856 'hidden'); 857 $("#errorMessagemodal").text(''); 858 document.getElementById("flagLabel").value = 'TRAIN'; 859 860 if (captchaConfig != '0') { 861 $('#CaptchaImgID').attr( 862 'src', 863 '../captchaDraw.png?' 864 + new Date() 865 .getTime()); 866 document 867 .getElementById("inputCaptcha").value = ''; 868 } 869 $('#myModal').modal('show'); 870 $("#getTrainSchedule1") 871 .val(GetSchedule); 872 $("#getTrainSchedule1").attr( 873 "disabled", false); 874 875 }); 876 877 function showPnr(resp) { 878 879 $('#inputPnrNoDiv').hide(); 880 $('#pnrOutputDiv').show(); 881 if (resp.isWL == 'Y') { 882 $('#predictionDiv').show(); 883 } else { 884 $('#predictionDiv').hide(); 885 } 886 $("#result").removeClass('hidden'); 887 $('#inputCaptcha').attr('src', 888 '../captchaDraw.png?' + new Date().getTime()); 889 $('trainNo').val(resp.trainNumber); 890 891 if (resp.chartStatus == "Chart Prepared") { 892 var coach = ""; 893 var berth = ""; 894 for (var i = 0; i < resp.passengerList.length; i++) { 895 if (resp.journeyClass == '1A') { 896 if (resp.passengerList[i].currentCoachId != undefined 897 && resp.passengerList[i].currentCoachId != null 898 && resp.passengerList[i].currentCoachId != '') { 899 coach = coach 900 + resp.passengerList[i].currentStatus 901 + ":" + resp.journeyClass; 902 berth = berth 903 + resp.passengerList[i].currentStatus 904 + ":" 905 + resp.journeyClass 906 + ":" 907 + resp.passengerList[i].currentBerthNo; 908 // berth.push(cc +':'+ 909 // resp.passengerList[i].currentBerthNo); 910 // coachSet.add(cc); 911 } 912 if (i < resp.passengerList.length - 1) { 913 coach = coach + ","; 914 berth = berth + ","; 915 } 916 } else if (!(resp.passengerList[i].currentCoachId == null || resp.passengerList[i].currentCoachId == "") 917 && (resp.passengerList[i].currentStatus == "CNF" || resp.passengerList[i].currentStatus == "RAC") 918 && resp.passengerList[i].currentBerthNo != 0) { 919 coach = coach 920 + resp.passengerList[i].currentCoachId 921 + ":" + resp.journeyClass; 922 berth = berth 923 + resp.passengerList[i].currentCoachId 924 + ":" 925 + resp.journeyClass 926 + ":" 927 + resp.passengerList[i].currentBerthNo; 928 if (i < resp.passengerList.length - 1) { 929 coach = coach + ","; 930 berth = berth + ","; 931 } 932 } 933 } 934 var jd = new Date(resp.dateOfJourney); 935 var cd = new Date(); 936 jd.setHours(0, 0, 0, 0); 937 cd.setHours(-24, 0, 0, 0); 938 // cd.setDate( cd.getDate() - 1 ); 939 if (coach != "" && berth != "" 940 && jd.getTime() >= cd.getTime()) { 941 var chartData = $("<input type='button' class='btn btn-primary btn-md' id='chartBtn' onclick=\"window.open('https://www.irctc.co.in/online-charts/?trainNumber=" 942 + resp.trainNumber 943 + "&journeyDate=" 944 + jd.getFullYear() 945 + "-" 946 + Number(jd.getMonth() + 1) 947 + "-" 948 + jd.getDate() 949 + "&boardingStation=" 950 + resp.sourceStation 951 + "&coachName="
952 + coach 953 + "&berthNumber=" 954 + berth 955 + "', '_blank');\" value='" 956 + ChartButtonMsg + "'>") 957 $("#chartDiv").append(chartData); 958 $('#chartDiv').show(); 959 } else { 960 $("#chartDiv").append(""); 961 $('#chartDiv').hide(); 962 } 963 } else { 964 $("#chartDiv").append(""); 965 $('#chartDiv').hide(); 966 } 967 968 document.getElementById("h4").innerHTML = PnrResultHeading 969 + " " + resp.pnrNumber; 970 var row1 = $("<tr/>") 971 $("#journeyDetailsTable").append(row1); 972 trainNo = resp.trainNumber; 973 var d = new Date(resp.dateOfJourney); 974 row1.append($("<td>" + resp.trainNumber + "</td>")); 975 row1.append($("<td>" + resp.trainName + "</td>")); 976 row1.append($("<td>" + d.getDate() + "-" 977 + Number(d.getMonth() + 1) + "-" 978 + d.getFullYear() + "</td>")) 979 row1.append($("<td>" + resp.sourceStation + "</td>")); 980 row1.append($("<td>" + resp.destinationStation 981 + "</td>")); 982 row1.append($("<td>" + resp.reservationUpto + "</td>")); 983 row1.append($("<td>" + resp.boardingPoint + "</td>")); 984 row1.append($("<td>" + resp.journeyClass + "</td>")); 985 986 var trainStatus = ""; 987 988 if (resp.trainCancelStatus != undefined) { 989 trainStatus = resp.trainCancelStatus; 990 } 991 var informationMessage = ""; 992 if (resp.informationMessage[0] != "" 993 && resp.informationMessage[1] != "") { 994 informationMessage = resp.informationMessage[0] 995 + " , " + resp.informationMessage[1]; 996 } 997 if (resp.informationMessage[0] != "" 998 && resp.informationMessage[1] == "") { 999 informationMessage = resp.informationMessage[0]; 1000 } 1001 var row2 = $("<tr />") 1002 $("#otherDetailsTable").append(row2); 1003 row2.append($("<td>" + resp.bookingFare + "</td>")); 1004 row2.append($("<td>" + resp.chartStatus + "</td>")); 1005 row2.append($("<td>" + informationMessage + "</td>")); 1006 row2.append($("<td>" + trainStatus + "</td>")); 1007 drawTable(resp.passengerList, resp.chartStatus) 1008 console.log(resp) 1009 } 1010 function drawTable(data, chartStatus) { 1011 for (var i = 0; i < data.length; i++) { 1012 drawRow(data[i], chartStatus); 1013 } 1014 1015 } 1016 function drawRow(rowData, chartStatus) { 1017 var finalStatusCurrent = rowData.currentStatus; 1018 var finalStatusBooking = rowData.bookingStatus; 1019 var row = $("<tr />") 1020 var count = 1; 1021 var coachPosition = ""; 1022 if (!(rowData.currentCoachId == null || rowData.currentCoachId == "")) { 1023 finalStatusCurrent = finalStatusCurrent + "/" 1024 + rowData.currentCoachId; 1025 } 1026 if ((rowData.currentStatus != "CNF" && rowData.currentStatus != "CAN") 1027 || (rowData.currentStatus == "CNF" && rowData.currentBerthNo != 0)) { 1028 finalStatusCurrent = finalStatusCurrent + "/" 1029 + rowData.currentBerthNo; 1030 } 1031 1032 if (!(rowData.bookingCoachId == null || rowData.bookingCoachId == "")) { 1033 finalStatusBooking = finalStatusBooking + "/" 1034 + rowData.bookingCoachId; 1035 } 1036 if ((rowData.bookingStatus != "CNF" && rowData.bookingStatus != "CAN") 1037 || (rowData.bookingStatus == "CNF" && rowData.bookingBerthNo != 0)) { 1038 finalStatusBooking = finalStatusBooking + "/" 1039 + rowData.bookingBerthNo; 1040 } 1041 if (rowData.bookingBerthCode != null 1042 && rowData.bookingBerthCode != "-1") { 1043 finalStatusBooking = finalStatusBooking + "/" 1044 + rowData.bookingBerthCode; 1045 } 1046 1047 if (chartStatus != null 1048 && chartStatus == "Chart Prepared") { 1049 if (rowData.passengerCoachPosition != null 1050 && rowData.passengerCoachPosition != "0") 1051 1052 { 1053 coachPosition = rowData.passengerCoachPosition; 1054 1055 } 1056 } 1057 $("#psgnDetailsTable").append(row); 1058 row.append($("<td>" + "Passenger " 1059 + rowData.passengerSerialNumber + "</td>")); 1060 row.append($("<td>" + finalStatusBooking + "/" 1061 + rowData.passengerQuota + "</td>")) 1062 row.append($("<td>" + finalStatusCurrent + "</td>")); 1063 //row.append($("<td>" + coachPosition + "</td>")); 1064 } 1065 1066 function getConfirmationPrediction() { 1067 var rtnStr = "" 1068 $ 1069 .ajax({ 1070 url : '../CommonCaptcha', 1071 data : { 1072 inputCaptcha : $('#inputCaptcha').val(), 1073 inputPage : 'PNRPrediction', 1074 language : language 1075 // captchaFlag : captchaConfig 1076 }, 1077 success : function(response) { 1078 var resp = jQuery.parseJSON(JSON 1079 .stringify(response)); 1080 if (resp.errorMessage == null 1081 || resp.errorMessage == '') { 1082 rtnStr = resp.probability; 1083 predictionBody = "<b><span style=\"padding: 28px; color:#165C0B;font-size:large\">Probability of Confirmation CNF: " 1084 + (rtnStr * 100) 1085 .toPrecision(4) 1086 + "</span></b>"; 1087 predictionBody = predictionBody 1088 + "<br><p><b><span style=\"padding: 28px;align-content: center\">Last Year Confirmation Trends for Same Period</span></b></p>"; 1089 predictionBody = predictionBody 1090 + "<div style=\"font-weight: bold; padding: 0px 0px 10px 5px;\">"; 1091 predictionBody = predictionBody 1092 + "<div>"; 1093 predictionBody = predictionBody 1094 + " <div class=\"row\" style=\"background-color: #337AB7;
1094 color: white; text-align: center; padding: 5px;\">"; 1095 predictionBody = predictionBody 1096 + " <div class=\"col-md-3 col-xs-6\">Journey Date</div>"; 1097 predictionBody = predictionBody 1098 + " <div class=\"col-md-3 col-xs-6\">Wait list Confirm on Booking Status</div>"; 1099 predictionBody = predictionBody 1100 + " <div class=\"col-md-3 hidden-xs hidden-sm\">Journey Date</div>"; 1101 predictionBody = predictionBody 1102 + " <div class=\"col-md-3 hidden-xs hidden-sm\">Wait list Confirm on Booking Status</div>"; 1103 predictionBody = predictionBody 1104 + " </div>"; 1105 for (var i = 0; i < resp.maxWlRacCnfList.length; i++) { 1106 predictionBody = predictionBody 1107 + " <div class=\"row text-center\">"; 1108 predictionBody = predictionBody 1109 + " <div class=\"col-md-12\">"; 1110 // predictionBody = 1111 // predictionBody + " <ul>"; 1112 // predictionBody = 1113 // predictionBody + " <li 1114 // class=\"probablity_alt 1115 // row\">"; 1116 predictionBody = predictionBody 1117 + " <div class=\"col-md-3 col-xs-6\"><span class=\"pull-left left_text\">" 1118 + parseDate(resp.maxWlRacCnfList[i].jdate) 1119 + "</span></div>"; 1120 predictionBody = predictionBody 1121 + " <div class=\"col-md-3 col-xs-6\"><span class=\"pull-right right_text\">" 1122 + resp.maxWlRacCnfList[i].lastYearRunningStatus 1123 + "/" 1124 + resp.maxWlRacCnfList[i].lastYearRunningNumber 1125 + "</span></div>"; 1126 i = i + 1; 1127 if (i < resp.maxWlRacCnfList.length) { 1128 predictionBody = predictionBody 1129 + " <div class=\"col-md-3 hidden-xs hidden-sm\"><span class=\"pull-left left_text\">" 1130 + parseDate(resp.maxWlRacCnfList[i].jdate) 1131 + "</span></div>"; 1132 predictionBody = predictionBody 1133 + " <div class=\"col-md-3 hidden-xs hidden-sm\"><span class=\"pull-right right_text\">" 1134 + resp.maxWlRacCnfList[i].lastYearRunningStatus 1135 + "/" 1136 + resp.maxWlRacCnfList[i].lastYearRunningNumber 1137 + "</span></div>"; 1138 } 1139 // predictionBody = 1140 // predictionBody + " </li>"; 1141 // predictionBody = 1142 // predictionBody + " </ul>"; 1143 predictionBody = predictionBody 1144 + " </div>"; 1145 predictionBody = predictionBody 1146 + " </div>"; 1147 } 1148 predictionBody = predictionBody 1149 + "</div>"; 1150 predictionBody = predictionBody 1151 + "</div>"; 1152 header = "<div class=\"ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top\">"; 1153 header = header 1154 + "<span class=\"ui-dialog-title ng-tns-c3-8\">"; 1155 header = header + resp.header 1156 + "</span></div>" 1157 document 1158 .getElementById('PNRPredictionModalHeader').innerHTML = header; 1159 document 1160 .getElementById('PNRPredictionModalBody').innerHTML = predictionBody; 1161 document 1162 .getElementById('PNRPredictionDsplDiv').innerHTML = "<b><span style=\"padding: 28px; color:#165C0B;font-size:large\">Probability of Confirmation CNF: " 1163 + (rtnStr * 100) 1164 .toPrecision(4) 1165 + "</span></b>" 1166 } else { 1167 if (resp.errorMessage == 'Captcha not matched') { 1168 rtnStr = "session out! Please Try again."; 1169 document 1170 .getElementById('PNRPredictionModalBody').innerHTML = rtnStr; 1171 } else { 1172 rtnStr = "session out! Please Try again."; 1173 document 1174 .getElementById('PNRPredictionModalBody').innerHTML = rtnStr; 1175 } 1176 } 1177 }, 1178 error : function(xhr, status) { 1179 rtnStr = "Some Error Occured! Please Try again."; 1180 document 1181 .getElementById('PNRPredictionModalBody').innerHTML = rtnStr; 1182 } 1183 }); 1184 // document.getElementById('PNRPredictionModalBody').innerHTML 1185 // = "Probability of Confirmation CNF: " + rtnStr; 1186 } 1187 function parseDate(varDate) { 1188 var d = new Date(varDate); 1189 var dd = d.getDate(); 1190 var mm = Number(d.getMonth() + 1) 1191 if (dd.toString().length == 1) { 1192 dd = "" + 0 + dd; 1193 } 1194 if (mm.toString().length == 1) { 1195 mm = "" + 0 + mm; 1196 } 1197 var newDate = dd + "-" + mm + "-" + d.getFullYear() 1198 return newDate; 1199 } 1200 1201 });
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.