1// updated version of imsi_ajax.js to be compliant with jQuery 3.5 2if (!window.console) console = {log: function() {}}; 3 4var properties = new Map(); 5 6function setIMSIProperties(props){ 7 properties = props; 8} 9 10var retrieveLightWindowAJAX = function(){ 11 var newAJAX = new Ajax.Request( 12 this.contentToFetch, { 13 method: 'get', 14 parameters: '', 15 onComplete: function(response) { 16 $('lightwindow_contents').innerHTML += response.responseText; 17 this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height); 18 this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width); 19 this._processWindow(); 20 }.on(this) 21 } 22 ); 23} 24 25function getElementsStartsWithId( id ) { 26 var children = document.body.getElementsByTagName('*'); 27 var elements = [], child; 28 for (var i = 0, length = children.length; i < length; i++) { 29 child = children[i]; 30 if (child.id.substr(0, id.length) == id) 31 elements.push(child); 32 } 33 return elements; 34} 35 36function isFunction(functionToCheck) { 37 var getType = {}; 38 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; 39} 40 41function partial(func /*, 0..n args */) { 42 var args = Array.prototype.slice.call(arguments).splice(1); 43 return function() { 44 var allArguments = args.concat(Array.prototype.slice.call(arguments)); 45 return func.apply(this, allArguments); 46 }; 47} 48 49function clearDiv(div){ 50 document.getElementById(div).innerHTML=''; 51} 52 53function retrieveURLValidateFormAJAX(url, divID, form, action){ 54 var answer = confirm("Are you sure you want to "+action+"?"); 55 if(answer){ 56 retrieveURLAJAX(url, divID, form); 57 }else{ 58 alert("Action will not be performed."); 59 } 60} 61function retrieveURLValidateAJAX(url, divID, action){ 62 var answer = confirm("Are you sure you want to "+action+"?"); 63 if(answer){ 64 retrieveURLAJAX(url, divID); 65 }else{ 66 alert("Action will not be performed."); 67 } 68} 69var func; 70function retrieveURLPostProcessFormAJAX(url, divID, form, funcIn){ 71 retrieveURLAJAX(url, divID, form); 72 func = funcIn; 73} 74 75function retrieveURLValidatePostProcessFormAJAX(url, divID, action, form, funcIn){ 76var answer = confirm("Are you sure you want to "+action+"?"); 77 if(answer){ 78 retrieveURLAJAX(url, divID, form); 79 func = funcIn; 80 }else{ 81 alert("Action will not be performed"); 82 } 83} 84 85var windowName, windowWidth, windowHeight, postURL, postURLParams; 86function newWindowPostAJAX(url, div, form, postProcessURL, winName, width, height){ 87 retrieveURLAJAX(url, div, form); 88 windowName = winName; 89 windowWidth = width; 90 windowHeight = height; 91 postURL = postProcessURL; 92} 93 94 95function retrieveURLPostProcessAJAX(url, divID, funcIn){ 96 retrieveURLAJAX(url, divID); 97 func = funcIn; 98} 99 100function retrieveURLValidatePostProcessAJAX(url, divID, action, funcIn){ 101var answer = confirm("Are you sure you want to "+action+"?"); 102 if(answer){ 103 retrieveURLPostProcessAJAX(url, divID, funcIn); 104 func = funcIn; 105 }else{ 106 alert("Action will not be performed"); 107 } 108} 109 110function retrieveURLSwitchDivAJAX(url, divID, replaceID, show){ 111 if(show){ 112 document.getElementById('show_'+replaceID).className=''; 113 document.getElementById('hide_'+replaceID).className='hide'; 114 }else{ 115 document.getElementById('show_'+replaceID).className='hide'; 116 document.getElementById('hide_'+replaceID).className=''; 117 } 118 119 retrieveURLAJAX(url, divID); 120} 121 122 123var workingDiv; 124var alternateDiv; 125function retrieveURLAJAX(url, divID){ 126 retrieveURLAJAX(url, divID, null); 127} 128 129function retrieveURLMultiDivAJAX(url, divID, alternateDivID, form){ 130 alternateDiv = alternateDivID; 131 retrieveURLAJAX(url, divID, form); 132} 133 134function retrieveURLMultiDivValidateAJAX(url, divID, alternateDivID, action, form){ 135 var answer = confirm("Are you sure you want to "+action+"?"); 136 if(answer){ 137 retrieveURLMultiDivAJAX(url, divID, alternateDivID, form); 138 }else{ 139 alert("Action will not be performed."); 140 } 141} 142 143function retrieveURLMultiDivPostProcessAJAX(url, divID, alternateDivID, form, funcIn){ 144 alternateDiv = alternateDivID; 145 retrieveURLPostProcessFormAJAX(url, divID, form, funcIn); 146} 147 148function showFlash(titleString, messageString) { 149 $.gritter.add({ 150 // (string | mandatory) the heading of the notification 151 title: titleString, 152 // (string | mandatory) the text inside the notification 153 text: messageString 154 }); 155} 156 157function alertPreventDefault(msg){ 158 showFlash("", msg); 159 //event.preventDefault(); 160} 161 162function startCallback(divID) { 163 workingDiv = divID; 164 // make something useful before submit (onStart) 165 return true; 166} 167 168function startAltCallBack(divID, alternateDivID){ 169 workingDiv = divID; 170 alternateDiv = alternateDivID; 171 return true; 172} 173 174function getCookie(c_name) 175{ 176if (document.cookie.length>0) 177 { 178 c_start=document.cookie.indexOf(c_name + "="); 179 if (c_start!=-1) 180 {
181 c_start=c_start + c_name.length+1; 182 c_end=document.cookie.indexOf(";",c_start); 183 if (c_end==-1) c_end=document.cookie.length; 184 return unescape(document.cookie.substring(c_start,c_end)); 185 } 186 } 187return ""; 188} 189 190function del_cookie(name) { 191 document.cookie = name +'=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; 192} 193 194function completeCallback(response) { 195 // make something useful after (onComplete) 196 //document.getElementById('').innerHTML = parseInt(document.getElementById('nr').innerHTML) + 1; 197 var imsiCookie = getCookie('imsi.response'); 198 if(imsiCookie!=null && imsiCookie=='210' && alternateDiv != null){ 199 document.getElementById(alternateDiv).innerHTML = response; 200 }else{ 201 document.getElementById(workingDiv).innerHTML = response; 202 } 203 del_cookie('imsi.response'); 204} 205 206function cboxCompleteCallback(response) { 207 // make something useful after (onComplete) 208 //document.getElementById('').innerHTML = parseInt(document.getElementById('nr').innerHTML) + 1; 209 var imsiCookie = getCookie('imsi.response'); 210 if(imsiCookie!=null && imsiCookie=='210'){ 211 document.getElementById('cboxLoadedContent').innerHTML = response; 212 $.fn.colorbox.resize(); 213 }else{ 214 $.fn.colorbox.close(); 215 var scripts = parseScript(response); 216 document.getElementById(workingDiv).innerHTML = response; 217 if(scripts!=null){ 218 evalScripts(scripts); 219 } 220 } 221 222 del_cookie('imsi.response'); 223} 224 225 226 227var canSubmit = true; 228function retrieveURLAJAX(url, divID, formObj){ 229 retrieveURLAJAX(url, divID, formObj, null); 230} 231 232function retrieveURLAJAX(url, divID, formObj, displayLoader){ 233 retrieveURLAJAX(url, divID, formObj, displayLoader, null); 234} 235var callback; 236function retrieveURLAJAX(url, divID, formObj, displayLoader, callbackFunction){ 237 retrieveURLAJAX(url, divID, formObj, displayLoader, callbackFunction, null); 238} 239 240function getLoader(){ 241 if(typeof ajaxLoader == 'undefined'){ 242 return 'ajax-loading.gif'; 243 }else{ 244 return ajaxLoader; 245 } 246} 247 248 249function getAJAX(urlIn, divID){ 250 $.ajax({type: "GET",url: urlIn, 251 success:function(response){ 252 $("#"+divID).html(response).foundation(); 253 fixDateInputs(); 254 applyMasking(); 255 addRequiredClass(); 256 addAddressClass(); 257 if (typeof initializeAllAutocompletes === 'function') { 258 initializeAllAutocompletes(); 259 } 260 }, 261 beforeSend: function (data) { 262 $('#offCanvasDiv').animate({scrollTop:0},800); 263 overrideableOnLoad(); 264 $("#"+divID).html('<br/><br/><center><img alt="Loading" src="../images/'+getLoader()+'"/></center>'); 265 }}); 266} 267 268function getAJAXNoAnimate(urlIn, divID){ 269 $.ajax({type: "GET",url: urlIn, 270 success:function(response){ 271 $("#"+divID).html(response).foundation(); 272 fixDateInputs(); 273 applyMasking(); 274 addRequiredClass(); 275 addAddressClass(); 276 if (typeof initializeAllAutocompletes === 'function') { 277 initializeAllAutocompletes(); 278 } 279 }, 280 beforeSend: function (data) { 281 overrideableOnLoad(); 282 }}); 283} 284 285function postAJAX(postURL, divID, formID){ 286 postAJAX(postURL, divID, formID, null); 287} 288 289function postAJAX(postURL, divID, formID, customLoading){ 290 var formData = new FormData($("#"+formID)[0]); 291 formData.append('screenWidth', $(window).width()); 292 /*** FIX FOR SAFARI FILE UPLOAD WIPING OUT ALL PARAMETERS ***/ 293 if(safariOsVersion()>10){ 294 $("#"+formID+" input[type=file]").each(function() { 295 if($(this).val() === "") { 296 formData.delete($(this).attr("name")); 297 } 298 }); 299 } 300 if(customLoading == null){ 301 customLoading = '<br/><br/><center><img alt="Processing" src="../images/'+getLoader()+'"/></center>'; 302 } 303 $.ajax({ 304 url: postURL, 305 type: 'POST', 306 data: formData, 307 beforeSend: function (data) { 308 $('#offCanvasDiv').animate({scrollTop:0},800); 309 overrideableOnLoad(); 310 $("#"+divID).html(customLoading); 311 }, 312 success: function (data) { 313 $("#"+divID).html(data).foundation(); 314 fixDateInputs(); 315 applyMasking(); 316 addRequiredClass(); 317 addAddressClass(); 318 if (typeof initializeAllAutocompletes === 'function') { 319 initializeAllAutocompletes(); 320 } 321 }, 322 contentType: false, 323 processData: false 324 }); 325} 326 327function overrideableOnLoad(){} 328 329function uploadAttach(applicationID, id, applicantID, categoryID){ 330 var myFormData = new FormData(); 331 myFormData.append('applicationID', applicationID); 332 myFormData.append('applicantIndex', applicantID); 333 myFormData.append('categoryID', categoryID); 334 myFormData.append('attachment', $('#'+id).prop('files')[0]); 335 /*** FIX FOR SAFARI FILE UPLOAD WIPING OUT ALL PARAMETERS ***/ 336 if(safariOsVersion()>10){ 337 $("#"+id).each(function() { 338 if($(this).val() === "") { 339 myFormData.delete($(this).attr("name")); 340 } 341 }); 342 } 343 344 var divID = "attach_"+applicantID+"_"+categoryID; 345 $.ajax({ 346 url: '/IMSIWeb/web/formAddAttachment.action', 347 type: 'POST', 348 processData: false, // important 349 contentType: false, // important 350 data: myFormData, 351 beforeSend: function (data) { 352 $("#"+divID).html('<br/><br/><center><img src="../images/'+getLoader()+'"/></center>'); 353 }, 354 success: function (data) { 355 $("#"+divID).html(data).foundation(); 356 } 357 }); 358} 359 360function uploadAttachRestrict(element, applicationID, id, applicantID, categoryID) { 361 var fileName = $(element).val(); 362 var fileFormat = fileName.split('.').pop().toLowerCase(); 363 var restrictedFormats = ['zip', 'xlsx', 'xls', 'doc', 'docx', 'csv', 'html']; 364 if (restrictedFormats.indexOf(fileFormat) !== -1) { 365 $(element).notify('File type not permitted'); 366 return false;
367 } 368 uploadAttach(applicationID, id, applicantID, categoryID); 369 return true; 370} 371 372function uploadWorkboxAttach(url, divID, id, recordID){ 373 uploadWorkboxAttach(url, divID, id, recordID, null); 374} 375 376function uploadWorkboxAttach(url, divID, id, recordID, categoryID){ 377 var myFormData = new FormData(); 378 myFormData.append('recordID', recordID); 379 myFormData.append('attachment', $('#'+id).prop('files')[0]); 380 if(categoryID != null){ 381 myFormData.append('categoryID', categoryID); 382 } 383 384 /*** FIX FOR SAFARI FILE UPLOAD WIPING OUT ALL PARAMETERS ***/ 385 if(safariOsVersion()>10){ 386 $("#"+id).each(function() { 387 if($(this).val() === "") { 388 myFormData.delete($(this).attr("name")); 389 } 390 }); 391 } 392 393 $.ajax({ 394 url: url, 395 type: 'POST', 396 processData: false, // important 397 contentType: false, // important 398 data: myFormData, 399 beforeSend: function (data) { 400 $("#"+divID).html('<br/><br/><center><img src="../images/'+getLoader()+'"/></center>'); 401 }, 402 success: function (data) { 403 $("#"+divID).html(data).foundation(); 404 } 405 }); 406} 407 408function applyMasking(){ 409 jQuery(function($){ 410 $(".hasDatepicker").mask("99/99/9999"); 411 $(".phone").mask("(999) 999-9999"); 412 $(".ssn").mask("999-99-9999"); 413 }); 414 applyCase(); 415 //applyCustomErrorMessages(); 416} 417function addRequiredClass() { 418 try { 419 // Function to add or remove 'req' class to the label associated with the input or select 420 function updateClass(elementId) { 421 const label = $('label[for="' + elementId + '"]'); 422 if ($('#' + elementId).prop('required')) { 423 label.addClass('req'); 424 } else { 425 label.removeClass('req'); 426 } 427 } 428 429 // Create a MutationObserver 430 const observer = new MutationObserver(function (mutations) { 431 mutations.forEach(function (mutation) { 432 if (mutation.attributeName === 'required') { 433 const elementId = mutation.target.id; 434 updateClass(elementId); 435 } 436 }); 437 }); 438 439 // Observe changes in the 'required' attribute of all input and select fields 440 $('input, select').each(function () { 441 observer.observe(this, { attributes: true }); 442 443 // Check if the element already has the 'required' attribute 444 // once we remove all hidden inputs with no name and no id, this wont be needed 445 if (this.id) { 446 updateClass(this.id); 447 } 448 }); 449 } catch (error) { 450 console.error('Error updating required class', error); 451 } 452} 453 454function addAddressClass() { 455 try { 456 // Track address groups with a counter 457 let addressCounter = 0; 458 const addressGroups = {}; 459 460 // Function to determine the address type and add appropriate class 461 function categorizeAddressField(elementId) { 462 const element = $('#' + elementId); 463 let addressType = ''; 464 let groupPrefix = ''; 465 466 // Skip elements without IDs 467 if (!elementId) return; 468 469 // Determine the type of address field 470 if (elementId.includes('address') || elementId.includes('Address')) { 471 addressType = 'address'; 472 } else if (elementId.includes('city') || elementId.includes('City')) { 473 addressType = 'city'; 474 } else if (elementId.includes('state') || elementId.includes('State')) { 475 addressType = 'state'; 476 } else if (elementId.includes('zipcode') || elementId.includes('Zipcode') || elementId.includes('zip') || elementId.includes('Zip')) { 477 addressType = 'zipcode'; 478 } else { 479 // Not an address field 480 return; 481 } 482 483 // Determine the group prefix (what comes before the field type) 484 if (elementId.includes('mail')) { 485 groupPrefix = 'mail'; 486 } else if (elementId.includes('prev')) { 487 groupPrefix = 'prev'; 488 } else { 489 groupPrefix = 'primary'; 490 } 491 492 // Check if we've seen this group before 493 if (!addressGroups[groupPrefix]) { 494 addressCounter++; 495 addressGroups[groupPrefix] = addressCounter; 496 } 497 498 // Add the appropriate class and data attribute 499 element.addClass(addressType); 500 element.attr('data-address-group', addressGroups[groupPrefix]); 501 } 502 503 // Process all input fields 504 $('input, select').each(function() { 505 // adding fix for inputs with empty ids 506 if (this.id) { 507 categorizeAddressField(this.id); 508 } 509 }); 510 511 // Create a MutationObserver to watch for new address fields 512 const observer = new MutationObserver(function(mutations) { 513 mutations.forEach(function(mutation) { 514 if (mutation.type === 'childList') {
515 mutation.addedNodes.forEach(function(node) { 516 if (node.nodeType === 1) { // Element node 517 const inputs = $(node).find('input, select'); 518 inputs.each(function() { 519 if (this.id) { 520 categorizeAddressField(this.id); 521 } 522 }); 523 } 524 }); 525 } 526 }); 527 }); 528 529 // Start observing the document 530 observer.observe(document.body, { childList: true, subtree: true }); 531 532 } catch (error) { 533 console.error('Error updating address classes', error); 534 } 535} 536 537 538function fixDateInputs(){ 539 if(!checkDateInput()){ 540 var date; 541 var str; 542 $(function() { 543 $('input[type="date"],input[imsi-date]').each(function() { 544 date = ''; 545 var maxDateVar = '+15y'; 546 var minDateVar = new Date(1904,1-1,1); 547 548 if($(this).prop('min')!=null){ 549 minDateVar = new Date($(this).prop('min')); 550 } 551 if($(this).prop('max')!=null){ 552 maxDateVar = new Date($(this).prop('max')); 553 } 554 555 $(this).prop('type', 'text'); 556 $(this).datepicker("destroy"); 557 $(this).prop('imsi-date', true); 558 $(this).datepicker({minDate:minDateVar,maxDate:maxDateVar,changeMonth:true,changeYear:true,yearRange:"-100:+15"}); 559 $(this).on('change', function(){ 560 if($(this).prop('max')!=null && $(this).prop('min')!=null && $(this).val().indexOf("/")==2){ 561 minDateVar = new Date($(this).prop('min')); 562 maxDateVar = new Date($(this).prop('max')); 563 var dateIn = new Date($(this).val().substring(6)+'-'+$(this).val().substring(0,2)+'-'+$(this).val().substring(3,5)); 564 var dateEarlierMessage = properties.get('fieldValidation.dateField.maxMessage'); 565 var dateLaterMessage = properties.get('fieldValidation.dateField.minMessage'); 566 if(dateEarlierMessage == undefined || dateEarlierMessage.length==0){ 567 dateEarlierMessage = 'Value must be on or earlier than'; 568 } 569 if(dateLaterMessage == undefined || dateLaterMessage.length==0){ 570 dateLaterMessage = 'Value must be on or later than'; 571 } 572 if(dateIn>maxDateVar){ 573 this.setCustomValidity(dateEarlierMessage+' '+(maxDateVar.getMonth()+1)+'/'+(maxDateVar.getDate()+1)+'/'+maxDateVar.getFullYear()); 574 }else if(dateIn<minDateVar){ 575 this.setCustomValidity(dateLaterMessage+' '+(minDateVar.getMonth()+1)+'/'+(minDateVar.getDate()+1)+'/'+minDateV
575ar.getFullYear()); 576 }else{ 577 this.setCustomValidity(''); 578 } 579 } 580 }); 581 str = $(this).val(); 582 if (str.indexOf("/") != 2){ 583 date = str.substring(5,7)+'/'+str.substring(8)+'/'+str.substring(0,4);//+str.substring(3,5); 584 console.log(date); 585 $(this).val(date); 586 } 587 }); 588 }); 589 } 590} 591 592function fixDateFieldPlaceholder(field){ 593 if(field.attr('type') == 'date'){ 594 field.on('change', function(){ 595 if(field.val()!==''){ 596 field.addClass('hasValue'); 597 }else{ 598 field.removeClass('hasValue'); 599 }}); 600 } 601 /* 602 if(field.attr('type') == 'date'){ 603 field.attr('type', 'text'); 604 field.attr('imsi-date', true); 605 field.on('focus', function(){ 606 field.attr('type', 'date'); 607 }); 608 field.on('blur', function(){ 609 if(field.val().length==0){ 610 field.attr('type', 'text'); 611 } 612 }); 613 }*/ 614} 615 616 617function properCase (str) { 618 if ((str===null) || (str==='')) 619 return ''; 620 else 621 str = str.toString(); 622 623 return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); 624} 625 626function applyProperCase(){ 627 $('form input:text').on('keyup', function(){ 628 if($(this).hasClass("noProper")){ 629 return; 630 } 631 $(this).val(properCase($(this).val())); 632 }); 633 $('form input:text').trigger('keyup'); 634} 635 636function applyCase(){ 637 var properCase = properties.get('client.properCaseFormInput'); 638 if(properCase =='Y'){ 639 applyProperCase(); 640 } 641} 642 643function submitForm(form) { 644 var textError = properties.get('fieldValidation.textField.required'); 645 var typeMismatch = properties.get('fieldValidation.typeMismatch'); 646 var patternMismatch = properties.get('fieldValidation.patternMismatch'); 647 var selectError = properties.get('fieldValidation.selectField.required'); 648 649 var f = document.getElementById(form); 650 if(f.checkValidity()) { 651 var pageName = document.getElementById('submitPageName'); 652 if(pageName != null && pageName!= undefined){ 653 var input = document.createElement("input"); 654 input.setAttribute("type", "hidden"); 655 input.setAttribute("name", "submitPageName"); 656 input.setAttribute("value", pageName.textContent); 657 f.appendChild(input); 658 } 659 660 $(escapeID(form)).trigger('submit'); 661 } else { 662 var counter = 0; 663 $('form'+escapeID(form)).find(':input').each(function(){ 664 if(!$(this)[0].validity.valid){ 665 666 counter++; 667 var message = $(this)[0].validationMessage; 668 if($(this)[0].validity.valueMissing && $(this).is("select") && selectError !== undefined && selectError.length>0){ 669 message = selectError; 670 }else if($(this)[0].validity.valueMissing && textError !== undefined && textError.length>0){ 671 message = textError; 672 }else if($(this)[0].validity.patternMismatch && typeMismatch !== undefined && typeMismatch.length>0){ 673 message = patternMismatch; 674 }else if($(this)[0].validity.typeMismatch && typeMismatch !== undefined && typeMismatch.length>0){ 675 message = typeMismatch; 676 } 677 if(counter == 1){ 678 $(this).trigger('focus'); 679 $('html,body').animate({ scrollTop: $(this).offset().top }, 500); 680 } 681 $(this).notify(message); 682 console.log('Error: '+$(this).prop('id')); 683 if (typeof errorHighlight === 'function') { 684 errorHighlight($(this)); 685 } 686 687 } 688 }); 689 } 690} 691 692function retrieveURLAJAX(url, divID, formObj, displayLoader, callbackFunction, allowMultiSubmit) 693{ 694 var method = "GET"; 695 var parameterString = ""; 696 var multiSubmit = false; 697 698 if(allowMultiSubmit!=null){ 699 multiSubmit = true; 700 } 701 if(canSubmit || multiSubmit){ 702 canSubmit = false; 703 if(formObj!=null){ 704 method = "POST"; 705 parameterString = buildFormStringAJAX(formObj, parameterString); 706 } 707 if(formObj!=null){ 708 parameterString += "returnDiv="+divID+"&screenWidth="+$(window).width(); 709 }else if(url.indexOf("?")>0){ 710 url += "&returnDiv="+divID+"&screenWidth="+$(window).width(); 711 }else{ 712 url += "?returnDiv="+divID+"&screenWidth="+$(window).width(); 713 } 714 715 716 if(alternateDiv == null && displayLoader == null){ 717 document.getElementById(divID).innerHTML = '<br/><br/><center><img src="../images/'+getLoader()+'"></center>'; 718 } 719 720 callback = null; 721 if(isFunction(callbackFunction)){ 722 callback = callbackFunction; 723 } 724 //alert('sending: '+divID+':'+url); 725 workingDiv = divID; 726 if (window.XMLHttpRequest) 727 { 728 // Non-IE browsers 729 req = new XMLHttpRequest(); 730 req.onreadystatechange = processStateChangeAJAX; 731 try { 732 req.open(method, url, true);
733 if(formObj!=null){ 734 req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 735 req.send(parameterString); 736 postURLParams = parameterString; 737 }else{ 738 req.send(null); 739 } 740 } catch (e) { 741 alert(e); 742 } 743 } else if (window.ActiveXObject) { // IE 744 req = new ActiveXObject("Microsoft.XMLHTTP"); 745 if (req) { 746 req.onreadystatechange = processStateChangeAJAX; 747 req.open(method, url, true); 748 if(formObj!=null){ 749 req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 750 req.send(parameterString); 751 postURLParams = parameterString; 752 } 753 req.send(); 754 } 755 } 756 //pushToDivArray(divID, alternateDiv); 757 }else{ 758 alert("Please wait while I process your last request."); 759 } 760 761 } 762 763function buildFormStringAJAX(obj,getstr){ 764 var i; 765 for (i=0; i<obj.childNodes.length; i++) { 766 var node = obj.childNodes[i]; 767 if(node.tagName != null){ 768 if(node.tagName.toUpperCase()=="BODY" || node.tagName.toUpperCase()=="TABLE" || node.tagName.toUpperCase()=="TBODY" || node.tagName.toUpperCase()=="TR"|| node.tagName.toUpperCase()=="TD"|| node.tagName.toUpperCase()=="DIV"|| node.tagName.toUpperCase()=="CENTER" || node.tagName==''||node.tagName=="SPAN"||node.tagName=="FIELDSET"|| node.tagName.toUpperCase()=="LI"|| node.tagName.toUpperCase()=="UL"|| node.tagName.toUpperCase()=="OL"|| node.tagName.toUpperCase()=="P"|| node.tagName.toUpperCase()=="B"){ 769 getstr = buildFormStringAJAX(node, getstr); 770 } 771 772 if (obj.childNodes[i].tagName.toUpperCase() == "INPUT") { 773 if (obj.childNodes[i].type.toUpperCase() == "TEXT" || obj.childNodes[i].type.toUpperCase()=="HIDDEN" || obj.childNodes[i].type.toUpperCase()=="NUMBER" || obj.childNodes[i].type.toUpperCase()=="EMAIL" || obj.childNodes[i].type.toUpperCase()=="TEL" || obj.childNodes[i].type.toUpperCase() == "DATE") { 774 getstr += obj.childNodes[i].name + "=" + escape(obj.childNodes[i].value) + "&"; 775 } 776 if (obj.childNodes[i].type.toUpperCase() == "CHECKBOX") { 777 if (obj.childNodes[i].checked) { 778 getstr += obj.childNodes[i].name + "="+obj.childNodes[i].value+ "&"; 779 } 780 } 781 if (obj.childNodes[i].type.toUpperCase() == "RADIO") { 782 if (obj.childNodes[i].checked) { 783 getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; 784 } 785 } 786 if(obj.childNodes[i].type.toUpperCase() == "PASSWORD"){ 787 getstr += obj.childNodes[i].name + "=" + escape(obj.childNodes[i].value) + "&"; 788 } 789 } 790 if (obj.childNodes[i].tagName.toUpperCase() == "SELECT") { 791 var sel = obj.childNodes[i]; 792 getstr += sel.name + "=" + escape(sel.options[sel.selectedIndex].value) + "&"; 793 } 794 if(obj.childNodes[i].tagName.toUpperCase() == "TEXTAREA"){ 795 getstr += obj.childNodes[i].name + "=" + encodeURIComponent(obj.childNodes[i].value) + "&"; 796 } 797 798 } 799 } 800 return getstr; 801} 802 803function waitFor(){ 804 while(req.readyState!= 4 && workingDiv!=null){ 805 sleep(10); 806 } 807} 808 809function closeLightWindow(){ 810 if(req.status == 210){ 811 myLightWindow.deactivate(); 812 } 813} 814 815function processStateChangeAJAX() { 816 var scripts = null; 817 if (req.readyState == 4) { // Complete 818 819 if (req.status == 200) { // OK response 820 scripts = parseScript(req.responseText); 821 var tempDiv = parseDiv(req.responseText); 822 if(tempDiv != null && tempDiv.length>0){ 823 workingDiv = tempDiv; 824 console.log('workingDiv='+workingDiv); 825 } 826 try { 827 document.getElementById(workingDiv).innerHTML = req.responseText; 828 }catch(ex){ 829 alert('error='+ex.message); 830 } 831 if(typeof myLightWindow != "undefined"){ 832 myLightWindow._setupLinks(); 833 } 834 }else if(req.status == 210){//IMSI HTTP Div Redirect Status code. 0 for IE issue 835 /*if(tempDiv != null && tempDiv.length>0){ 836 popDiv(tempDiv); 837 }*/ 838 if(windowName ==null){ 839 scripts = parseScript(req.responseText); 840 document.getElementById(alternateDiv).innerHTML = req.responseText; 841 }else{ 842 scripts = parseScript(req.responseText); 843 document.getElementById(workingDiv).innerHTML = req.responseText; 844 var ppURL = postURL; 845 if(postURLParams != null){ 846 ppURL += "?"+postURLParams; 847 } 848 newWindow(ppURL, windowName, windowWidth, windowHeight, 'yes', 'center'); 849 postURL = null; 850 postURLParams = null; 851 windowName = null; 852 windowWidth = null; 853 windowHeight = null; 854 } 855 if(typeof myLightWindow != "undefined"){ 856 myLightWindow._setupLinks(); 857 } 858 }else if(req.status == 211){//IMSI HTTP Div Not Authenticated. 859 scripts = parseScript(req.responseText); 860 document.body.innerHTML = req.responseText; 861 }else { 862 alert(req.status); 863 alert("Problem: " + req.statusText); 864 } 865 866 workingDiv = null; 867 alternateDiv = null; 868 canSubmit = true; 869 870 if(func !=null && func && typeof(func.onComplete) == 'function') { 871 func.onComplete(); 872 func = null; 873 } 874 875 if(isFunction(callback)){ 876 callback(); 877 } 878 879 if(scripts!=null){ 880 evalScripts(scripts); 881 } 882 883 //callback = null; 884 } 885} 886 887function parseScript(_source) { 888 var source = _source; 889 var scripts = new Array(); 890 891 // Strip out tags 892 while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) { 893 var s = source.indexOf("<script"); 894 var s_e = source.indexOf(">", s);
895 var e = source.indexOf("</script", s); 896 var e_e = source.indexOf(">", e); 897 // Add to scripts array 898 scripts.push(source.substring(s_e+1, e)); 899 // Strip from source 900 source = source.substring(0, s) + source.substring(e_e+1); 901 } 902 if(source.indexOf('hiddenScript')>0){ 903 var s = source.indexOf("hiddenScript"); 904 var s_e = source.indexOf(">", s); 905 var e = source.toUpperCase().indexOf("</DIV", s); 906 scripts.push(source.substring(s_e+1, e)); 907 } 908 return scripts; 909 910 911 // Return the cleaned source 912 //return source; 913} 914 915function parseDiv(source){ 916 var divID; 917 while(source.indexOf("<!-- workingDiv")>-1){ 918 var begin = source.indexOf("<!-- workingDiv"); 919 var equal = source.indexOf("=", begin); 920 var end = source.indexOf(" -->", equal); 921 var div = source.substring(equal+1, end); 922 divID = div; 923 break; 924 } 925 return divID; 926} 927 928/*function popDiv(tempDiv){ 929 var i = findDivInArray(tempDiv); 930 if(i>=0){ 931 divID = divArray[i][0]; 932 alternateDiv = divArray[i][1]; 933 divArray.splice(i,1); 934 } 935} 936 937function pushToDivArray(divIDa, alternateDivIDa){ 938 var i = findDivInArray(divIDa); 939 if(i<0){ 940 divArray.push([divIDa, alternateDivIDa]); 941 } 942} 943 944function findDivInArray(tempDiv){ 945 for( var i=0;i< divArray.length;i++){ 946 var stringArray = divArray[i]; 947 if(stringArray[0]==tempDiv){ 948 return i; 949 } 950 } 951 return -1; 952}*/ 953 954function isIE(){ 955 var ua = window.navigator.userAgent; 956 var msie = ua.indexOf("MSIE "); 957 958 if (msie > 0){ 959 return true; 960 } 961 return false; 962} 963 964function safariOsVersion() { 965 if (navigator.appVersion.indexOf('Safari')) { 966 var v = (navigator.appVersion).match(/Version\/(\d+).(\d+)?/); 967 if (v !== null && v.length > 1) { 968 return v[1]; 969 } 970 } 971 return 0; 972} 973 974function evalScripts(scripts){ 975 var window = this; 976 var isMSIE = isIE(); 977 // Loop through every script collected and eval it 978 for(var i=0; i<scripts.length; i++) { 979 try { 980 if(scripts[i]==null || scripts[i].length==0){ 981 continue; 982 } 983 if(isMSIE){ 984 window.execScript(scripts[i]); 985 }else{ 986 eval.call(window,scripts[i]); 987 } 988 } 989 catch(ex) {} 990 } 991} 992 993function newWindow(mypage,myname,w,h,scroll,pos){ 994 if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;} 995 else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20} 996 settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+', location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes'; 997 window.open(mypage,myname,settings); 998} 999 1000function newWindowPost(mypage,myname,w,h,scroll,pos, formObj){ 1001 if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;} 1002 else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20} 1003 settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+', location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes'; 1004 window.open('about:blank',myname,settings); 1005 document.getElementById(formObj).action=mypage; 1006 document.getElementById(formObj).target=myname; 1007 document.getElementById(formObj).submit(); 1008} 1009 1010function evaluateSubmitExtension(){ 1011 var updateableProperties = document.getElementById('updateableProperties').value; 1012 var recordID = document.getElementById('recordID').value; 1013 1014 if(updateableProperties=='false'){ 1015 document.getElementById('extensionParameterForm'+recordID).submit(); 1016 } 1017} 1018 1019var dateInput; 1020function checkDateInput() { 1021 if(dateInput == null){ 1022 var input = document.createElement('input'); 1023 input.setAttribute('type','date'); 1024 1025 var notADateValue = 'not-a-date'; 1026 input.setAttribute('value', notADateValue); 1027 dateInput = (input.value !== notADateValue); 1028 } 1029 return dateInput; 1030} 1031 1032function toggleSSN(id){ 1033 let input = $(escapeID(id)); 1034 let replacement = input.clone(); 1035 var title = 'SSN'; 1036 if(id == 'ein'){ 1037 title = 'EIN'; 1038 } 1039 // jQuery migrate fix, instead of changing type of existing element, create new element altogether 1040 const originalInputType = $(escapeID(id)).attr("type")==="tel" ? "password":"tel"; 1041 replacement.attr('type', originalInputType); 1042 const inputVal = $(escapeID(id)).val(); 1043 1044 if (originalInputType !== 'password') { 1045 replacement.attr('class', 'ssn').attr('pattern', "^\\d{3}-\\d{2}-\\d{4}$"); 1046 input.replaceWith(replacement); 1047 replacement.mask("999-99-9999"); 1048 // this must happen after the mask is re-called or it won't be properly formatted 1049 replacement.val(inputVal).trigger('input'); 1050 $(escapeID(id+'Toggle')).html('<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 640 512"><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"/></svg>'); 1051 }else{ 1052 replacement.removeAttr('class').removeAttr('pattern'); 1053 input.replaceWith(replacement); 1054 replacement.unmask(); 1055 // no mask on the text input so we remove - 1056 replacement.val(inputVal.replaceAll('-','')).trigger('input'); 1057 $(escapeID(id+'Toggle')).html('<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 576 512"><path d="M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z"/></svg>'); 1058 } 1059} 1060 1061function toggleSSNNoIcon(id){ 1062 let input = $(escapeID(id)); 1063 let replacement = input.clone(); 1064 var title = 'SSN'; 1065 if(id == 'ein'){ 1066 title = 'EIN'; 1067 } 1068 // jQuery migrate fix, instead of changing type of existing element, create new element altogether 1069 const originalInputType = $(escapeID(id)).attr("type")==="tel" ? "password":"tel"; 1070 replacement.attr('type', originalInputType); 1071 const inputVal = $(escapeID(id)).val(); 1072 1073 if (originalInputType !== 'password') { 1074 replacement.attr('class', 'ssn').attr('pattern', "^\\d{3}-\\d{2}-\\d{4}$"); 1075 input.replaceWith(replacement); 1076 replacement.mask("999-99-9999"); 1077 // this must happen after the mask is re-called or it won't be properly formatted 1078 replacement.val(inputVal).trigger('input'); 1079 $(escapeID(id+'Toggle')).text("Show "+title); 1080 } else { 1081 replacement.removeAttr('class').removeAttr('pattern'); 1082 input.replaceWith(replacement); 1083 replacement.unmask(); 1084 // no mask on the text input so we remove - 1085 replacement.val(inputVal.replaceAll('-','')).trigger('input'); 1086 $(escapeID(id+'Toggle')).text("Show "+title); 1087 } 1088} 1089 1090function keyupCC(){ 1091 var ccNumber = document.getElementById("creditNumber"); 1092 if(ccNumber!=null){ 1093 var ccVal = ccNumber.value;
1094 var type = getCreditCardType(ccVal); 1095 if(type!="unknown"){ 1096 var appender = ""; 1097 if(type =="amex"){ 1098 appender = " Not accepted"; 1099 }else{ 1100 appender = " Accepted"; 1101 } 1102 $("#ccDisplay").html('<img src="/IMSIWeb/images/'+type+'.png"/>'+appender); 1103 }else{ 1104 $("#ccDisplay").html(""); 1105 } 1106 1107 if(isValidCC(ccVal)){ 1108 $("#creditNumber").css("background-color", "#94e194"); 1109 }else if(ccVal.length>0){ 1110 $("#creditNumber").css("background-color", "#ffebeb"); 1111 }else if(ccVal.length==0){ 1112 $("#creditNumber").css("background-color", ""); 1113 } 1114 } 1115} 1116 1117function routingDFILookupSuccess(data){ 1118 var dfiName="unknown"; 1119 for (var member in data) 1120 { 1121 if(member == "code" && data[member]!=200){ 1122 break; 1123 } 1124 if(member == "name"){ 1125 dfiName = data[member]; 1126 break; 1127 } 1128 } 1129 if(dfiName == "unknown"){ 1130 alert("Routing Number is not recognized as a financial institution, please double check this value."); 1131 document.getElementById("dfiRow").style.display="none"; 1132 document.getElementById("dfiDisplay").innerHTML=""; 1133 }else{ 1134 document.getElementById("dfiRow").style.display=""; 1135 document.getElementById("dfiDisplay").innerHTML="<b>"+dfiName+"</b>"; 1136 } 1137} 1138function lookupRouting(){ 1139 var rnItem = document.getElementById("routingNumber"); 1140 if(rnItem != null){ 1141 var rn = rnItem.value; 1142 if(rn.length==9){ 1143 $.ajax({ 1144 url: "https://routingnumbers.herokuapp.com/api/name.json?rn=" + rn, 1145 dataType: "jsonp", 1146 success: routingDFILookupSuccess 1147 }); 1148 } 1149 } 1150} 1151 1152 1153function lookupZip(zipcode, async=true){ 1154 var url = "https://maps.googleapis.com/maps/api/geocode/json?key="; 1155 var key = properties.get('api.geoCode.key'); 1156 url += key; 1157 url += "&address="+zipcode; 1158 $.ajax({ 1159 url: url, 1160 dataType: "json", 1161 success: zipcodeLookupSuccess, 1162 async: async 1163 }); 1164} 1165 1166function zipcodeLookupSuccess(data){ 1167 var city = ''; 1168 var state = ''; 1169 data.results[0]?.address_components.forEach(function(component) { 1170 if(component.types[0]=='locality' || component.types[0]=='neighborhood'){ 1171 city=component.long_name; 1172 } 1173 if(component.types[0]=='administrative_area_level_1'){ 1174 state=component.short_name; 1175 } 1176 }); 1177 // ensure we have a value here, otherwise we can potentially overwrite existing city/state with blank values 1178 if (city !== '') { 1179 $('#city').val(city); 1180 } 1181 if (state !== '') { 1182 $('#state').val(state); 1183} 1184} 1185 1186function isValidRoutingNumber(routing){ 1187 if (routing.length !== 9) { 1188 return false; 1189 } 1190 1191 var checksumTotal = (7 * (parseInt(routing.charAt(0),10) + parseInt(routing.charAt(3),10) + parseInt(routing.charAt(6),10))) + 1192 (3 * (parseInt(routing.charAt(1),10) + parseInt(routing.charAt(4),10) + parseInt(routing.charAt(7),10))) + 1193 (9 * (parseInt(routing.charAt(2),10) + parseInt(routing.charAt(5),10) + parseInt(routing.charAt(8),10))); 1194 1195 var checksumMod = checksumTotal % 10; 1196 if (checksumMod !== 0) { 1197 return false; 1198 } else { 1199 return true; 1200 } 1201} 1202 1203function uploadAttachContainsContent(event, applicationID, id, applicantID, categoryID) { 1204 var file = $(event)[0].files[0]; 1205 if (!file || file.size <= 0) { 1206 $(event).notify('File does not contain content'); 1207 return false; 1208 } 1209 uploadAttach(applicationID, id, applicantID, categoryID); 1210}
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.