1function resetValidateApplicantForm() { 2 var $form = getCurrentForm(); 3 $form.find('#sevisId').val(''); 4 $form.find('#firstName').val(''); 5 $form.find('#lastName').val(''); 6 $form.find('#dateOfBirth').val(''); 7 $form.find('#dobMM').val(''); 8 $form.find('#dobDD').val(''); 9 $form.find('#dobYYYY').val(''); 10 I901_STATES = null; 11 I901_COUNTRIES = null; 12 I901_EV_CATEGORIES = null; 13 I901_VISA_TYPES = null; 14 I901_IS_BLOCKED_CC = false; 15 I901_APPLICANT = null; 16 I901_SEVIS_APPLICANT = null; 17} 18 19function resetApplicantForm(applicant) { 20 21 var $form = getCurrentForm(); 22 if (isDefined(applicant)) { 23 $form.find('#visaType').val(applicant.visaType).trigger("change"); 24 $form.find('#emailAddress').val(applicant.emailAddress); 25 $form.find('#citizenshipCountry').val(applicant.citizenshipCountry).trigger("change"); 26 $form.find('#birthCountry').val(applicant.birthCountry).trigger("change"); 27 $form.find('#schoolCode').val(applicant.schoolCode1); 28 $form.find('#schoolCode2').val(applicant.schoolCode2); 29 $form.find('#schoolCode3').val(applicant.schoolCode3); 30 $form.find('#programCode').val(applicant.programCode1); 31 $form.find('#programCode2').val(applicant.programCode2); 32 $form.find('#programCode3').val(applicant.programCode3); 33 $form.find('#evCategory').val(applicant.evCategory).trigger("change"); 34 $form.find('#address1').val(applicant.address1); 35 $form.find('#address2').val(applicant.address2); 36 $form.find('#city').val(applicant.city); 37 $form.find('#postalCode').val(applicant.postalCode); 38 $form.find('#country').val(applicant.country).trigger("change"); 39 $form.find('.stateArea').show().trigger("refresh"); 40 $form.find('#state').val(applicant.state).trigger("change"); 41 $form.find('#fmjAgreement').prop('checked', applicant.fmjAgreement); 42 } else { 43 $form.find('#visaType').val(''); 44 $form.find('#emailAddress').val(''); 45 $form.find('#citizenshipCountry').val('').trigger("change"); 46 $form.find('#birthCountry').val('').trigger("change"); 47 $form.find('#schoolCode').val(''); 48 $form.find('#schoolCode2').val(''); 49 $form.find('#schoolCode3').val(''); 50 $form.find('#programCode').val(''); 51 $form.find('#programCode2').val(''); 52 $form.find('#programCode3').val(''); 53 $form.find('#evCategory').val('').trigger("change"); 54 $form.find('#address1').val(''); 55 $form.find('#address2').val(''); 56 $form.find('#city').val(''); 57 $form.find('#postalCode').val(''); 58 $form.find('#country').val('').trigger("change"); 59 $form.find('.stateArea').show().trigger("refresh"); 60 $form.find('#state').val('').trigger("change"); 61 $form.find('#fmjAgreement').prop('checked', false); 62 } 63} 64 65function toggleVisaType(visaType) { 66 debugLog("Switching visaType to " + visaType + " Form"); 67 if (visaType.startsWith("J-1")) { 68 $('.toggleFormArea').show(); 69 $('.formJGroup').show(); 70 $('.formFMGroup').hide(); 71 $('#schoolCode').val(''); 72 $('#schoolCode2').val(''); 73 $('#schoolCode3').val(''); 74 doFocusForwardFormI901(); 75 } else if (visaType.startsWith("F-1")) { 76 $('.toggleFormArea').show(); 77 $('.formJGroup').hide(); 78 $('.formFMGroup').show(); 79 $('#programCode').val(''); 80 $('#programCode2').val(''); 81 $('#programCode3').val(''); 82 $('#evCategory').val('').trigger("change"); 83 doFocusForwardFormI901(); 84 } else { 85 $('.toggleFormArea').hide(); 86 $('.formJGroup').hide(); 87 $('.formFMGroup').hide(); 88 } 89} 90 91function getFullNameFromForm() { 92 var $form = getCurrentForm(); 93 var firstName = $form.find('#firstName').val(); 94 var lastName = $form.find('#lastName').val(); 95 var nameSpace = ""; 96 if(isDefined(firstName) && firstName.length > 0) { 97 nameSpace = "%20"; 98 } else { 99 firstName = ""; 100 } 101 102 return firstName + nameSpace + lastName; 103 104} 105 106function getMakePaymentExistsPopupMessage() { 107 var $form = getCurrentForm(); 108 109 var makePaymentExistsPopupMessage = getCMSPlainTextValue('makePaymentExistsPopupMessage'); 110 111 if (!isDefined(makePaymentExistsPopupMessage) || makePaymentExistsPopupMessage.length <= 0) { 112 makePaymentExistsPopupMessage += 'ERROR: Unable to find user-defined content for makePaymentExistsPopupMessage<br /><br />'; 113 } else { 114 115 var mailto = 'mailto:[email protected]?subject=Payment%20Verification&body=Name:%20' + getFieldValue(encodeURIComponent( getFullNameFromForm() )) + 116 '%0D%0ASEVIS%20ID:%20' + getFieldValue($form.find('#sevisId').val()) + '%0D%0A%0D%0A'; 117 118 makePaymentExistsPopupMessage = makePaymentExistsPopupMessage.replace("#popupMailto#", mailto); 119 } 120 121 return makePaymentExistsPopupMessage; 122} 123 124function createModalDialogHTML() { 125 var modalDialogHTML = ''; 126 127 modalDialogHTML += '<div class="modal fade" id="continuePaymentModal" tabindex="-1" role="dialog" data-bs-backdrop="static" aria-labelledby="continuePaymentModalLabel">'; 128 modalDialogHTML += ' <div class="modal-dialog" role="document">'; 129 modalDialogHTML += ' <div class="modal-content">'; 130 modalDialogHTML += ' <div class="modal-header">'; 131 modalDialogHTML += ' <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>'; 132 modalDialogHTML += ' </div>'; 133 modalDialogHTML += ' <div class="modal-body" id="continuePaymentModalLabel">'; 134 modalDialogHTML += ' <p id="popupMessageText"></p>'; 135 modalDialogHTML += ' </div>'; 136 modalDialogHTML += ' <div class="modal-footer">'; 137 modalDialogHTML += ' <button type="button" class="commonBtn btn btn-secondary fee-modal-action-button" data-bs-dismiss="modal">Cancel</button>'; 138 modalDialogHTML += ' <button type="button" class="commonBtn btn btn-primary fee-modal-action-button" id="confirmContinuePaymentButtonAction" name="confirmContinuePaymentButtonAction" data-bs-dismiss="modal">Make Payment</button>'; 139 modalDialogHTML += ' </div>'; 140 modalDialogHTML += ' </div><!-- /.modal-content -->'; 141 modalDialogHTML += ' </div><!-- /.modal-dialog -->'; 142 modalDialogHTML += '</div><!-- /.modal -->'; 143 144 return modalDialogHTML; 145 146} 147 148function addButtonHTML(data, errorKey, showMakePaymentMsg, showCheckStatus
148Msg, showMakePaymentBtn, showCheckStatusBtn) { 149 var html = ''; 150 151 var makePaymentExistsMessage = getCMSValue('makePaymentExistsMessage'); 152 if (showMakePaymentMsg) { 153 if (isDefined(makePaymentExistsMessage) && makePaymentExistsMessage.length > 0) { 154 html += makePaymentExistsMessage; 155 } else { 156 html += 'ERROR: Unable to find user-defined content for makePaymentExistsMessage<br /><br />'; 157 } 158 } 159 160 if (showCheckStatusMsg) { 161 html += 'We can only accept Check, Money Order or Western Union for your I-901 Fee.<br/><br/>'; 162 } 163 164 165 addError(errorKey, html); 166 167 var buttonHtml = '<div class="form-group">'; 168 var errorId = "#" + errorKey + "Error"; 169 buttonHtml += '<div class="row">'; 170 171 if (showCheckStatusBtn) { 172 buttonHtml += '<div class="col-xs-12 col-sm-6">'; 173 buttonHtml += '<div class="text-field">'; 174 buttonHtml += '<button type="button" class="commonBtn errorButton continuePaymentCheckStatusButtonAction" id="continuPaymentCheckStatusButton">Check Payment Status</button>'; 175 buttonHtml += '</div>'; 176 buttonHtml += '</div>'; 177 } 178 179 if(showMakePaymentMsg) { 180 buttonHtml += '<div class="col-xs-12 col-sm-6">'; 181 buttonHtml += '<div class="text-field">'; 182 buttonHtml += '<button type="button" class="commonBtn errorButton continuePaymentButtonAction" id="continuePaymentButton" data-bs-toggle="modal" data-bs-target="#continuePaymentModal">Continue Making Payment</button>'; 183 buttonHtml += '</div>'; 184 buttonHtml += '</div>'; 185 186 } else if(showCheckStatusMsg) { 187 buttonHtml += '<div class="col-xs-12 col-sm-6">'; 188 buttonHtml += '<div class="text-field">'; 189 buttonHtml += '<button type="button" class="commonBtn errorButton continuePaymentButtonAction" id="continuePaymentButton">Continue Making Payment</button>'; 190 buttonHtml += '</div>'; 191 buttonHtml += '</div>'; 192 193 } 194 195 if (showMakePaymentMsg) { 196 buttonHtml += createModalDialogHTML(); 197 198 } 199 200 buttonHtml += '</div>'; 201 buttonHtml += '</div>'; 202 $(errorId).append(buttonHtml); 203 204 // To avoid self-XSS, now populating the popup message text after the HTML is added to the DOM 205 if(showMakePaymentMsg) { 206 $('#popupMessageText').text(getMakePaymentExistsPopupMessage()); 207 } 208 209 if(showMakePaymentMsg) { 210 var $continuePaymentModal = $('#continuePaymentModal'); 211 $continuePaymentModal.off('hide.bs.modal.i901Continue hidden.bs.modal.i901Continue'); 212 $continuePaymentModal.on('hide.bs.modal.i901Continue', function() { 213 if (document.activeElement && this.contains(document.activeElement) && document.activeElement.blur) { 214 document.activeElement.blur(); 215 } 216 }); 217 $('#confirmContinuePaymentButtonAction').focus(); 218 handleOn($('#confirmContinuePaymentButtonAction'), 'click', function(event) { 219 $continuePaymentModal.off('hidden.bs.modal.i901ContinueAction').one('hidden.bs.modal.i901ContinueAction', function(e) { 220 showApplicantForm(true); 221 focusFieldControl('visaType'); 222 }); 223 }); 224 } else if(showCheckStatusMsg) { 225 $('.continuePaymentButtonAction').focus(); 226 handleOn($('.continuePaymentButtonAction'), 'click', function(event) { 227 showApplicantForm(true); 228 }); 229 230 } 231 232 if (showCheckStatusBtn) { 233 $('.continuePaymentCheckStatusButton').focus(); 234 handleOn($('.continuePaymentCheckStatusButtonAction'), 'click', handleContinuePaymentCheckStatusButtonAction); 235 } 236 237} 238 239// setup forms 240function setupFMJForm(data, previewPaymentExists) { 241 if(previewPaymentExists) { 242 addButtonHTML(data, 'duplicatePayment', true, false, true, true); 243 } else if (data) { 244 debugLog("Data:"); 245 debugLog(data); 246 I901_STATES = data.states; 247 I901_COUNTRIES = data.countries; 248 I901_EV_CATEGORIES = data.evCategories; 249 I901_VISA_TYPES = data.visaTypes; 250 I901_IS_BLOCKED_CC = data.isBlockedCC; 251 I901_SEVIS_APPLICANT = data.sevisApplicant; 252 253 if (data.isBlockedCC && data.isHasDuplicatePayments) { 254 addButtonHTML(data, 'duplicatePaymentAndNoCCPaymentAllowed', true, true, true, true); 255 } else if (data.isHasDuplicatePayments) { 256 addButtonHTML(data, 'duplicatePayment', true, false, true, true); 257 } else if (data.isBlockedCC) { 258 addButtonHTML(data, 'noCCPaymentAllowed', false, true, true, false); 259 } else { 260 showApplicantForm(); 261 } 262 } 263} 264 265function doFocusForwardFormI901(event) { 266 switch (I901_CURRENT_FOCUS) { 267 case "visaType": 268 focusOnItem("firstName", event, false); 269 break; 270 case "emailAddress": 271 focusOnItem("citizenshipCountry", event, true); 272 break; 273 case "citizenshipCountry": 274 focusOnItem("birthCountry", event, true); 275 break; 276 case "birthCountry": 277 focusOnItem("address1", event, false); 278 break; 279 case "city":
280 var $form = getCurrentForm(); 281 if ($form.find('.stateArea:visible').length > 0) { 282 focusOnItem("state", event, true); 283 } else { 284 focusOnItem("country", event, true); 285 } 286 break; 287 case "state": 288 focusOnItem("country", event, true); 289 break; 290 case "country": 291 focusOnItem("postalCode", event, false); 292 break; 293 case "programCode3": 294 focusOnItem("evCategory", event, true); 295 break; 296 case "evCategory": 297 focusOnItem("fmjAgreement", event, false); 298 break; 299 case "schoolCode3": 300 focusOnItem("fmjAgreement", event, false); 301 break; 302 } 303} 304 305function doFocusBackwardFormI901(event) { 306 switch (I901_CURRENT_FOCUS) { 307 case "firstName": 308 focusOnItem("visaType", event, true); 309 break; 310 case "citizenshipCountry": 311 focusOnItem("emailAddress", event, false); 312 break; 313 case "birthCountry": 314 focusOnItem("citizenshipCountry", event, true); 315 break; 316 case "address1": 317 focusOnItem("birthCountry", event, true); 318 break; 319 case "country": 320 var $form = getCurrentForm(); 321 if ($form.find('.stateArea:visible').length > 0) { 322 focusOnItem("state", event, true); 323 } else { 324 focusOnItem("city", event, false); 325 } 326 break; 327 case "state": 328 focusOnItem("city", event, false); 329 break; 330 case "postalCode": 331 focusOnItem("country", event, true); 332 break; 333 case "evCategory": 334 focusOnItem("programCode3", event, false); 335 break; 336 case "fmjAgreement": 337 var $form = getCurrentForm(); 338 if ($form.find('.formJGroup:visible').length > 0) { 339 focusOnItem("evCategory", event, true); 340 } else { 341 focusOnItem("schoolCode3", event, false); 342 } 343 break; 344 } 345} 346 347function showApplicantForm() { 348 showSplitContent("pay/applicantForm", "applicantFormSidebar"); 349 var $form = getCurrentForm(); 350 351 populateArea($form, I901_SEVIS_APPLICANT); 352 populateSelects($form.find(".visaTypes"), I901_VISA_TYPES, false, "Form Type"); 353 populateSelects($form.find(".countries"), I901_COUNTRIES, true, "Country"); 354 populateSelects($form.find(".states"), I901_STATES, false, "State"); 355 populateSelects($form.find(".evCategories"), I901_EV_CATEGORIES, false, "Category"); 356 357 // for resizing and focus 358 setupSelect2("visaType", doFocusForwardFormI901, doFocusBackwardFormI901); 359 360 resetApplicantForm(I901_APPLICANT); 361 362 var setCountry = function(countryName) { 363 setCountryVal($form.find('#country'), countryName); 364 setCountryVal($form.find('#birthCountry'), countryName); 365 setCountryVal($form.find('#citizenshipCountry'), countryName); 366 }; 367 var setCountryVal = function($tag, countryName) { 368 var countryVal = $tag.val(); 369 if (!isDefined(countryVal) || countryVal.length == 0) { 370 $tag.val(countryName).trigger("change"); 371 } 372 }; 373 374 toggleVisaType($form.find('#visaType').val()); 375 toggleState($form.find('#country').val()); 376 377 // visaType changed 378 handleSelectChange($form.find('#visaType'), function(event) { 379 toggleVisaType($(this).val()); 380 }); 381 382 // country changed 383 handleSelectChange($form.find('#country'), function(event) { 384 toggleState($(this).val()); 385 }); 386 387 // FMJ form submitted 388 handleOn($form, 'submit', function(event) { 389 event.preventDefault(); 390 submitDataform($form, true, handleFMJFormSubmitResponse); 391 }); 392} 393 394function toggleConfirmState($form, countryName) { 395 switch (countryName) { 396 case "UNITED STATES": 397 case "US": 398 case "USA": 399 case "": 400 $form.find('.stateArea').show(); 401 break; 402 default: 403 $form.find('.stateArea').hide(); 404 break; 405 } 406} 407 408function setupFMJFormConfirm(applicant) { 409 showSplitContent("pay/applicantFormConfirm", "applicantFormConfirmSidebar"); 410 411 if (isDefined(applicant)) { 412 I901_APPLICANT = applicant; 413 } else { 414 applicant = I901_APPLICANT; 415 } 416 417 var $applicantFormConfirmTable = $('#applicantFormConfirmTable'); 418 419 populateArea($applicantFormConfirmTable, applicant); 420 421 toggleVisaType(applicant.visaType); 422 toggleConfirmState($applicantFormConfirmTable, applicant.country); 423 424 if (!isDefined(applicant.address2) || applicant.address2.length == 0) { 425 $applicantFormConfirmTable.find('.address2Group').hide(); 426 } 427 if (!isDefined(applicant.firstName) || applicant.firstName.length == 0) { 428 $applicantFormConfirmTable.find('.firstNameGroup').hide(); 429 } 430 if (!isDefined(applicant.postalCode) || applicant.postalCode.length == 0) { 431 $applicantFormConfirmTable.find('.postalCodeGroup').hide(); 432 } 433 434 $(".reprintCouponForm").hide(); 435 $(".makePaymentForm").show(); 436 $(".sidebar").show(); 437 438 handleOn($('.previousPageButton'), 'click', function(event) { 439 event.preventDefault(); 440 showApplicantForm(); 441 }); 442 443 if (!I901_IS_BLOCKED_CC && isPaygovLive()) {
444 $('#creditCardSelectButton').show(); 445 handleOn($('#creditCardSelectButton'), 'click', function(event) { 446 event.preventDefault(); 447 setupCCForm(applicant); 448 }); 449 } else { 450 $('#creditCardSelectButton').hide(); 451 } 452 453 handleOn($('#checkSelectButton'), 'click', function(event) { 454 var $form = $(event.currentTarget).parent('form'); 455 // set token 456 $form.find("#CSRFToken").val(getCSRFToken()); 457 // set action corrected 458 $form.attr("action", getActionURI($form.attr("action"))); 459 $(".reprintCouponForm").show(); 460 $(".makePaymentForm").hide(); 461 $(".sidebar").hide(); 462 }); 463 464 handleOn($('#reprintCouponButton'), 'click', function(event) { 465 var $form = $(event.currentTarget).parent('form'); 466 // set token 467 $form.find("#CSRFToken").val(getCSRFToken()); 468 // set action corrected 469 $form.attr("action", getActionURI($form.attr("action"))); 470 }); 471 472} 473 474// handlers 475function handleValidateApplicantFormSubmitResponse(i901AJAXResponse) { 476 if (i901AJAXResponse && !i901AJAXResponse.errors) { 477 setupFMJForm(i901AJAXResponse.data); 478 } else { 479 alertLog(i901AJAXResponse); 480 } 481 return false; 482} 483 484function handleFMJFormSubmitResponse(i901AJAXResponse) { 485 if (i901AJAXResponse && !i901AJAXResponse.errors && i901AJAXResponse.data) { 486 setupFMJFormConfirm(i901AJAXResponse.data.applicant); 487 } else { 488 alertLog(i901AJAXResponse); 489 } 490 return false; 491} 492 493function isPreviewPaymentExists() { 494 var queryParams = window.location.queryParams; 495 496 return ((queryParams["previewPaymentExists"] != null) && (queryParams["previewPaymentExists"] == "true")); 497} 498 499function handlePaymentButtonAction(event) { 500 showSplitContent("pay/validateApplicant", "validateApplicantSidebar"); 501 resetValidateApplicantForm(); 502 resetEmailInfo(); 503 setupValidateApplicantForm(); 504 505 if(isPreviewPaymentExists()) { 506 setupFMJForm(null, true); 507 } 508 509 // validateApplicant form submitted 510 var $form = getCurrentForm(); 511 handleOn($form, 'submit', function(event) { 512 event.preventDefault(); 513 putTogetherFormDate("dateOfBirth", [ "dobMM", "dobDD", "dobYYYY" ]); 514 submitDataform($(event.currentTarget), true, handleValidateApplicantFormSubmitResponse); 515 }); 516 return false; 517}
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.