PageSourceSearch

http://www.olmakscars.com/wp-content/mu-plugins/dws-forms/js/dws-forms-script_ver-240604.js

js olmakscars.com collected 2026-10-04 17:08:11 UTC 37,059 bytes, 617 lines download raw bytes

1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4    return new (P || (P = Promise))(function (resolve, reject) {
5        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8        step((generator = generator.apply(thisArg, _arguments || [])).next());
9    });
10};
11var DealerCenter;
12(function (DealerCenter) {
13    var WebSite;
14    (function (WebSite) {
15        var Plugins;
16        (function (Plugins) {
17            class DWSFormsScript {
18                /**
19                 * Initialize class
20                 * @param form
21                 * @returns {}
22                 */
23                constructor(form) {
24                    var $ = jQuery;
25                    // set form property
26                    this.form = form;
27                    this.formThankYouMessage = jQuery('#' + form.attr('id') + '-thank-you-message');
28                    this.formErrorMessageWrapper = form.find('.dws-forms-error-wrapper');
29                    this.formValidationErrorMessageWrapper = form.find('.dws-forms-validation-error-wrapper');
30                    console.log('DWSFormsScript constructor: ' + this.form.attr('id'));
31                    // initialize form
32                    this.initForm();
33                }
34                /**
35                 * Initialize form
36                 * @param form
37                 * @returns {}
38                 */
39                initForm() {
40                    var $ = jQuery;
41                    var form = this.form;
42                    // check if form has data, if not, set to empty object
43                    if (!form.data('form-data')) {
44                        form.data('form-data', {});
45                    }
46                    // check if form.data('form-data').session.applicantCid is set, if not, set to current user cid cookie
47                    if (!form.data('form-data').session || !form.data('form-data').session.applicantCid) {
48                        // set applicantCid in form-data object to current user cid cookie
49                        form.data('form-data').session.applicantCid = DWSFormsScript.getCookie('cid');
50                    }
51                    // check if form.data('form-data').session.applicantSid is set, if not, set to current user sid cookie
52                    if (!form.data('form-data').session || !form.data('form-data').session.applicantSid) {
53                        // set applicantSid in form-data object to current user sid cookie
54                        form.data('form-data').session.applicantSid = DWSFormsScript.getCookie('sid');
55                    }
56                    // console log form data
57                    console.log(form.data('form-data'));
58                    // initialize file upload plugin
59                    var hasFileAttachmentsSection = form.find('.dws-forms-section-file-attachments').length > 0;
60                    if (hasFileAttachmentsSection) {
61                        var uploadPlugin = new DealerCenter.WebSite.Plugins.DWSFormsScriptMulipleFileAttachments(form);
62                        uploadPlugin.init();
63                    }
64                    var coverLetterFile = document.querySelector('#dws-forms-cover-letter-file-input');
65                    // get cover letter file type
66                    if (coverLetterFile) {
67                        coverLetterFile.addEventListener('change', (e) => {
68                            // Get the selected file
69                            const file = e.target.files[0];
70                            // check the file type if its docx or pdf
71                            const fileType = file.type;
72                            const validFileTypes = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
73                            if (!validFileTypes.includes(fileType)) {
74                                // set input file type to invali
74d
75                                // set text to invalid-feedback
76                                coverLetterFile.nextElementSibling.textContent = 'File Type Not Supported. Supported file types are .docx, .pdf';
77                                coverLetterFile.setCustomValidity('File Type Not Supported. Supported file types are .docx, .pdf');
78                                coverLetterFile.reportValidity();
79                            }
80                            else {
81                                coverLetterFile.setCustomValidity('');
82                                coverLetterFile.reportValidity();
83                            }
84                        });
85                    }
86                    // set function on click of submit button
87                    form.find('.dws-forms-button-submit').on('click', (event) => __awaiter(this, void 0, void 0, function* () {
88                        // cancel click
89                        event.preventDefault();
90                        console.log('submit button clicked');
91                        // hide error message wrapper
92                        this.formErrorMessageWrapper.hide();
93                        // hide validation error message wrapper
94                        this.formValidationErrorMessageWrapper.hide();
95                        try {
96                            var submitBtn = form.find('.dws-forms-button-submit');
97                            // disable submit button
98                            this.setLoadingBtn(submitBtn);
99                            // check and mark fields with invalid pseudo class
100                            let countInvalidFields = yield this.markInvalidFormFields();
101                            // if there are invalid fields, then show error message and return
102                            if (countInvalidFields > 0) {
103                                console.log('invalid field input found.');
104                                this.showSubmissionValidationErrorMessage();
105                                return;
106                            }
107                            else {
108                                // map form fields to form-data object
109                                yield this.mapFormFields();
110                                // set reCAPTCHA token in form-data object
111                                yield this.setReCaptchaToken();
112                                // get CSRF token
113                                let csrfToken = yield this.getCsrfToken();
114                                if (!form.data('form-data').isThirdParty) {
115                                    // set referer and traffic source from cookies
116                                    this.setRefererAndTrafficSource();
117                                }
118                                // trigger file upload if there are files to upload
119                                yield this.uploadFiles(hasFileAttachmentsSection, uploadPlugin, csrfToken);
120                                // do submit form process
121                                let submitResult = yield this.submitForm(csrfToken);
122                                // if submitResult statusCode is OK, then hide form, reset fields and show formThankYouMessage
123                                if (('statusCode' in submitResult) && (submitResult.statusCode == 'OK')) {
124                                    // show thank you message
125                                    this.showThankYouMessage();
126                                    // check if testimonial form, then store testimonial to DWS admin
127                                    var formData = form.data('form-data');
128                                    if (formData.inquiryType == 14 && formData.secondaryInquiryType == null) {
129                                        // initialize testimonial functionality class
130                                        var testimonialFunctionality = new DealerCenter.WebSite.Plugins.DWSFormsTestimonialsFunctionality(formData);
131                                        // store testimonial to DWS admin
132                                        testimonialFunctionality.store_testimonial_to_dws_admin();
133                                    }
134                                }
135                            }
136                        }
137                        catch (e) {
138                            console.error(e);
139                            console.log('submit process failed.');
140                            // show error message
141                            this.showSubmissionErrorMessage();
142                        }
143                        finally {
144                            // enable submit button
145                            this.setLoadingBtn(submitBtn, false);
146                        }
147                    }));
148                }
149                /**
150                 * Method to get and set referer and traffic source from cookies
151                 */
152                setRefererAndTrafficSource() {
153                    console.log('setting referer and traffic source...');
154                    var form = this.form;
155                    // get referer and traffic source from cookies
156                    var referer = '';
157                    var trafficSource = decodeURIComponent(DWSFormsScript.getCookie('dws-trs'));
158                    if (trafficSource != '') {
159                        var trafficSourceObj = JSON.parse(trafficSource);
160                        referer = trafficSourceObj.RF;
161                    }
162                    var trafficSourceFromScript = decodeURIComponent(DWSFormsScript.getCookie('dws-ts-js'));
163                    if ((form.data('form-data').inquiryType == 28 && form.data('form-data').secondaryInquiryType == 'RequestMileage') ||
164                        (form.data('form-data').inquiryType == 29 && form.data('form-data').secondaryInquiryType == 'RequestPrice') ||
165                        (form.data('form-data').inquiryType == 26 && form.data('form-data').secondaryInquiryType == 'RequestVIN')) {
166                        form.data('form-data').session.referrer = form.data('form-data').session.referrer;
167                    }
168                    else {
169                        form.data('form-data').session.referrer = referer 
169!= '' ? referer : null;
170                    }
171                    form.data('form-data').session.sourceMedian = trafficSourceFromScript != '' ? trafficSourceFromScript : null;
172                }
173                /**
174                 * Method to upload files
175                 * @param hasFileAttachmentsSection
176                 * @param uploadPlugin
177                 * @param csrfToken
178                 * @returns {Promise<void>}
179                 */
180                uploadFiles(hasFileAttachmentsSection, uploadPlugin, csrfToken) {
181                    var $ = jQuery;
182                    var form = this.form;
183                    console.log('checking if files need to be uploaded...');
184                    // check if form has file attachments section
185                    if (hasFileAttachmentsSection) {
186                        // check if there are files to upload
187                        if (form.find('#total-file-count-pending-upload').length > 0 && parseInt(form.find('#total-file-count-pending-upload').val()) > 0) {
188                            // trigger file upload
189                            return new Promise((resolve, reject) => {
190                                console.log('triggering file upload...');
191                                form.find('#dws-trigger-click-upload').trigger("click", [{ token: csrfToken }]);
192                                if (form.find('#total-file-successfully-uploaded').length > 0 && parseInt(form.find('#total-file-successfully-uploaded').val()) > 0) {
193                                    uploadPlugin.addFilesToPayload();
194                                }
195                                resolve();
196                            });
197                        }
198                    }
199                    return new Promise((resolve, reject) => {
200                        resolve();
201                    });
202                }
203                /**
204                 * Method to submit form to dwsFormsScriptSettings.actionUrl via AJAX POST
205                 * @param csrfToken
206                 *
207                 */
208                submitForm(csrfToken) {
209                    var $ = jQuery;
210                    var ajaxOptions = this.getAjaxOptions();
211                    // submit form via AJAX POST
212                    return new Promise((resolve, reject) => {
213                        $.ajax({
214                            url: ajaxOptions.url,
215                            method: 'POST',
216                            headers: {
217                                'X-CSRF-TOKEN': csrfToken
218                            },
219                            contentType: ajaxOptions.contentType,
220                            processData: ajaxOptions.processData,
221                            data: ajaxOptions.data,
222                            success: (response) => {
223                                if (('success' in response) && (response.success == true)) {
224                                    console.log('form submitted successfully: ' + response.statusCode);
225                                }
226                                else if (('success' in response) && (response.success == false)) {
227                                    this.showSubmissionErrorMessage();
228                                    console.log('form submission failed: ' + response.statusCode);
229                                }
230                                else {
231                                    console.log('form submission failed: ' + response);
232                                    this.showSubmissionErrorMessage();
233                                }
234                                resolve(response);
235                            },
236                            error: (response) => {
237                                console.log('form service error: ' + response.status);
238                                reject(response);
239                            }
240                        });
241                    });
242                }
243                /**
244                 * Method to get AJAX options
245                 * @returns {any}
246                 */
247                getAjaxOptions() {
248                    var $ = jQuery;
249                    var form = this.form;
250                    // get form data
251                    var formData = form.data('form-data');
252                    console.log(formData);
253                    var ajaxOptions = {
254                        url: dwsFormsScriptSettings.actionUrl,
255                        contentType: 'application/json',
256                        processData: true,
257                        data: JSON.stringify(formData)
258                    };
259                    if (formData.inquiryType == 12) { // careers
260                        var career = new DealerCenter.WebSite.Plugins.DWSFormsCareerDataPreProcessing(form);
261                        ajaxOptions.url = dwsFormsScriptSettings.actionUrl + '/careers';
262                        ajaxOptions.contentType = false;
263                        ajaxOptions.processData = false;
264                        ajaxOptions.data = career.getFormData();
265                    }
266                    return ajaxOptions;
267                }
268                /**
269                 * Method to map form fields to form-data object
270                 * @returns {Promise<void>}
271                 */
272                mapFormFields() {
273                    var $ = jQuery;
274                    var form = this.form;
275                    console.log('mapping form fields...');
276                    return new Promise((resolve, reject) => {
277                        // get input fields with dws-forms-form-* class
278                        var fields = form.find('.dws-forms-form-control, .dws-forms-form-file-control, .dws-forms-form-select, .dws-forms-form-radio, .dws-forms-form-checkbox, .dws-forms-form-textarea');
279                        // get value of each field and map to form-data object based on data-form-json-field-map attribute string value
280                        fields.each((index, element) => {
281                            var field = $(element);
282                            var fieldMap = field.data('form-json-field-map');
283                            var fieldSection = field.data('form-section');
284                            if (fieldMap && field.attr('disabled') != 'disabled') {
285                                var value = field.val();
286                                var map = fieldMap.split('.');
287                                var data = form.data('form-data');
288                                for (var i = 0; i < map.length; i++) {
289                                    if (i == map.length - 1) {
290                                        if (value != '') {
291                                            if (field.data('data-type') == 'number') {
292                                                var sanitizedNumericValue = DealerCenter.WebSite.Plugins.DWS_Input_Price_Format.sanitizedMoneyValue(value);
293                                                if ($.isNumeric(sanitizedNumericValue)) {
294                                                    data[map[i]] = parseFloat(sanitizedNumericValue);
295                                                }
296                                            }
297                                            else {
298                                                data[map[i]] = value;
299                                            }
300                                        }
301                                        else {
302                                            delete data[map[i]];
303                                        }
304                                    }
305                                    else {
306                                        if (!data[map[i]]) {
307                                            data[map[i]] = {};
308                                        }
309                                        data = data[map[i]];
310                                    }
311                                }
312                            }
313                            // set data pre processing per section
314                            switch (fieldSection) {
315                                case 'vehicle_information':
316                                    console.log('pre processing vehicle information section...');
317                                    var vehicleInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsVehicleInformationSectionDataPreProcessing(field, form);
318                                    vehicleInformationSectionDataPreProcessing.init();
319                                    break;
320                                case 'survey_information':
321                                    console.log('pre processing survey information section...');
322                                    var surveyInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsSurveyInformationSectionDataPreProcessing(field, form);
323                                    surveyInformationSectionDataPreProcessing.init();
324                                    break;
325                                case 'personal_information':
326                                    console.log('pre processing personal information section...');
327                                    var personalInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsPersonalInformationSectionDataPreProcessing(field, form);
328                                    personalInformationSectionDataPreProcessing.init(
328);
329                                    break;
330                                case 'employment_information':
331                                    console.log('pre processing employment information section...');
332                                    var employmentInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsEmploymentInformationSectionDataPreProcessing(form, field);
333                                    employmentInformationSectionDataPreProcessing.init();
334                                    break;
335                                case 'co_buyer_employment_information':
336                                    console.log('pre processing co buyer employment information section...');
337                                    var coBuyerEmploymentInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsCoBuyerEmploymentInformationSectionDataPreProcessing(field, form);
338                                    coBuyerEmploymentInformationSectionDataPreProcessing.init();
339                                    break;
340                                case 'residential_information':
341                                    console.log('pre processing residential information section...');
342                                    var residentialInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsResidentialInformationSectionDataPreProcessing(form, field);
343                                    residentialInformationSectionDataPreProcessing.init();
344                                    break;
345                                case 'delivery_details':
346                                    console.log('pre processing delivery details section...');
347                                    var deliveryDetailsSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsDeliveryDetailsSectionDataPreProcessing(field, form);
348                                    deliveryDetailsSectionDataPreProcessing.init();
349                                    break;
350                                case 'other_information':
351                                    console.log('pre processing other information section...');
352                                    // check if the class exists in dom
353                                    if (typeof DealerCenter.WebSite.Plugins.DWSFormsOtherInformationSectionDataPreProcessing === 'undefined') {
354                                        break;
355                                    }
356                                    var otherInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsOtherInformationSectionDataPreProcessing(field, form);
357                                    otherInformationSectionDataPreProcessing.init();
358                                    break;
359                                case 'contact_information':
360                                default:
361                                    console.log('pre processing default/contact information section...');
362                                    // check if exists DealerCenter.WebSite.Plugins.DWSFormsContactInformationSectionDataPreProcessing
363                                    if (typeof DealerCenter.WebSite.Plugins.DWSFormsContactInformationSectionDataPreProcessing === 'undefined') {
364                                        break;
365                                    }
366                                    var contactInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsContactInformationSectionDataPreProcessing(field, form);
367                                    contactInformationSectionDataPreProcessing.init();
368                                    break;
369                            }
370                        });
371                        // set data pre processing after per fields
372                        console.log('pre processing after...');
373                        // if inquiry type is credit application
374                        if (form.data('form-data').inquiryType == 1 && !this.form.data('form-data').secondaryInquiryType) { // credit app form
375                            console.log('pre processing credit application...');
376                            var employmentInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsEmploymentInformationSectionDataPreProcessing(form);
377                            var previousAddressSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsPreviousAddressSectionDataPreProcessing(form);
378                            var previousEmploymentSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsPreviousEmploymentSectionDataPreProcessing(form);
379                            var additionalEmploymentInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsAdditionalEmploymentInformationSectionDataPreProcessing(form);
380                            var tradeInSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsTradeInSectionDataPreProcessing(form);
381                            var additionalInfoSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsAdditionalInfoSectionDataPreProcessing(form);
382                            var otherReferencesSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsReferencesSectionDataPreProcessing(form);
383                            var commentAndOthersSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsCommentAndOthersSectionDataPreProcessing(form);
384                            var residentialInformationSectionDataPreProcessing = new DealerCenter.WebSite.Plugins.DWSFormsResidentialInformationSectionDataPreProcessing(form);
385                            residentialInformationSectionDataPreProcessing.setFieldsToComment();
386                            employmentInformationSectionDataPreProcessing.setFieldsToComment();
387                            previousAddressSectionDataPreProcessing.init(
387);
388                            previousEmploymentSectionDataPreProcessing.init();
389                            additionalEmploymentInformationSectionDataPreProcessing.init();
390                            tradeInSectionDataPreProcessing.init();
391                            additionalInfoSectionDataPreProcessing.init();
392                            otherReferencesSectionDataPreProcessing.init();
393                            commentAndOthersSectionDataPreProcessing.init();
394                        }
395                        // remove empty objects from form-data object
396                        this.removeEmptyObjects(form.data('form-data'));
397                        console.log('form fields mapped.');
398                        resolve();
399                    });
400                }
401                /**
402                 * Method to remove empty objects from the object
403                 * @param obj object
404                 */
405                removeEmptyObjects(obj) {
406                    var $ = jQuery;
407                    // for loop on data
408                    for (var key in obj) {
409                        let prop = obj[key];
410                        // check if prop is object
411                        if (typeof prop === 'object') {
412                            // check if prop is empty
413                            if (prop && Object.keys(prop).length === 0 && prop.constructor === Object) {
414                                // delete prop
415                                delete obj[key];
416                            }
417                            else {
418                                // recursive call
419                                this.removeEmptyObjects(prop);
420                            }
421                        }
422                    }
423                }
424                /**
425                 * Method to check and mark invalid form fields identified by browser
426                 * @returns {Promise<void>}
427                 */
428                markInvalidFormFields() {
429                    var $ = jQuery;
430                    var form = this.form;
431                    console.log('getting list of invalid fields...');
432                    var invalidFields = form.find('.dws-forms-form-control:invalid, dws-forms-form-file-control:invalid, .dws-forms-form-select:invalid, .dws-forms-form-radio:invalid, .dws-forms-form-checkbox:invalid, .dws-forms-form-textarea:invalid');
433                    console.log(invalidFields);
434                    return new Promise((resolve, reject) => {
435                        let count = invalidFields.length;
436                        form.addClass('was-validated');
437                        resolve(count);
438                    });
439                }
440                /**
441                 * Method to get CSRF token
442                 * @returns {Promise<string>}
443                 */
444                getCsrfToken() {
445                    var $ = jQuery;
446                    var form = this.form;
447                    // get form data
448                    var formData = form.data('form-data');
449                    console.log('getting csrf token...');
450                    var hostnameUrl = new URL(formData.session.landingUrl);
451                    // get CSRF token via admin-ajax.php call using get_form_token action
452                    return new Promise((resolve, reject) => {
453                        $.ajax({
454                            url: '/wp-admin/admin-ajax.php',
455                            method: 'POST',
456                            data: {
457                                action: 'get_form_token',
458                                form_id: form.attr('id'),
459                                dcCompanyId: formData.dcCompanyId,
460                                hostname: 'https://' + hostnameUrl.hostname,
461                                _wpnonce: jQuery("[name='_wpnonce']", form).val(),
462                                _wp_http_referer: jQuery("[name='_wp_http_referer']", form).val()
463                            },
464                            success: (response) => {
465                                console.log('csrf token received.');
466                                resolve(response);
467                            },
468                            error: (response) => {
469                                console.log('csrf token error: ' + response);
470                                reject(response);
471                            }
472                        });
473                    });
474                }
475                /**
476                 * Method to set form reCAPTCHA token
477                 * @returns {Promise<void>}
478                 */
479                setReCaptchaToken() {
480                    var $ = jQuery;
481                    var form = this.form;
482                    console.log('getting recaptcha token...');
483                    // get grecaptcha token once ready
484                    return new Promise((resolve, reject) => {
485                        grecaptcha.enterprise.ready(() => __awaiter(this, void 0, void 0, function* () {
486                            try {
487                                // get grecaptcha token
488                                const grecaptchaToken = yield grecaptcha.enterprise.execute(dwsFormsScriptSettings.greCaptchaSiteKey, { action: 'submitform' });
489                                // set grecaptcha token in form-data object
490                                form.data('form-data').reCaptcha = grecaptchaToken;
491                                console.log('recaptcha token received and set in form.');
492                                resolve();
493                            }
494                            catch (e) {
495                                console.log(e);
496                                reject();
497                            }
498                        }));
499                    });
500                }
501                /**
502                 * Method to show thank you message
503                 */
504                showThankYouMessage() {
505                    var $ = jQuery;
506                    var form = this.form;
507                    console.log('showing thank you message...');
508                    // hide the form
509                    form.hide();
510                    // reset the form fields
511                    form.trigger("reset");
512                    // show the thank you message
513                    this.formThankYouMessage.show();
514                    // modal on shown 
515                    form.closest('.modal').on('hidden.bs.modal', function (e) {
516                        // reset the form fields
517                        form.trigger("reset");
518                        // show the form
519                        form.show();
520                        // remove was-validated class
521                        form.removeClass('was-validated');
522                        // clear form data applicant
523                        // form.data('form-data').applicant = {};
524                        // hide the thank you message
525                        // note could not use this.formThankYouMessage.hide() because this is not the same this as the one in the submit button click event
526                        $('#' + form.attr('id') + '-thank-you-message').hide();
527                    });
528                }
529                /**
530                 * Method to show submission error message
531                 */
532                showSubmissionErrorMessage() {
533                    var $ = jQuery;
534                    var form = this.form;
535                    console.log('showing submission error message...');
536                    // show error message wrapper
537                    this.formErrorMessageWrapper.show();
538                }
539                /**
540                 * Method to show submission error message
541                 */
542                showSubmissionValidationErrorMessage() {
543                    var $ = jQuery;
544                    var form = this.form;
545                    console.log('showing submission validation error message...');
546                    // show error message wrapper
547                    this.formValidationErrorMessageWrapper.show();
548                }
549                /**
550                 * Method to get cookie value
551                 * @param cookieName
552                 * @returns {string}
553                 */
554                static getCookie(cookieName) {
555                    var nameWithEqual = cookieName + '=';
556                    var cookieStrings = document.cookie.split(';');
557                    for (var i = 0; i < cookieStrings.length; i++) {
558                        var cookieString = cookieStrings[i];
559                        while (cookieString.charAt(0) == ' ') {
560                            cookieString = cookieString.substring(1);
561                        }
562                        if (cookieString.indexOf(nameWithEqual) == 0) {
563                            return cookieString.substring(nameWithEqual.length, cookieString.length);
564                        }
565                    }
566                    return '';
567                }
568                setLoadingBtn(btn, isLoading = true) {
569                    if (!btn.length) {
570                        return;
571                    }
572                    var btnLabel = btn.find('.dws-forms-button-submit-label');
573                    var btnSpinner = btn.find('.spinner-border');
574                    if (isLoading) {
575                        btn.prop('disabled', true);
576                        btnLabel.hide();
577                        btnSpinner.show();
578                    }
579                    else {
580                        btn.prop('disabled', false);
581                        btnLabel.show();
582                        btnSpinner.hide();
583                    }
584                }
585                /**
586                   * static function to get form markup via AJAX POST to get_dws_forms action
587                   */
588                static getFormMarkup(formId, vehicleStockNumber, themeColor) {
589                    var $ = jQuery;
590                    console.log('getting form markup...' + formId);
591                    // get form markup via admin-ajax.php call using get_dws_forms action
592                    return new Promise((resolve, reject) => {
593                        $.ajax({
594                            url: '/wp-admin/admin-ajax.php',
595                            method: 'POST',
596                            data: {
597                                action: 'get_dws_forms',
598                                form_id: formId,
599                                vehicle_stock_number: vehicleStockNumber,
600                                theme_color: themeColor,
601                            },
602                            success: (response) => {
603                                console.log('form markup received.');
604                                resolve(response);
605                            },
606                            error: (response) => {
607                                console.log('form markup error: ' + response);
608                                reject(response);
609                            }
610                        });
611                    });
612                }
613            }
614            Plugins.DWSFormsScript = DWSFormsScript;
615        })(Plugins = WebSite.Plugins || (WebSite.Plugins = {}));
616    })(WebSite = DealerCenter.WebSite || (DealerCenter.WebSite = {}));
617})(DealerCenter || (DealerCenter = {}));

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.