PageSourceSearch

https://www.bkquestionnaire.com/assets/js/custom.js?v=08-01-2026-1

js bkquestionnaire.com collected 2026-10-02 00:28:18 UTC 36,657 bytes, 977 lines download raw bytes

1
2var langLbl = {
3    "confirmNameUpdate": "Do you want to update name?",
4    "confirmEmailUpdate": "Do you want to update email?",
5    "confirmRemove": "Do you want to remove",
6    "confirmReset": "Do you want to reset settings",
7    "confirmDelete": "Do you want to delete",
8    "confirmChange": "Do You want to change the status?",
9    "confirmResend": "Do You want to resend Invite?",
10    "processing": "Processing...",
11    "confirmApprove": "Do you want to approve?",
12    "confirmDecline": "Do you want to decline?",
13    "confirmReuploading": "Do you want to enable reuploading?",
14    "confirmUploadCRSReport": "Are you sure you want to run your Credit Report? \nBy selecting yes you are authorizing your attorney to run your credit report and import all of your creditors into the questionnaire.",
15  };
16
17  var siteConstants =  {
18    "webroot": '/',
19    "webroot_traditional": '/',
20    "rewritingEnabled": true
21  };
22
23
24var laws = {
25    ajaxRequestLog: [],
26    logAjaxRequest: function (url, data, res) {
27        var d = (new Date()).getTime();
28        var last = d - 120000;
29        var obj = {url: url,
30            data: (typeof data == "object") ? JSON.stringify(data) : data,
31            res: (typeof res == "object") ? JSON.stringify(res) : res,
32            t: d};
33        var repeatCount = 0;
34        for (var i = laws.ajaxRequestLog.length - 1; i >= 0; i--) {
35            var oldObj = laws.ajaxRequestLog[i];
36            if (oldObj.t < last) {
37                laws.ajaxRequestLog.splice(i, 1);
38                continue;
39            }
40            if (oldObj.url == obj.url && oldObj.data == obj.data && oldObj.res == obj.res) {
41                repeatCount++;
42            }
43        }
44        if (repeatCount >= 10) {
45            if (confirm('This page seems to be stuck with some ajax call loop.\nDo you want to reload the page?')) {
46               location.reload(true);
47            }
48        }
49        laws.ajaxRequestLog.push(obj);
50        console.log('Added log: ' + laws.ajaxRequestLog.length);
51    },
52    ajax: function (url, data, fn, options) {
53        var o = $.extend(true, {fOutMode: 'html', timeout: 300000, maxRetry: 0, retryNumber: 0}, options);
54        if ("string" == $.type(data)) {
55            data += '&fOutMode=' + o.fOutMode + '&fIsAjax=1';
56        }
57        if ("object" == $.type(data)) {
58            var data = $.extend(true, {}, data);
59            if (!data.isAjax)
60                data.fIsAjax = 1;
61            if (!data.fOutMode)
62                data.fOutMode = o.fOutMode;
63        }
64        $.ajax({
65        headers: {
66            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
67            },
68            method: "POST",
69            url: url,
70            data: data,
71            dataType: o.fOutMode,
72            success: function (t) {
73                laws.logAjaxRequest(url, data, t);
74                if (o.fOutMode == 'json') {
75                    if (t.status == -1) {
76                        alert(t.msg);
77                        if (options.errorFn) {
78                            options.errorFn();
79                        }
80                        return;
81                    }
82                }
83                fn(t);
84            },
85            error: function (jqXHR, textStatus, error) {
86                if (textStatus == "parsererror" && jqXHR.statusText == "OK") {
87                    alert('Seems some json error.' + jqXHR.responseText);
88                    if (typeof o.errorFn === 'function') {
89                        o.errorFn(jqXHR, textStatus, error);
90                    }
91                    return;
92                }
93                o.retryNumber++;
94                if (o.retryNumber <= o.maxRetry) {
95                    console.log('Will retry ' + o.retryNumber);
96                    setTimeout(function () {
97                        laws.ajax(url, data, fn, o)
98                    }, 3000);
99                } else if (typeof o.errorFn === 'function') {
100                    o.errorFn(jqXHR, textStatus, error);
101                }
102            },
103            timeout: o.timeout
104        });
105    },
106    updateWithAjax: function (url, data, fn, options) {
107        $.systemMessage(langLbl.processing, 'alert--process alert');
108        var o = $.extend(true, {fOutMode: 'json'}, options);
109        this.ajax(url, data, function (ans) {
110            if (ans.status != 1) {
111                $.systemMessage(ans.msg, 'alert alert--danger');
112                return;
113            }
114            $.systemMessage(ans.msg, 'alert--success');
115            fn(ans);
116        }, o);
117    },
118    camel2dashed: function (str) {
119        return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase();
120    },
121    breakUrl: function (url) {
122        url = url.substring(2000);
123        var arr = url.split('/');
124        var obj = {controller: arr[0], action: '', others: []};
125        arr.shift();
126        if (!arr.length)
127            return obj;
128        obj.action = arr[0];
129        arr.shift();
130        obj.others = arr;
131        return obj;
132    },
133    makeUrl: function (controller, action, others, use_root_url, urlRewritingEnabled) {
134        if (typeof urlRewritingEnabled === 'undefined') {
135            urlRewritingEnabled = (siteConstants.rewritingEnabled == 1);
136        }
137        if (!use_root_url) {
138            use_root_url = (urlRewritingEnabled) ? siteConstants.webroot : siteConstants.webroot_traditional;
139        }
140        var url;
141        if (!controller)
142            controller = '';
143        if (!action)
144            action = '';
145        controller = this.camel2dashed(controller);
146        action = this.camel2dashed(action);
147        if (!others) {
148            others = [];
149        }
150
151        if ('' == action && others.length)
152            action = 'index';
153        url = use_root_url + controller;
154        if ('' != action)
155            url += '/' + action;
156        if (others.length) {
157            for (x in others)
158                others[x] = encodeURIComponent(others[x]);
159            url += '/' + others.join('/');
160        }
161        if (typeof ezcalcToken != 'undefined') {
162            url += '?_token=' + ezcalcToken;
163        }
164        return url;
165    },
166    frmData: function (frm) {
167        return $(frm).serialize();
168    },
169    qStringToObject: function (q) {
170        var args = new Object();
171        var pairs = q.split("&");
172        for (var i = 0; i < pairs.length; i++) {
173            var pos = pairs[i].indexOf('=');
174            if (pos == -1)
175                continue;
176            var argname = pairs[i].substring(0, pos);
177            var value = pairs[i].substring(pos + 1);
178            args[argname] = unescape(value);
179        }
180        return args;
181    },
182    urlWrittenQueryObject: function () {
183        var url = location.pathname;
184        url = url.substring(siteConstants.userWebRoot.length);
185        var arr = url.split('/');
186        if (arr.length <= 2)
187            return {};
188        arr.shift();
189        arr.shift();
190        var obj = {};
191        for (var i = 0; i < arr.length; i += 2) {
192            obj[arr[i]] = arr[i + 1];
193        }
194        return obj;
195    },
196    getLoader: function () {
197        return '<div class="circularLoader loader-Js"><svg width="30" height="30" class="circular"><circle stroke-miterlimit="10" stroke-width="6" fill="none" r="19.9" cy="25.2" cx="25" class="path"/></svg></div>';
198    },
199    displayProcessing: function (msg, cls, autoclose) {
200        if (typeof msg == 'undefined' || msg == 'undefined') {
201            msg = langLbl.processing;
202        }
203        $.systemMessage(msg, 'alert--process', autoclose);
204    },
205    ajaxMultipart: function (url, data, fn, options) {
206        var o = $.extend(true, {fOutMode: 'html', timeout: 300000, maxRetry: 0, retryNumber: 0}, options);
207        if ("object" == $.type(data)) {
208            data.append("fIsAjax", 1);
209            data.append("fOutMode", o.fOutMode);
210        }
211        $.ajax({
212            method: "POST",
213            enctype: 'multipart/form-data',
214            url: url,
215            data: data,
216            dataType: o.fOutMode,
217            processData: false,
218            contentType: false,
219            cache: false,
220            timeout: 300000,
221            success: function (t) {
222                laws.logAjaxRequest(url, data, t);
223                if (o.fOutMode == 'json') {
224                    if (t.status == -1) {
225
226                        if (options.errorFn) {
227                            options.errorFn();
228                        }
229                        return;
230                    }
231                }
232                fn(t);
233            },
234            error: function (jqXHR, textStatus, error) {
235                if (textStatus == "parsererror" && jqXHR.statusText == "OK") {
236                    alert('Seems some json error.' + jqXHR.responseText);
237                    return;
238                }
239                o.retryNumber++;
240                if (o.retryNumber <= o.maxRetry) {
241                    console.log('Will retry ' + o.retryNumber);
242                    setTimeout(function () {
243                        laws.ajax(url, data, fn, o)
244                    }, 3000);
245                } else {
246                    if (!options.errorFn) {
247                        alert(jqXHR.statusText + '\n' + textStatus);
248                    }
249                }
250                console.log("Ajax Request " + url + " error: " + textStatus + " -- " + error);
251                if (options.errorFn) {
252                    options.errorFn();
253                }
254            },
255            timeout: o.timeout
256        });
257    },
258};
259
260$.extend(laws, {
261    getLoader: function() {
262        return '<div class="loader-yk"><div class="loader-yk-inner"></div></div>';
263    },
264
265    scrollToTop: function(obj) {
266        if (typeof obj == undefined || obj == null) {
267            $('html, body').animate({
268                scrollTop: $('html, body').offset().top - 100
269            }, 'slow');
270        } else {
271            $('html, body').animate({
272                scrollTop: $(obj).offset().top - 100
273            }, 'slow');
274        }
275    },
276    resetEditorInstance: function() {
277        if (extendEditorJs == true) {
278            var editors = oUtil.arrEditor;
279            for (x in editors) {
280                eval('delete window.' + editors[x]);
281            }
282            oUtil.arrEditor = [];
283        }
284    },
285
286    resetEditorWidth: function(width = "100%") {
287        if (typeof oUtil != 'undefined') {
288            (oUtil.arrEditor).forEach(function(input) {
289                var oEdit1 = eval(input);
290                $("#idArea" + oEdit1.oName).attr("width", width);
291            });
292        }
293    },
294
295    setEditorLayout: function(lang_id) {
296        if (extendEditorJs == true) {
297            var editors = oUtil.arrEditor;
298            layout = langLbl['language' + lang_id];
299            for (x in editors) {
300                $('#idContent' + editors[x]).contents().find("body").css('direction', layout);
301            }
302        }
303    },
304
305    resetFaceboxHeight: function() {
306        var screenHeight = $(window).height();
307      
308
309         /*$('html').css('overflow','hidden');*/
310        facebocxHeight = screenHeight;
311        var fbContentHeight = parseInt($('#facebox .content').height()) + 150; // Additional height calculation
312    
313        setTimeout(function() {
314            var adjustedHeight = 0.9 * screenHeight; // 90% of screen height
315            $('#facebox .content').css('max-height', '100vh'); // Set max-height
316            
317        }, 700); // Timeout delay for rendering
318        
319        $('#facebox .content').css('overflow-y', 'auto');
320        if (fbContentHeight > screenHeight - parseInt(100)) {
321            $('#facebox .content').css('display', 'block');
322        } else {
323            $('#facebox .content').css('max-height', '');
324        }
325    },
326    updateFaceboxContent: function(t, cls) {
327        if (typeof cls == 'undefined' || cls == 'undefined') {
328            cls = '';
329        }
330        $.facebox(t, cls);
331        $.systemMessage.close();
332        laws.resetFaceboxHeight();
333    },
334
335    /** Client P&L form: Bootstrap modal when #profitLossFormModal exists; else Facebox. */
336    profitLossFormModalIsAvailable: function () {
337        return typeof bootstrap !== 'undefined' && bootstrap.Modal &&
338            document.getElementById('profitLossFormModal') &&
339            document.getElementById('profitLossFormModalContent');
340    },
341    profitLossFormModalSetContentAndShow: function (html, faceboxClass) {
342        if (!laws.profitLossFormModalIsAvailable()) {
343            laws.updateFaceboxContent(html, faceboxClass || 'profitlosspopup-div questions_popup_div');
344            return;
345        }
346        $('#profitLossFormModalContent').html(html);
347        $.systemMessage.close();
348        $(document).trigger('profitLossFormModalContentUpdated');
349        var el = document.getElementById('profitLossFormModal');
350        bootstrap.Modal.getOrCreateInstance(el).show();
351    },
352    profitLossFormModalSetContent: function (html, faceboxClass) {
353        if (!laws.profitLossFormModalIsAvailable()) {
354            laws.updateFaceboxContent(html, faceboxClass || 'profitlosspopup-div');
355            return;
356        }
357        $('#profitLossFormModalContent').html(html);
358        $.systemMessage.close();
359        $(document).trigger('profitLossFormModalContentUpdated');
360    },
361    profitLossFormModalHide: function () {
362        if (!laws.profitLossFormModalIsAvailable()) {
363            if (typeof $ !== 'undefined' && $.facebox && $.facebox.close) {
364                $.facebox.close();
365            }
366            return;
367        }
368        var el = document.getElementById('profitLossFormModal');
369        var inst = typeof bootstrap !== 'undefined' && bootstrap.Modal ? bootstrap.Modal.getInstance(el) : null;
370        if (inst) {
371            inst.hide();
372            return;
373        }
374        if (typeof $ !== 'undefined' && $.facebox && $.facebox.close) {
375            $.facebox.close();
376        }
377    },
378
379    sanitizeOpenFlagPopupHtml: function(html) {
380        if (!html || typeof html !== 'string') {
381            return html || '';
382        }
383        return String(html)
384            .replace(/\$\.facebox\.close\s*\(\s*\)/g, 'closeOpenFlagPopupModal()')
385            .replace(/jQuery\.facebox\.close\s*\(\s*\)/g, 'closeOpenFlagPopupModal()');
386    },
387
388    escapeHtmlOpenFlag: function(s) {
389        if (!s) {
390            return '';
391        }
392        var d = document.createElement('div');
393        d.textContent = s;
394        return d.innerHTML;
395    },
396
397    closeOpenFlagPopupModal: function() {
398        var el = document.getElementById('openFlagPopupModal');
399        if (el && typeof bootstrap !== 'undefined' && bootstrap.Modal) {
400            var inst = bootstrap.Modal.getInstance(el);
401            if (inst) {
402                inst.hide();
403                return;
404            }
405        }
406        if (typeof $ !== 'undefined' && $.facebox && $.facebox.close) {
407            $.facebox.close();
408        }
409    },
410
411    /**
412     * Display openFlagPopup content in Bootstrap 5 modal (fallback to Facebox if modal missing).
413     */
414    showOpenFlagPopupModal: function(bodyInnerHtml, extraClass, options) {
415        options = options || {};
416        var includeradio = options.includeradio !== false;
417        var noText = options.noText;
418        if (noText === undefined || noText === '') {
419            noText = "I do. I just don't know what to put for this item";
420        }
421
422        var modalEl = document.getElementById('openFlagPopupModal');
423        if (!modalEl || typeof bootstrap === 'undefined' || !bootstrap.Modal) {
424            if (typeof laws.updateFaceboxContent === 'function') {
425                var radioAppend = '';
426                if (includeradio) {
427                    radioAppend = '<div class="d-inline radio-primary"><input type="radio" id="popup_yes_fb_fallback" name="popup_yes_no_fb" value="1" class="yes-radio" onclick="if(typeof closeOpenFlagPopupModal===\'function\'){closeOpenFlagPopupModal();}else if(typeof $!==\'undefined\'&&$.facebox){$.facebox.close();}"> <label for="popup_yes_fb_fallback">Yes</label></div><div class="d-inline radio-primary"><input type="radio" id="popup_no_fb_fallback" name="popup_yes_no_fb" value="0" class="no-radio" onclick="if(typeof closeOpenFlagPopupModal===\'function\'){closeOpenFlagPopupModal();}else if(typeof $!==\'undefined\'&&$.facebox){$.facebox.close();}"><label for="popup_no_fb_fallback">' + laws.escapeHtmlOpenFlag(noText) + '</label></div>';
428                }
429                var wrapped = '<div class="sign_up_bgs"><div class="container-fluid"><div class="row py-0 page-flex"><div class="col-md-12 pr-0 pl-0"><div class="form_colm red-flag row p-4"><div class="col-md-12 main-div"><div class="row"><div class="col-md-12"><div class="align-left">' +
430                    (bodyInnerHtml || '') + radioAppend +
431                    '</div></div></div></div></div></div></div></div></div>';
432                laws.updateFaceboxContent(wrapped, (extraClass || '').trim());
433            }
434            return;
435        }
436
437        var dialogEl = modalEl.querySelector('.open-flag-popup-modal-dialog');
438        var bodyEl = modalEl.querySelector('.open-flag-popup-modal-body');
439        var footerEl = modalEl.querySelector('.open-flag-popup-modal-footer');
440        var titleEl = modalEl.querySelector('#openFlagPopupModalLabel');
441        if (!dialogEl || !bodyEl || !footerEl) {
442            return;
443        }
444
445        var baseDialogClass = 'modal-dialog modal-lg modal-dialog-scrollable open-flag-popup-modal-dialog';
446        dialogEl.className = baseDialogClass + (extraClass ? ' ' + extraClass.trim() : '');
447
448        modalEl.classList.toggle('open-flag-popup--confirm', !!includeradio);
449
450        if (titleEl) {
451            titleEl.textContent = includeradio ? 'Please confirm' : 'Information';
452        }
453
454        var iconInner = modalEl.querySelector('.open-flag-popup-header-icon i');
455        if (iconInner) {
456            iconInner.className = 'bi ' + (includeradio ? 'bi-exclamation-triangle-fill' : 'bi-info-circle-fill');
457        }
458
459        var sanitized = laws.sanitizeOpenFlagPopupHtml(bodyInnerHtml || '');
460        var bodyWrap = '<div class="resend-reminder-popup-card open-flag-popup-dynamic-card mb-0"><div class="open-flag-popup-dynamic-content align-left">' + sanitized + '</div></div>';
461        bodyEl.innerHTML = bodyWrap;
462
463        if (includeradio) {
464            footerEl.classList.remove('d-none');
465            footerEl.innerHTML =
466                '<button type="button" class="btn resend-reminder-popup-btn-submit invite-client-popup-btn-submit-green mb-0 me-2">' + laws.escapeHtmlOpenFlag('Yes') + '</button>' +
467                '<button type="button" class="btn resend-reminder-popup-btn-back mb-0">' + laws.escapeHtmlOpenFlag(noText) + '</button>';
468            footerEl.querySelectorAll('button').forEach(function(btn
468) {
469                btn.addEventListener('click', function() {
470                    laws.closeOpenFlagPopupModal();
471                });
472            });
473        } else {
474            footerEl.classList.add('d-none');
475            footerEl.innerHTML = '';
476        }
477
478        if (typeof $ !== 'undefined' && $.systemMessage && typeof $.systemMessage.close === 'function') {
479            $.systemMessage.close();
480        }
481        bootstrap.Modal.getOrCreateInstance(modalEl).show();
482    },
483
484    openFlagPopup: function(divclass, noText, includeradio, attorneyEdit, loadnAjax, ajaxurl, clientId) {
485        if (divclass == 'no-popup') {
486            return;
487        }
488        if (typeof noText === 'undefined') {
489            noText = '';
490        }
491        if (typeof includeradio === 'undefined') {
492            includeradio = true;
493        }
494        if (typeof attorneyEdit === 'undefined') {
495            attorneyEdit = false;
496        }
497        if (typeof loadnAjax === 'undefined') {
498            loadnAjax = false;
499        }
500        if (typeof ajaxurl === 'undefined') {
501            ajaxurl = '';
502        }
503        if (typeof clientId === 'undefined') {
504            clientId = '';
505        }
506
507        var extraClass = '';
508        var dc = divclass;
509        if (dc == 'Auto_Insurance_Documents' || dc == 'venmo-statement-popup' || dc == 'paypal-statement-popup' || dc == 'cash-statement-popup' || dc == 'credit-report-popup' || dc == 'apple-pay-statement-popup' || (typeof dc === 'string' && dc.indexOf('gig-work-how-popup-') === 0)) {
510            extraClass = 'video-popup-div';
511        }
512        if (dc == 'no-profit-loss-popup') {
513            extraClass = 'no-profit-loss-popup-div';
514        }
515        if (dc == 'primary-residence-popup') {
516            extraClass = 'item-index-' + noText;
517            noText = '';
518        }
519
520        if (loadnAjax == true) {
521            // Document guide path (load_guide_doc) — unchanged
522            laws.ajax(ajaxurl, { divclass: divclass, clientId: clientId }, function(response) {
523                var res = JSON.parse(response);
524                if (res.status == 0) {
525                    $.systemMessage(res.msg, 'alert--danger', true);
526                } else {
527                    laws.showOpenFlagPopupModal(res.html || '', 'help-popup productQuickView quickinfor ' + extraClass, { includeradio: false });
528                }
529            });
530            return;
531        }
532
533        if (noText == '') {
534            noText = "I do. I just don't know what to put for this item";
535        }
536
537        var flagUrl = window.__flagPopupContentUrl || null;
538        if (!flagUrl) {
539            // Fallback: read from hidden DOM element when route URL is not available
540            var domHtml = $('.' + divclass).html() || '';
541            laws.showOpenFlagPopupModal(domHtml, 'help-popup productQuickView quickinfor ' + extraClass, { includeradio: !!includeradio, noText: noText });
542            return;
543        }
544
545        laws.ajax(flagUrl, { divclass: divclass }, function(response) {
546            var res = JSON.parse(response);
547            if (res.status == 0) {
548                // Graceful fallback to DOM if key not in service yet
549                var domHtml = $('.' + divclass).html() || '';
550                laws.showOpenFlagPopupModal(domHtml, 'help-popup productQuickView quickinfor ' + extraClass, { includeradio: !!includeradio, noText: noText });
551            } else {
552                laws.showOpenFlagPopupModal(res.html || '', 'help-popup productQuickView quickinfor ' + extraClass, { includeradio: !!includeradio, noText: noText });
553            }
554        });
555    },
556});
557
558(function() {
559    if (typeof window === 'undefined') {
560        return;
561    }
562    window.closeOpenFlagPopupModal = function() {
563        laws.closeOpenFlagPopupModal();
564    };
565    window.openFlagPopup = function() {
566        return laws.openFlagPopup.apply(laws, arguments);
567    };
568
569    /**
570     * Context-neutral wrappers for primary-residence-popup action buttons.
571     * The popup HTML (served from FlagPopupContentService) always calls these;
572     * they delegate to whichever context-specific function is available on the page.
573     */
574    window.flagPopupEditPreviousProperty = function(el) {
575        if (typeof editPreviousPropertyIntake === 'function')          { editPreviousPropertyIntake(el); return; }
576        if (typeof editPreviousPropertyQuestionnaire === 'function')   { editPreviousPropertyQuestionnaire(el); return; }
577        if (typeof editPreviousProperty === 'function')                { editPreviousProperty(el); return; }
578    };
579    window.flagPopupConvertToNonPrimary = function(el) {
580        if (typeof convertToNonPrimaryIntake === 'function')           { convertToNonPrimaryIntake(el); return; }
581        if (typeof convertToNonPrimaryQuestionnaire === 'function')    { convertToNonPrimaryQuestionnaire(el); return; }
582        if (typeof convertToNonPrimary === 'function')                 { convertToNonPrimary(el); return; }
583    };
584})();
585
586$(document).bind('reveal.facebox', function() {
587    laws.resetFaceboxHeight();
588});
589
590$(window).on("orientationchange", function() {
591    laws.resetFaceboxHeight();
592});
593
594$(document).bind('loading.facebox', function() {
595    $('#facebox .content').addClass('fbminwidth');
596});
597
598$(document).bind('afterClose.facebox', function() {
599    $('html').css('overflow', '');
600});
601
602/* $(document).bind('afterClose.facebox', laws.resetEditorInstance); */
603$(document).bind('beforeReveal.facebox', function() {
604    $('#facebox .content').addClass('fbminwidth');
605    $('html').css('overflow', '')
606});
607
608$(document).bind('reveal.facebox', function() {
609    $('#facebox .content').addClass('fbminwidth');
610});
611
612
613
614$.systemMessage = function (message, alertType, autoClose) {
615    $('.alert').removeClass('alert--success');
616    $('.alert').removeClass('alert--danger');
617    $('.alert').removeClass('alert--process');
618    $('.alert').removeClass('alert--info');
619    $('.alert').addClass((typeof alertType == 'undefined' || alertType == 'undefined') ? 'alert--info' : alertType);
620    $('.alert .sysmsgcontent').html(message);
621    $('.alert').fadeIn();
622    if (typeof autoClose != 'undefined' && autoClose != 'undefined' && autoClose != false) {
623        const messageEl = document.querySelector('.custom_alerting.sysmsgcontent');
624
625    // Get the text content
626    const text = messageEl?.textContent || '';
627    
628    // Count the number of words
629    const wordCount = text.trim().split(/\s+/).length;
630    const wordsPerSecond = 3.5; // moderate pace
631    const bufferSeconds = 2;
632    const timeout = wordCount > 0 ? (Math.ceil((wordCount / wordsPerSecond) + bufferSeconds) * 1000) : 3000; // in milliseconds
633    if(wordCount>2){
634       setTimeout(function () {
635            $(document).trigger('close.sysmsgcontent');
636        }, timeout);
637    }else{
638            setTimeout(function () {
639                $(document).trigger('close.sysmsgcontent');
640            }, 2000); 
641        }
642    }
643    
644};
645$.extend($.systemMessage, {
646    settings: {
647        closeimage: 'images/facebox/close.gif',
648    },
649    initialize: function () {
650        $('.alert .close').click($.systemMessage.close());
651    },
652    loading: function () {
653        $('.alert').show();
654    },
655    fillSysMessage: function (data, cls, autoClose) {
656        $('.alert').removeClass('alert--success');
657        $('.alert').removeClass('alert--danger');
658        $('.alert').removeClass('alert--process');
659        if (cls) {
660            $('.alert').addClass(cls);
661        }
662
663        $('.alert .sysmsgcontent').html(data);
664        $('.alert').fadeIn();
665
666        if (autoClose) {
667            setTimeout(function () {
668                $.systemMessage.close();
669            }, 50000000);
670        }
671    },
672    close: function () {
673        $(document).trigger('close.sysmsgcontent');
674    },
675});
676function initialize() {
677
678    $('.alert .close').click($.systemMessage.close);
679}
680$(document).on('click', '.close', function () {
681
682    $(document).trigger('close.sysmsgcontent');
683});
684$(document).bind('close.sysmsgcontent', function () {
685
686    $('.alert').fadeOut();
687});
688
689$(document).on('click', '.close', function () {
690
691    $(document).trigger('close.sysmsgcontent');
692});
693function isJson(str) {
694    try {
695        JSON.parse(str);
696    } catch (e) {
697        return false;
698    }
699    return true
700}
701$(document).ready(function(){
702$(document).on("keyup", ".phone-number-field", function(evt) {
703
704
705    var self = $(this);
706    self.val(self.val().replace(/[^0-9\.]/g, ''));
707    self.val(self.val().replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'$1-$2-$3'))
708    var first10 = $(this).val().substring(0, 12);
709    if (this.value.length > 12) {
710        this.value = first10;
711    }
712
713
714});
715$(document).on("change", ".convert-text-for-other", function(e) {
716    if ($(this).val() == "-1") {
717       $(this).next("div.other_income").removeClass("hide-data");
718    }else{
719        $(this).next("div.other_income").addClass("hide-data");
720    }
721});
722
723$(document).ready(function () {
724    $('.paystub-additional-date').on('change', function () {
725        var $input = $(this);
726        var enteredDate = new Date($input.val());
727        var startDate = new Date($input.data('startdate'));
728        var endDate = new Date($input.data('enddate'));
729        var $formGroup = $input.closest('.form-group');
730
731        // Remove existing error message
732        $formGroup.next('.date-error-msg').remove();
733
734        if (isNaN(enteredDate)) {
735            showError("Please enter a valid date.");
736            $input.val('');
737            return;
738        }
739
740        if (enteredDate < startDate || enteredDate > endDate) {
741            showError(`Please enter Pay Stub date between ${$input.data('startdate')} & ${$input.data('enddate')}.`);
742            $input.val('');
743        }
744
745        function showError(message) {
746            $('<div class="date-error-msg text-danger mt-1"><small class="fw-600">' + message + '</small></div>').insertAfter($formGroup);
747        }
748    });
749});
750
751});
752
753function _injectPurchaseIntoAddonModal(ajaxurl, requestData, responseFilter) {
754  var $addonModal = $('.popup-addon-features.modal.show');
755  if (!$addonModal.length) return false;
756  var $content = $addonModal.find('.addon-popup-content').first();
757  if (!$content.length) return false;
758  if (!$content.data('addon-content-saved')) {
759    $content.data('addon-content-saved', $content.html());
760  }
761  laws.ajax(ajaxurl, requestData, function (response) {
762    if (typeof responseFilter === 'function' && responseFilter(response)) return;
763    $content.html(response);
764    $content.find('script').each(function () {
765      var el = this;
766      if (el.src) return;
767      try { $.globalEval(el.textContent || el.innerText || ''); } catch (e) {}
768    });
769    $addonModal.find('.btn-back-to-addons').off('click.addonRestore').on('click.addonRestore', function () {
770      var saved = $content.data('addon-content-saved');
771      if (saved) $content.html(saved);
772    });
773  });
774  return true;
775}
776
777/* When Additional Add-On Features popup opens, uncheck all checkboxes (except disabled "Included"/"N/A" display state) */
778$(document).on('show.bs.modal', '.popup-addon-features', function () {
779  $(this).find('input[type="checkbox"]:not(:disabled)').prop('checked', false);
780});
781
782/* When Add-On modal is closed without clicking Back, restore packages list so next open shows it */
783$(document).on('hidden.bs.modal', '.popup-addon-features', function () {
784  var $content = $(this).find('.addon-popup-content').first();
785  var saved = $content.data('addon-content-saved');
786  if (saved) {
787    $content.html(saved);
788  }
789});
790
791packagePurchasePopup = function(ptype, client_id, ajaxurl ){
792  if (_injectPurchaseIntoAddonModal(ajaxurl, { client_id: client_id, type: ptype })) return;
793  laws.ajax(ajaxurl, { client_id:client_id,type:ptype}, function (response) {
794    laws.updateFaceboxContent(response,'large-fb-width');
795  });
796}
797
798payrollPurchasePopup = function(payroll_type,client_id,ajaxurl){
799  if (_injectPurchaseIntoAddonModal(ajaxurl, { client_id: client_id, type: payroll_type })) return;
800  laws.ajax(ajaxurl, { client_id:client_id,type:payroll_type}, function (response) {
801    laws.updateFaceboxContent(response,'large-fb-width bg-unset add-on-info-modal');
802  });
803}
804
805servicePurchase = function(subscription_type,client_id,ajaxurl){
806  var handled = _injectPurchaseIntoAddonModal(ajaxurl, { client_id: client_id, type: subscription_type }, function (response) {
807    if (!isJson(response)) return false;
808    var res = JSON.parse(response);
809    if (res.status == 0) {
810      $.systemMessage(res.msg, 'alert--danger', true);
811    } else if (res.status == 1) {
812      $.systemMessage(res.msg, 'alert--success', true);
813      setTimeout(function() { location.reload(true); }, 1000);
814    }
815    return true;
816  });
817  if (handled) return;
818  laws.ajax(ajaxurl, { client_id:client_id,type:subscription_type}, function (response) {
819    if(isJson(response)){
820      var res = JSON.parse(response);
821      if (res.status == 0) {
822        $.systemMessage(res.msg, 'alert--danger', true);
823      } else if(res.status == 1){
824        $.systemMessage(res.msg, 'alert--success', true);
825        setTimeout(function() {
826          location.reload(true);
827        }, 1000);
828      }
829    } else {
830      laws.updateFaceboxContent(response,'large-fb-width');
831    }
832  });
833}
834
835
836
837  function copytoclip() {
838    // Get the text field
839    var copyText = document.getElementById("myInput");
840  
841    // Select the text field
842    copyText.select();
843    copyText.setSelectionRange(0, 99999); // For mobile devices
844  
845    // Copy the text inside the text field
846    navigator.clipboard.writeText(copyText.value);
847    
848    // Alert the copied text
849    alert("Copied the text: " + copyText.value);
850  }
851
852  function loginEye(){
853
854
855  const togglePassword = document.querySelector('#togglePassword');
856  const password = document.querySelector('#password');
857
858  if (!togglePassword || !password) {
859    return;
860  }
861
862  togglePassword.addEventListener('click', function (e) {
863    // toggle the type attribute
864    const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
865    password.setAttribute('type', type);
866    // toggle the eye slash icon
867    this.classList.toggle('fa-eye-slash');
868});
869
870}
871
872function showConfirmation(message, callback) {
873    $('#customConfirm').remove();
874
875    const modalHtml = `
876        <div id="customConfirm" class="bk-custom-confirm" role="dialog" aria-modal="true">
877            <div class="bk-custom-confirm__dialog">
878                <p class="bk-custom-confirm__message">${message}</p>
879                <div class="bk-custom-confirm__actions">
880                    <button type="button" id="confirmYes" class="btn-new-ui-default">Yes</button>
881                    <button type="button" id="confirmNo" class="btn-new-ui-default">No</button>
882                </div>
883            </div>
884        </div>
885    `;
886
887    $('body').append(modalHtml);
888
889    $('#confirmYes').on('click', function() {
890        $('#customConfirm').remove();
891        callback(true);
892    });
893
894    $('#confirmNo').on('click', function() {
895        $('#customConfirm').remove();
896        callback(false);
897    });
898}
899
900
901function showProfitLossConfirmation(callback, options = {}) {
902    var requireBusinessName = options.requireBusinessName === true;
903    var businessName = typeof options.businessName === 'string' ? options.businessName : '';
904    var $modal = $('#profitLossConfirmModal');
905
906    if (!$modal.length || typeof bootstrap === 'undefined' || !bootstrap.Modal) {
907        console.warn('showProfitLossConfirmation: #profitLossConfirmModal or Bootstrap Modal not available.');
908        return;
909    }
910
911    var modalEl = $modal[0];
912    var bsModal = bootstrap.Modal.getOrCreateInstance(modalEl);
913    var dismissedByActionButton = false;
914    /* Yes: run callback only after modal is fully hidden so Facebox P&L is not blocked by Bootstrap backdrop/z-index */
915    var pendingYes = false;
916    var pendingYesName = '';
917
918    $('#plConfirmBusinessNameInput').val(businessName);
919    $('#plConfirmBusinessNameError').hide();
920    if (requireBusinessName) {
921        $('#plConfirmBusinessNameWrapper').show();
922    } else {
923        $('#plConfirmBusinessNameWrapper').hide();
924    }
925
926    $modal.off('hidden.bs.modal.plConfirm');
927    $('#plConfirmYes').off('click.plConfirm');
928    $('#plConfirmNo').off('click.plConfirm');
929
930    $modal.on('hidden.bs.modal.plConfirm', function () {
931        if (pendingYes) {
932            pendingYes = false;
933            callback(true, pendingYesName);
934        } else if (!dismissedByActionButton) {
935            callback(null, businessName);
936        }
937        dismissedByActionButton = false;
938        $modal.off('hidden.bs.modal.plConfirm');
939    });
940
941    $('#plConfirmYes').on('click.plConfirm', function () {
942        var currentBusinessName = $('#plConfirmBusinessNameInput').val();
943        var trimmedBusinessName = currentBusinessName ? currentBusinessName.trim() : '';
944        $('#plConfirmBusinessNameError').hide();
945        dismissedByActionButton = true;
946        pendingYes = true;
947        pendingYesName = trimmedBusinessName || businessName;
948        bsModal.hide();
949    });
950
951    $('#plConfirmNo').on('click.plConfirm', function () {
952        var currentBusinessName = $('#plConfirmBusinessNameInput').val();
953        var trimmedBusinessName = currentBusinessName ? currentBusinessName.trim() : '';
954        if (requireBusinessName && !trimmedBusinessName) {
955            $('#plConfirmBusinessNameWrapper').show();
956            $('#plConfirmBusinessNameError').show();
957            $('#plConfirmBusinessNameInput').focus();
958            return;
959        }
960        dismissedByActionButton = true;
961        callback(false, trimmedBusinessName || businessName);
962        bsModal.hide();
963    });
964
965    bsModal.show();
966}
967
968// Reuse the existing success modal as-is (no text overrides)
969// Safe to call from anywhere after the page loads
970window.showSuccessModal = function () {
971    try {
972        $('#successModal').modal('show');
973    } catch (e) {
974        console.error('showSuccessModal error:', e);
975    }
976};
977

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.