1// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2// for details on configuring this project to bundle and minify static web assets. 3var EMAIL_REGEX = new RegExp('^(([^<>()\\[\\]\\.,;:\\s@"]+(\\.[^<>()\\[\\]\\.,;:\\s@"]+)*)|(".+"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$'); 4 5$.extend({ 6 apiget: function (url, data, successCallback) { 7 $.get(url, data, successCallback); 8 } 9}); 10 11$.extend({ 12 apipost: function (url, data, groupId, successCallback) { 13 14 $.post({ 15 url: url, 16 data: data, 17 headers: { 18 RequestVerificationToken: CP.AntiForgeryToken 19 }, 20 dataType: "json", 21 success: function (data) { 22 23 if (data.result == "Success") { 24 $(this).addClass('has-success'); 25 $('#cc-dialog').modal('hide'); 26 } else { 27 $(this).addClass('has-error'); 28 } 29 30 setTimeout(function () { 31 $(this).removeClass('has-error'); $(this).removeClass('has-success'); 32 }, 1000); 33 34 if (typeof successCallback === 'function') { 35 successCallback(data); 36 } 37 } 38 }); 39 } 40}); 41 42$.extend({ 43 apidelete: function (url, data, successCallback, errorCallback) { 44 $.ajax({
45 url: url, 46 data: data, 47 type: 'DELETE', 48 success: successCallback, 49 error: errorCallback 50 }); 51 } 52}); 53 54$.extend({ 55 apiput: function (url, data, successCallback, errorCallback) { 56 $.ajax({ 57 url: url, 58 data: data, 59 type: 'PUT', 60 success: successCallback, 61 error: errorCallback 62 }); 63 } 64}); 65 66$.extend({ 67 alert: function (title, message) { 68 $("<div></div>").dialog({ 69 buttons: [ 70 { 71 text: "OK", 72 click: function () { $(this).remove(); } 73 } 74 ], 75 close: function (event, ui) { $(this).remove(); }, 76 resizable: false, 77 title: title, 78 modal: true, 79 width: 420, 80 zIndex: 100002 81 }).html(message).parent().addClass("no-close");; 82 } 83}); 84 85$.extend({ 86 confirm: function (title, message, yesCallback, yesText, noText, noCallback, width, cancelText) { 87 $("<div id=\"jqueryExtendedConfirmDialog\"></div>").dialog({ 88 buttons: [ 89 { 90 text: yesText == null ? "Yes" : yesText, 91 "class": "btn btn-primary textButtonYes", 92 click: function () { 93 if (typeof (yesCallback) != 'undefined') { 94 yesCallback(); 95 } 96 $(this).remove(); 97 } 98 }, 99 { 100 text: noText == null ? "No" : noText, 101 "class": "btn btn-link textButtonNo", 102 click: function () { 103 if (noCallback !== null && (typeof (noCallback) != 'undefined')) { 104 noCallback(); 105 } 106 $(this).remove(); 107 } 108 }, 109 { 110 text: cancelText == null ? "Cancel" : cancelText, 111 "class": cancelText == null ? 'hide' : 'btn btn-link textButtonNo', 112 click: function () { 113 $(this).remove(); 114 } 115 } 116 ], 117 close: function (event, ui) { $(this).remove(); }, 118 resizable: false, 119 title: title, 120 modal: true, 121 width: width == null ? 420 : width, 122 zIndex: 100002 123 }).html(message).parent().addClass("no-close"); 124 } 125}); 126 127$.fn.isChecked = function (setCheck) { 128 if (typeof (setCheck) != 'undefined') { 129 this.prop('checked', setCheck); 130 } else { 131 return this.prop('checked'); 132 } 133}; 134$.fn.isEnabled = function (setEnabled) { 135 if (typeof (setEnabled) != 'undefined') { 136 var type = this.prop('type'); 137 this.prop('disabled', !setEnabled); 138 if (type == 'checkbox' || type == 'radio') { 139 var label = this.next('label'); 140 if (typeof (label) != 'undefined') { 141 if (setEnabled) 142 label.removeClass('aspNetDisabled'); 143 else 144 label.addClass('aspNetDisabled'); 145 } 146 } 147 } else { 148 return !this.prop('disabled'); 149 } 150}; 151$.fn.isDate = function () { 152 var d = new Date(this[0].value); 153 return !isNaN(d.valueOf()); 154}; 155$.fn.isVisible = function (visible) { 156 if (typeof (visible) != 'undefined') { 157 if (visible) this.show(); 158 else this.hide(); 159 } else { 160 return this.is(':visible'); 161 } 162}; 163 164String.prototype.startsWith = function (searchString, position) { 165 position = position || 0; 166 return this.indexOf(searchString, position) === position; 167}; 168 169String.prototype.format = function (type, areaCode) { 170 if (type == 'phone') { 171 var strph = new String(this).replace(/[^\d\+]/g, ""); 172 var strtemp = strph; 173 oldPhone = strph; 174 175 if (strph.charCodeAt(0) == "+".charCodeAt(0)) { 176 //Leave it alone 177 strph = oldPhone; 178 } else { 179 //Remove 1 from 19015550000 180 if (oldPhone.charCodeAt(0) == "1".charCodeAt(0) && oldPhone.length == 11) { 181 oldPhone = oldPhone.substr(1); 182 } 183 //555-0000 184 if (oldPhone.length == 7) { 185 if (typeof (areaCode) != 'undefined' && areaCode != "") { 186 oldPhone = areaCode + oldPhone; 187 } 188 } //(901) 555-0000 189 if (oldPhone.length == 10) { 190 strtemp = '(' + oldPhone.substr(0, 3) + ') ' + oldPhone.substr(3, 3) + '-' + oldPhone.substr(6, 4); 191 } else if (oldPhone.length == 7) { 192 strtemp = oldPhone.substr(0, 3) + '-' + oldPhone.substr(3); 193 } else { 194 strtemp = oldPhone; 195 } 196 } 197 return strtemp; 198 } 199}; 200 201String.prototype.toCurrency = function formatCurrency(round) { 202 if (this == "") 203 return ""; 204
205 var num = this.toFloat(); 206 207 // evalutate number input 208 var numParts = String(num).split('.'); 209 var isPositive = (num == Math.abs(num)); 210 var hasDecimals = (numParts.length > 1); 211 var decimals = (hasDecimals ? numParts[1].toString() : '0'); 212 213 // format number 214 num = Math.abs(numParts[0]); 215 num = isNaN(num) ? 0 : num; 216 round = isNaN(round) ? 0 : round; 217 if (round > 0) { 218 decimals = parseFloat('1.' + decimals); // prepend "0."; (IE does NOT round 0.50.toFixed(0) up, but (1+0.50).toFixed(0)-1 219 decimals = decimals.toFixed(round); // round 220 if (decimals.substring(0, 1) == '2') { 221 num = Number(num) + 1; 222 } 223 decimals = decimals.substring(2); // remove "0." 224 } 225 else if ($.cultureInfo.roundToDecimalPlace >= 0) { 226 decimals = parseFloat('1.' + decimals); // prepend "0."; (IE does NOT round 0.50.toFixed(0) up, but (1+0.50).toFixed(0)-1 227 decimals = decimals.toFixed($.cultureInfo.roundToDecimalPlace); // round 228 if (decimals.substring(0, 1) == '2') { 229 num = Number(num) + 1; 230 } 231 decimals = decimals.substring(2); // remove "0." 232 } 233 num = String(num); 234 235 if ($.cultureInfo.groupDigits) { 236 for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { 237 num = num.substring(0, num.length - (4 * i + 3)) + $.cultureInfo.digitGroupSymbol + num.substring(num.length - (4 * i + 3)); 238 } 239 } 240 241 if ((hasDecimals && $.cultureInfo.roundToDecimalPlace == -1) || $.cultureInfo.roundToDecimalPlace > 0 || round > 0) { 242 num += $.cultureInfo.decimalSymbol + decimals; 243 } 244 245 // format symbol/negative 246 var format = isPositive ? $.cultureInfo.positiveFormat : $.cultureInfo.negativeFormat; 247 var money = format.replace(/%s/g, $.cultureInfo.symbol); 248 money = money.replace(/%n/g, num); 249 250 return money; 251}; 252 253String.prototype.toFloat = function toFloat() { 254 var num = this.replace(/[^\d.()-]/g, ''); 255 if (num.indexOf('(') > -1) { 256 num = '-' + num.replace('(', '').replace(')', ''); 257 } 258 num = isNaN(num) || num === '' || num === null ? 0.00 : num; 259 return parseFloat(num); 260}; 261 262$(document).on("blur", ":text", function () { 263 formatTextBox(this); 264}); 265 266$(document).on('focus', ':text', function () { 267 var $this = $(this); 268 var classes = $this.attr('class'); 269 if (classes != null && $this.attr('readonly') != 'readonly') { 270 var cls = classes.split(' '); 271 if ($.inArray('currency', cls) != -1) {
272 var amount = $this.val().toFloat(); 273 if (amount == 0) 274 $this.val(""); 275 else 276 $this.val(amount.toFixed(2)); 277 } 278 } 279}); 280 281function ShowScannedCheckModal(checkId) { 282 if (typeof checkId === 'undefined' || checkId === null || checkId === '') { 283 console.log("Invalid checkId provided to ShowScannedCheckModal function."); 284 return; 285 } 286 287 var scancheckmodaldiv = $('<div>', { 288 id: "ScannedCheckModal", 289 class: "et-modal modal", 290 tabindex: "-1", 291 role: "dialog", 292 'data-keyboard': "false", 293 'data-backdrop': "static", 294 }); 295 296 var oldDiv = document.getElementById("ScannedCheckModal"); 297 if (oldDiv != null) { oldDiv.remove(); } 298 $('body').append(scancheckmodaldiv); 299 openDialog(Dialogs.ScanCheck, "/cp/Reports/GetScannedCheckModal", { 'scannedCheckId': checkId }, '', ScannedCheckModalLoaded,''); 300 return; 301} 302function ScannedCheckModalLoaded(e) { 303 scannedCheckModalInitialize(); 304} 305function showAmplifyInvoiceModal() { 306 showRootLoadingOverlay(); 307 $("#AmplifyBillingModalBody").empty(); 308 $("#AmplifyBillingModalBody").load("/cp/invoice/GetAmplifyInvoiceModalForm", function (responseTxt, statusTxt, xhr) { 309 if (statusTxt == "success") { 310 initializeAmplifyModal(); 311 } 312 if (statusTxt == "error") { 313 hideRootLoadingOverlay(); 314 alert('Unable to load Payment Form'); 315 } 316 }); 317 318} 319function formatTextBox(textBox) { 320 var control = $(textBox); 321 var classes = control.attr('class'); 322 if (classes == null) 323 return; 324 var cls = classes.split(' '); 325 if ($.inArray('currency', cls) != -1) { 326 if (control.val() == '') 327 control.val("0"); 328 control.val(control.val().toCurrency()); 329 } else if ($.inArray('currency-4', cls) != -1) { 330 if (control.val() == '') 331 control.val("0"); 332 control.val(control.val().toCurrency(4)); 333 } else if ($.inArray('percent', cls) != -1) { 334 control.val(formatPercent(control.val())); 335 } else if (control.val() != '') { 336 if ($.inArray('zerodecimals', cls) != -1 337 || $.inArray('twodecimals', cls) != -1 338 || $.inArray('hours', cls) != -1 339 || $.inArray('fourdecimals', cls) != -1 340 || $.inArray('sixdecimals', cls) != -1) { 341 var decimals = 2; 342 if ($.inArray('zerodecimals', cls) != -1) decimals = 0; 343 if ($.inArray('fourdecimals', cls) != -1) decimals = 4; 344 if ($.inArray('sixdecimals', cls) != -1) decimals = 6;
345 var result = control.val().toFloat(); 346 if (result < 0) { 347 result = '(' + (result * -1).toFixed(decimals) + ')'; 348 } 349 else { 350 result = result.toFixed(decimals); 351 } 352 control.val(result); 353 } 354 } 355} 356 357Date.prototype.addDays = function (days) { 358 var dat = new Date(this.valueOf()); 359 dat.setDate(dat.getDate() + days); 360 return dat; 361}; 362 363Date.prototype.addMonths = function (num) { 364 var value = new Date(this.valueOf()); 365 366 var mo = this.getMonth(); 367 var yr = this.getFullYear(); 368 369 mo = (mo + num) % 12; 370 if (0 > mo) { 371 yr += (this.getMonth() + num - mo - 12) / 12; 372 mo += 12; 373 } 374 else 375 yr += ((this.getMonth() + num - mo) / 12); 376 377 value.setMonth(mo); 378 value.setYear(yr); 379 return value; 380}; 381 382function autoFreq1() { 383 var selection = ""; 384 var today = new Date(); 385 var firstofMonth = new Date(today.getFullYear(), today.getMonth(), 1); 386 firstofMonth = firstofMonth.addMonths(1); 387 for (i = 0; i < 6; i++) { 388 selection = selection + "<option value='" + firstofMonth.toLocaleDateString() + "'>" + firstofMonth.toLocaleDateString() + "</option>"; 389 firstofMonth = firstofMonth.addMonths(1); 390 } 391 392 return selection; 393} 394 395function autoFreq2() { 396 var selection = ""; 397 var today = new Date(); 398 var sixteenthoftheMonth = new Date(today.getFullYear(), today.getMonth(), 16); 399 400 if (today.getDate() > 15) 401 sixteenthoftheMonth = sixteenthoftheMonth.addMonths(1); 402 403 for (i = 0; i < 6; i++) { 404 selection = selection + "<option value='" + sixteenthoftheMonth.toLocaleDateString() + "'>" + sixteenthoftheMonth.toLocaleDateString() + "</option>"; 405 sixteenthoftheMonth = sixteenthoftheMonth.addMonths(1); 406 } 407 408 return selection; 409} 410 411function autoFreq3() { 412 var selection = ""; 413 var today = new Date(); 414 var firstofMonth = new Date(today.getFullYear(), today.getMonth(), 1); 415 var sixteenthoftheMonth = new Date(today.getFullYear(), today.getMonth(), 16); 416 firstofMonth = firstofMonth.addMonths(1); 417 418 if (today.getDate() >= 16) { 419 sixteenthoftheMonth = sixteenthoftheMonth.addMonths(1); 420 selection = selection + "<option value='" + firstofMonth.toLocaleDateString() + "'>" + firstofMonth.toLocaleDateString() + "</option>"; 421 selection = selection + "<option value='" + sixteenthoftheMonth.toLocaleDateString() + "'>" + sixteenthoftheMonth.toLocaleDateString() + "</option>"; 422 } else { 423 selection = selection + "<option value='" + sixteenthoftheMonth.toLocaleDateString() + "'>" + sixteenthoftheMonth.toLocaleDateString() + "</option>"; 424 } 425 426 for (i = 0; i < 4; i++) { 427 firstofMonth = firstofMonth.addMonths(1); 428 sixteenthoftheMonth = sixteenthoftheMonth.addMonths(1); 429 selection = selection + "<option value='" + firstofMonth.toLocaleDateString() + "'>" + firstofMonth.toLocaleDateString() + "</option>"; 430 selection = selection + "<option value='" + sixteenthoftheMonth.toLocaleDateString() + "'>" + sixteenthoftheMonth.toLocaleDateString() + "</option>"; 431 } 432 433 return selection; 434} 435 436function autoFreq4() { 437 var selection = ""; 438 var today = new Date(); 439 var fifthoftheMonth = new Date(today.getFullYear(), today.getMonth(), 5); 440 var twentiethoftheMonth = new Date(today.getFullYear(), today.getMonth(), 20); 441 fifthoftheMonth = fifthoftheMonth.addMonths(1); 442 443 if ((today.getDate() >= 20) || (today.getDate() < 5)) { 444 twentiethoftheMonth = twentiethoftheMonth.addMonths(1); 445 selection = selection + "<option value='" + fifthoftheMonth.toLocaleDateString() + "'>" + fifthoftheMonth.toLocaleDateString() + "</option>"; 446 selection = selection + "<option value='" + twentiethoftheMonth.toLocaleDateString() + "'>" + twentiethoftheMonth.toLocaleDateString() + "</option>"; 447 } else { 448 selection = selection + "<option value='" + twentiethoftheMonth.toLocaleDateString() + "'>" + twentiethoftheMonth.toLocaleDateString() + "</option>"; 449 } 450 451 for (i = 0; i < 4; i++) { 452 fifthoftheMonth = fifthoftheMonth.addMonths(1); 453 twentiethoftheMonth = twentiethoftheMonth.addMonths(1); 454 selection = selection + "<option value='" + fifthoftheMonth.toLocaleDateString() + "'>" + fifthoftheMonth.toLocaleDateString() + "</option>"; 455 selection = selection + "<option value='" + twentiethoftheMonth.toLocaleDateString() + "'>" + twentiethoftheMonth.toLocaleDateString() + "</option>"; 456 } 457 458 return selection; 459} 460 461function autoFreq5() { 462 var selection = ""; 463 var selectedDay = new Date(); 464 var isSunday = false; 465 466 while (!isSunday) { 467 selectedDay = selectedDay.addDays(1); 468 if (selectedDay.getDay() == 0) 469 isSunday = true; 470 } 471 472 for (i = 0; i < 6; i++) { 473 selection = selection + "<option value='" + selectedDay.toLocaleDateString() + "'>" + selectedDay.toLocaleDateString() + "</option>"; 474 selectedDay = selectedDay.addDays(7); 475 } 476 477 return selection; 478} 479 480function fixStartDate(tstd) { 481 var today = new Date(); 482 var tomorrow = new Date(today.addDays(1));
483 var autoStartSpan = document.getElementById("freqStartOption"); 484 var selOptions = "<option value='" + tomorrow.toDateString() + "'>" + tomorrow.toLocaleDateString() + "</option>"; 485 if (tstd == 1) { selOptions = autoFreq1(); } 486 if (tstd == 2) { selOptions = autoFreq2(); } 487 if (tstd == 3) { selOptions = autoFreq3(); } 488 if (tstd == 4) { selOptions = autoFreq4(); } 489 if ((tstd == 5) || (tstd == 6)) { selOptions = autoFreq5(); } 490 491 autoStartSpan.innerHTML = "<select class='form-control' id='startdate' name='startdate'>" + selOptions + "</select>"; 492} 493 494// Adjusts end date for datetimepicker controls so End Date is in range 495function adjustEndDateLimits(startControlId, endControlId) { 496 if ($(startControlId).val() == '') { 497 return; 498 } 499 var startingDate = $(startControlId).data('DateTimePicker').date(); 500 var maxMonths = parseInt(ReportingLimits_MaxMonths); 501 if (maxMonths < 1) maxMonths = 24; 502 var maxDate = moment(startingDate).endOf('day'); 503 var minDate = moment(startingDate).startOf('day'); 504 maxDate.add(maxMonths, 'months'); 505 506 var endOfDay = moment().endOf('day');; 507 if (maxDate > endOfDay) { 508 maxDate = moment(endOfDay).endOf('day'); 509 } 510 var currentEndDate = moment().endOf('day'); 511 if ($(endControlId).val() != '') { 512 currentEndDate = moment($(endControlId).data('DateTimePicker').date()); 513 } 514 if (currentEndDate > maxDate) { 515 currentEndDate = moment(maxDate); 516 } 517 if (currentEndDate < minDate) { 518 currentEndDate = moment(minDate) 519 } 520 // saftey check 521 if (minDate > maxDate) { 522 minDate = moment(maxDate).startOf('day'); 523 } 524 525 // set min max high to prevent errors when setting 526 $(endControlId).datetimepicker('minDate', moment().subtract(10, 'year')); 527 $(endControlId).datetimepicker('maxDate', moment().add(10, 'year')); 528 529 $(endControlId).datetimepicker('date', currentEndDate); 530 $(endControlId).datetimepicker('maxDate', maxDate); 531 $(endControlId).datetimepicker('minDate', minDate); 532} 533function getdateRangeMessage() { 534 return "Maximum Date Range " + ReportingLimits_MaxMonths + " months."; 535} 536 537// Function to validate if date range exceeds maximum allowed months 538function validateDateRange(startDate, endDate) { 539 if (!startDate || !endDate) { 540 return false; 541 } 542 543 var maxMonths = parseInt(ReportingLimits_MaxMonths); 544 if (!maxMonths || maxMonths <= 0) { 545 return true; // No limit set 546 } 547 548 var start = moment(startDate); 549 var end = moment(endDate); 550 var monthsDiff = end.diff(start, 'months', true); 551 552 return monthsDiff <= maxMonths; 553} 554 555// Function to toggle Apply Filters button state 556function toggleApplyFiltersButton(enabled) { 557 if (enabled) { 558 $("#btnApplyFilters").show().prop('disabled', false).removeClass('disabled'); 559 $("#btnApplyFiltersLoading").hide(); 560 } else { 561 $("#btnApplyFilters").hide(); 562 $("#btnApplyFiltersLoading").show(); 563 } 564} 565// Loads the correct sidebar on window load, collapses the sidebar on window resize. Sets the min-height of #page-wrapper to window size. 566$(function () { 567 $("#amplifyBillingBtn").off().on('click', function () { showAmplifyInvoiceModal(); }) 568 $(window).bind("load resize", function () { 569 topOffset = 100; 570 width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width; 571 if (width < 768) { 572 $('div.navbar-collapse').addClass('collapse'); 573 topOffset = 150; // 2-row-menu 574 } else { 575 $('div.navbar-collapse').removeClass('collapse'); 576 } 577 578 height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1; 579 height = height - topOffset; 580 if (height < 1) height = 1; 581 if (height > topOffset) { 582 $("#page-wrapper").css("min-height", (height) + "px"); 583 } 584 }); 585 586 var url = window.location.toString(); 587 if (url.indexOf('?') > 0) 588 url = url.substring(0, url.indexOf('?')); 589 if (url.lastIndexOf('/') == url.length - 1) 590 url = url.substring(0, url.lastIndexOf('/')); 591 592 var element = $('#sidebar-container ul.nav a').filter(function () { 593 return this.href == url; 594 }); 595 var tries = 0; 596 while (element.length == 0 && tries < 4) { 597 url = url.substring(0, url.lastIndexOf('/')); 598 element = $('#sidebar-container ul.nav a').filter(function () { 599 return this.href == url; 600 });
601 tries++; 602 } 603 604 var parent = element.last().addClass('active').parent().parent().addClass('active in').parent(); 605 if (element.is('li')) { 606 element.addClass('active'); 607 } 608 var arrow = parent.find('span.fa-chevron-left'); 609 if (arrow.hasClass('fa-chevron-left')) { 610 arrow.removeClass('fa-chevron-left'); 611 arrow.addClass('fa-chevron-down') 612 } 613 614 $('input[data-val-required]').each(function () { 615 $(this).parent().siblings('label').addClass('text-danger'); 616 }); 617 618 $(document).on('change', 'input.phone', function () { 619 var phone = $(this).val().format('phone'); 620 $(this).val(phone); 621 }); 622 623 $('.currency, .zerodecimals, .twodecimals, .fourdecimals, .sixdecimals, .hours').each(function () { 624 formatTextBox(this); 625 }); 626 627 // $('.currency-symbol').each(function () { 628 // $(this).html($.cultureInfo.symbol); 629 // }); 630 631 $('input[type="text"]').first().focus(); 632}); 633 634function acceptCurrencyEntryOnly(event, acceptNegative) { 635 var val = event.target.value; 636 var hasDecimal = /[.]/.test(val); 637 var isDecimal = (event.which || event.keyCode) == 110 || (event.which || event.keyCode) == 190; 638 639 if (hasDecimal && isDecimal) 640 return false; 641 642 if (event.shiftKey && { 48: 1, 49: 1, 50: 1, 51: 1, 52: 1, 53: 1, 54: 1, 55: 1, 56: 1, 57: 1 }[event.which || event.keyCode] === 1) { 643 return false; 644 } 645 646 if (acceptNegative) { 647 // need to accept 173 b/c dash/negative returns 173 in fire fox (its a bug) 648 return (({ 109: 1, 189: 1, 173: 1, 8: 1, 9: 1, 48: 1, 49: 1, 50: 1, 51: 1, 52: 1, 53: 1, 54: 1, 55: 1, 56: 1, 57: 1, 96: 1, 97: 1, 98: 1, 99: 1, 100: 1, 101: 1, 102: 1, 103: 1, 104: 1, 105: 1, 110: 1, 190: 1, 37: 1, 39: 1, 8: 1, 46: 1, 13: 1 }[event.which || event.keyCode]) == 1); 649 } 650 else { 651 return (({ 8: 1, 9: 1, 48: 1, 49: 1, 50: 1, 51: 1, 52: 1, 53: 1, 54: 1, 55: 1, 56: 1, 57: 1, 96: 1, 97: 1, 98: 1, 99: 1, 100: 1, 101: 1, 102: 1, 103: 1, 104: 1, 105: 1, 110: 1, 190: 1, 37: 1, 39: 1, 8: 1, 46: 1, 13: 1 }[event.which || event.keyCode]) == 1); 652 } 653} 654function acceptNumberEntryOnly(e) { 655 // Enable Shift Tab functionality 656 if (e.shiftKey && { 48: 1, 49: 1, 50: 1, 51: 1, 52: 1, 53: 1, 54: 1, 55: 1, 56: 1, 57: 1 }[e.which || e.keyCode] === 1) { 657 return false; 658 } 659 return (({ 8: 1, 9: 1, 48: 1, 49: 1, 50: 1, 51: 1, 52: 1, 53: 1, 54: 1, 55: 1, 56: 1, 57: 1, 96: 1, 97: 1, 98: 1, 99: 1, 100: 1, 101: 1, 102: 1, 103: 1, 104: 1, 105: 1, 37: 1, 39: 1, 8: 1, 46: 1, 13: 1 }[e.which || e.keyCode]) == 1); 660} 661// Allows digits and common phone-number formatting characters: ( ) + - . and space. 662// Blocks letters and other symbols. Uses e.key so symbols are detected reliably. 663function acceptPhoneEntryOnly(e) { 664 var key = e.key; 665 if (key === undefined) { 666 // Old-browser fallback: defer to digit-only handling. 667 return acceptNumberEntryOnly(e); 668 } 669 // Allow navigation/editing keys and keyboard shortcuts (copy/paste/select-all). 670 var controlKeys = { 'Backspace': 1, 'Tab': 1, 'Delete': 1, 'Enter': 1, 'ArrowLeft': 1, 'ArrowRight': 1, 'Home': 1, 'End': 1 }; 671 if (controlKeys[key] || e.ctrlKey || e.metaKey) { 672 return true; 673 } 674 return /^[0-9()+\-.\s]$/.test(key); 675} 676// Normalizes a phone input toward the 10 digits the backend requires, without 677// disturbing allowed formatting characters ( ) + - . and space. 678// - If 11 digits are present starting with a leading "1" (US/Canada country 679// code), the leading "1" is dropped so the correct 10-digit number remains. 680// - Otherwise digits past the 10th are dropped. 681// Non-digit characters are left in place. Does not change validation. 682function limitPhoneDigits(el) { 683 if (!el) return; 684 var digits = (el.value.match(/\d/g) || []).join(''); 685 if (digits.length <= 10) return; 686 // 11 digits with a leading country-code "1": drop that first digit. 687 var skipFirstDigit = digits.length === 11 && digits.charAt(0) === '1'; 688 var seen = 0, kept = 0, result = ''; 689 for (var i = 0; i < el.value.length; i++) { 690 var ch = el.value.charAt(i); 691 if (ch >= '0' && ch <= '9') { 692 seen++; 693 if (skipFirstDigit && seen === 1) continue; // drop leading "1" 694 if (kept < 10) { result += ch;
694 kept++; } 695 } else { 696 result += ch; 697 } 698 } 699 el.value = result; 700} 701function denyRepeating(val) { 702 return /^(.)\1+$/.test(val); 703} 704function denyPOBox(val) { 705 return /([P|p]\.[O|o]\.)+([B|b][O|o][X|x])?/.test(val) || /([P|p][O|o])+\s+([B|b][O|o][X|x])/.test(val); 706} 707 708var PageAlertType = { 709 SUCCESS: 0, 710 INFO: 1, 711 WARNING: 2, 712 ERROR: 3, 713 SUCCESS2: 4, 714 ERROR2: 5 715}; 716function showPageAlert(message, pageAlertType, hideAfter) { 717 var className = ""; 718 719 switch (pageAlertType) { 720 case PageAlertType.SUCCESS: 721 className = "success"; 722 break; 723 case PageAlertType.ERROR: 724 className = "error"; 725 break; 726 case PageAlertType.INFO: 727 className = "info"; 728 break; 729 case PageAlertType.SUCCESS2: 730 className = "success2"; 731 break; 732 case PageAlertType.ERROR2: 733 className = "error2"; 734 break; 735 } 736 737 $("#pageAlertText").html(message); 738 $("#pageAlert").hide().removeClass().addClass(className).slideDown("fast").delay(400); 739 if (hideAfter !== null && typeof hideAfter !== "undefined") { 740 setTimeout(function () { 741 hidePageAlert(); 742 }, hideAfter); 743 } 744} 745function hidePageAlert() { 746 $('#pageAlert').fadeOut("fast"); 747} 748 749function numberWithCommasAndNoCents(x) { 750 var y = parseFloat(x); 751 y = y.toFixed(2); 752 var parts = y.toString().split("."); 753 parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); 754 //return parts.join("."); 755 return parts[0]; 756} 757 758function twoDecimalPlacesOnly(element, event) { 759 var value = element.value.split("."); 760 var cents = value[1]; 761 if (typeof cents !== 'undefined' && cents.length > 2) { 762 cents = cents.substr(0, 2); 763 element.value = value[0] + "." + cents; 764 } 765} 766 767function printPage(sURL, query) { 768 if (typeof query !== 'undefined' && query !== null) { 769 var gridSort = query.match(/grid-column=\w+&grid-dir=[01]/); 770 if (gridSort !== null) { 771 if (sURL.indexOf("?") < 0) { 772 sURL = sURL + "?" + gridSort[0]; 773 } else { 774 sURL = sURL + "&" + gridSort[0]; 775 } 776 } 777 } 778 var oHiddFrame = document.createElement("iframe"); 779 oHiddFrame.id = "printFrame"; 780 oHiddFrame.style.visibility = "hidden"; 781 oHiddFrame.style.position = "fixed"; 782 oHiddFrame.style.right = "0"; 783 oHiddFrame.style.bottom = "0"; 784 oHiddFrame.src = sURL; 785 //remove iframe if already exist 786 var oldFrame = document.getElementById("printFrame"); 787 if (oldFrame != null) { oldFrame.remove(); } 788 //insert iframe 789 document.body.appendChild(oHiddFrame); 790} 791 792var Dialogs = Object.freeze({ "ViewDonor": 0, "MatchDonor": 1, "ScanCheck": 2 }); 793 794function openDialog(dialog, url, params, onHide, onDone, onFail) { 795 var divId = ''; 796 switch (dialog) { 797 case Dialogs.ViewDonor: 798 break; 799 case Dialogs.MatchDonor: 800 divId = "#chMSMatchDonor"; 801 break; 802 case Dialogs.ScanCheck: 803 divId = "#ScannedCheckModal"; 804 break; 805 default: 806 break; 807 } 808 if (divId !== '') { 809 var jqxhr = $.get(url, params, function (data) { 810 $(divId).html(data); 811 $(divId).off('hide.bs.modal') 812 .on('hide.bs.modal', function (event) { 813 if (jQuery.isFunction(onHide)) { 814 params['hideEvent'] = { event: event }; 815 onHide(params); 816 } 817 }); 818 $(divId).modal("show"); 819 }).done(function (data, textStatus, jqXHR) { 820 if (jQuery.isFunction(onDone)) { 821 params['doneEvent'] = { data: data, textStatus: textStatus, jqXHR: jqXHR }; 822 onDone(params); 823 } 824 }).fail(function (jqXHR, textStatus, errorThrown) { 825 if (jQuery.isFunction(onFail)) { 826 params['doneEvent'] = { textStatus: textStatus, errorThrown: errorThrown, jqXHR: jqXHR }; 827 onFail(params); 828 } 829 }).always(function () { 830 ; 831 }); 832 } 833}; 834 835const TemplateUtils = { 836 escape: (str) => { 837 if (str === null || str === undefined) return ''; 838 return String(str) 839 .replace(/&/g, '&') 840 .replace(/</g, '<') 841 .replace(/>/g, '>') 842 .replace(/"/g, '"') 843 .replace(/'/g, '''); 844 }, 845 846 formatDate: (date) => { 847 return new moment(date).format("MM/DD/YYYY"); 848 } 849}
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.