PageSourceSearch

https://form.edupia.vn/media/js/mautic-form-src.js?v=20200325

js edupia.vn collected 2026-10-01 13:14:04 UTC 52,724 bytes, 1,179 lines download raw bytes

1(function (window) {
2    'use strict';
3
4    function define_library() {
5        //Core library
6        var Core = {};
7        //Mautic Modal
8        var Modal = {
9            closeButton: null,
10            modal: null,
11            overlay: null,
12            defaults: {
13                className: 'fade-and-drop',
14                closeButton: true,
15                content: "",
16                width: '600px',
17                height: '480px',
18                overlay: true
19            }
20        };
21        //Mautic Form
22        var Form = {
23            clickEvents: []
24        };
25        //Mautic Profiler
26        var Profiler = {};
27
28        //global configuration
29        var config = {devmode: true, debug: true};
30
31        Profiler.startTime = function () {
32            this._startTime = performance.now();
33        };
34
35        Profiler.runTime = function () {
36            this._endTime = performance.now();
37            this._runtime = this._endTime - this._startTime;
38            if (Core.debug()) console.log('Execution time: ' + this._runtime + ' ms.');
39        };
40
41        Form.initialize = function () {
42            var re = /{mauticform([^}]+)}/g, text;
43            while (text = re.exec(document.body.innerHTML)) {
44                var replaceText = text[0];
45                var replaceArgs = {data: {}, params: ''};
46                var tmpParams = [];
47                text[1].trim().split(/\s+/).forEach(function (strAttribute) {
48                    var tmpAtr = strAttribute.split('=');
49                    replaceArgs.data[tmpAtr[0]] = tmpAtr[1];
50                    if (tmpAtr[0] != 'id')
51                        tmpParams.push(tmpAtr[0] + '=' + encodeURIComponent(tmpAtr[1]));
52                });
53                tmpParams.push('html=1');
54                replaceArgs.params = tmpParams.join('&');
55                replaceArgs.data['replace'] = replaceText;
56
57                replaceArgs.data['style'] = typeof(replaceArgs.data['style']) == 'undefined' ? 'embed' : replaceArgs.data['style'];
58                if (Core.debug()) console.log(replaceArgs.data['style'] + ' Mautic Form: ' + replaceText);
59
60                //display form accoding with style
61                switch (replaceArgs.data['style']) {
62                    case 'modal':
63                        document.body.innerHTML = document.body.innerHTML.replace(replaceText, '');
64                        Form.clickEvents.push(replaceArgs);
65                        break;
66                    case 'embed':
67                    default:
68                        document.body.innerHTML = document.body.innerHTML.replace(replaceText, this.createIframe(replaceArgs).outerHTML);
69                        break;
70                }
71            }
72
73            this.bindClickEvents();
74            Profiler.runTime();
75        };
76
77        Form.bindClickEvents = function () {
78            if (Core.debug()) console.log('binding modal click events');
79            for (var index in Form.clickEvents) {
80                var current = Form.clickEvents[index];
81                document.querySelector(current.data.element).setAttribute("_mautic_form_index", index);
82                document.querySelector(current.data.element).addEventListener("click", function () {
83                    if (Core.debug()) console.log('add event to ' + current.data.element);
84                    Form.openModal(Form.clickEvents[this.getAttribute('_mautic_form_index')]);
85                });
86            }
87        };
88
89        Form.openModal = function (options) {
90            Core.openModal({
91                content: Form.createIframe(options, true).outerHTML,
92                width: typeof(options.data['width']) != 'undefined' ? options.data['width'] : '600px',
93                height: typeof(options.data['height']) != 'undefined' ? options.data['height'] : '480px'
94            });
95        };
96
97        Form.getFormLink = function (options) {
98            var index = (Core.devMode()) ? 'index_dev.php' : 'index.php';
99            return Core.getMauticBaseUrl() + index + '/form/' + options.data['id'] + '?' + options.params;
100        };
101
102        Form.createIframe = function (options, embed) {
103            var embed = (typeof(embed) == 'undefined') ? false : true;
104            var iframe = document.createElement('iframe');
105            //iframe config properties
106            iframe.frameBorder = typeof(options.data['border']) != 'undefined' ? parseInt(options.data['border']) : '0';
107            iframe.width = (embed) ? '100%' : typeof(options.data['width']) != 'undefined' ? options.data['width'] : '600px';
108            iframe.height = (embed) ? '100%' : typeof(options.data['height']) != 'undefined' ? options.data['height'] : '400px';
109            iframe.className = (typeof(options.data['class']) == 'string') ? options.data['class'] : '';
110            iframe.src = this.getFormLink(options);
111
112            return iframe;
113        };
114
115        Form.customCallbackHandler = function (formId, event, data) {
116            if (typeof MauticFormCallback !== 'undefined' &&
117                typeof MauticFormCallback[formId] !== 'undefined' &&
118                typeof MauticFormCallback[formId][event] == 'function'
119            ) {
120                if (typeof data == 'undefined') {
121                    data = null;
122                }
123
124                return MauticFormCallback[formId][event](data);
125            }
126
127            return null;
128        };
129
130        Form.prepareForms = function () {
131            var forms = document.getElementsByTagName('form');
132            for (var i = 0, n = forms.length; i < n; i++) {
133                var formId = forms[i].getAttribute('data-mautic-form');
134                if (formId !== null) {
135                    Form.prepareMessengerForm(formId);
136                    Form.prepareValidation(formId);
137                    Form.preparePagination(formId);
138                }
139            }
140        };
141
142        Form.prepareMessengerForm = function (formId) {
143            var theForm = document.getElementById('mauticform_' + formId);
144
145            // Check for an onsubmit attribute
146            if (!theForm.getAttribute('onsubmit')) {
147                theForm.onsubmit = function (event) {
148                    event.preventDefault();
149
150                    Core.validateForm(formId, true);
151                }
152            }
153
154            // Check to see if the iframe exists
155            if (!document.getElementById('mauticiframe_' + formId)) {
156                // Likely an editor has stripped out the iframe so let's dynamically create it
157                var ifrm = document.createElement("IFRAME");
158                ifrm.style.display = "none";
159                ifrm.style.margin = 0;
160                ifrm.style.padding = 0;
161                ifrm.style.border = "none";
162                ifrm.style.width = 0;
163                ifrm.style.heigh = 0;
164                ifrm.setAttribute('id', 'mauticiframe_' + formId);
165                ifrm.setAttribute('name', 'mauticiframe_' + formId);
166                document.body.appendChild(ifrm);
167
168                theForm.target = 'mauticiframe_' + formId;
169            }
170
171            if (!document.getElementById('mauticform_' + formId + '_messenger')) {
172                var messengerInput = document.createElement('INPUT');
173                messengerInput.type = 'hidden';
174                messengerInput.setAttribute('name', 'mauticform[messenger]');
175                messengerInput.setAttribute('id', 'mauticform_' + formId + '_messenger');
176                messengerInput.value = 1;
177
178                theForm.appendChild(messengerInput);
179            }
180        };
181
182        Form.prepareValidation = function (formId) {
183            if (typeof window.MauticFormValidations[formId] == 'undefined') {
184                window.MauticFormValidations[formId] = {};
185
186                var theForm = document.getElementById('mauticform_' + formId);
187
188                // Find validations via data-attributes
189                var validations = theForm.querySelectorAll('[data-validate]');
190                [].forEach.call(validations, function (container) {
191                    var alias = container.getAttribute('data-validate');
192                    window.MauticFormValidations[formId][alias] = {
193                        type: container.getAttribute('data-validation-type'),
194                        name: alias,
195                        multiple: container.getAttribute('data-validate-multiple'),
196                    }
197                });
198            }
199        };
200
201        Form.preparePagination = function (formId) {
202            var theForm = document.getElementById('mauticform_' + formId);
203            var pages = theForm.querySelectorAll('[data-mautic-form-page]');
204            var lastPageNumber = pages.length;
205
206            [].forEach.call(pages, function (page) {
207                var pageNumber = parseInt(page.getAttribute('data-mautic-form-page'));
208                var pageBreak = theForm.querySelector('[data-mautic-form-pagebreak="' + pageNumber + '"]');
209
210                if (pageNumber > 1) {
211                    // Hide other pages by default
212                    page.style.display = 'none';
213                }
214
215                if (pageBreak) {
216                    var prevPageNumber = pageNumber - 1;
217                    var nextPageNumber = pageNumber + 1;
218
219                    var prevButton = pageBreak.querySelector('[data-mautic-form-pagebreak-button="prev"]');
220                    var nextButton = pageBreak.querySelector('[data-mautic-form-pagebreak-button="next"]');
221
222                    // Add button handlers
223                    prevButton.onclick = function (formId, theForm, showPageNumber) {
224                        return function () {
225                            Form.customCallbackHandler(formId, 'onShowPreviousPage', showPageNumber);
226                            Form.switchPage(theForm, showPageNumber);
227                        }
228                    }(formId, theForm, prevPageNumber);
229
230                    nextButton.onclick = function (formId, theForm, hidePageNumber, showPageNumber) {
231                        return function () {
232                            // Validate fields first
233                            var validations = theForm.querySelector('[data-mautic-form-page="' + hidePageNumber + '"]').querySelectorAll('[data-validate]');
234                            var isValid = true;
235                            [].forEach.call(validations, function (container) {
236                                var fieldKey = container.getAttribute('data-validate');
237                                if (!Core.getValidator(formId).validateField(theForm, fieldKey)) {
238                                    isValid = false;
239                                }
240                            });
241                            if (!isValid) {
242                                return;
243                            }
244
245                            Form.customCallbackHandler(formId, 'onShowNextPage', showPageNumber);
246                            Form.switchPage(theForm, showPageNumber);
247                        }
248                    }(formId, theForm, pageNumber, nextPageNumber);
249
250                    if (1 === pageNumber) {
251                        prevButton.setAttribute('disabled', 'disabled');
252                        pageBreak.style.display = 'block';
253                    } else {
254                        if (lastPageNumber === pageNumber) {
255                            var theSubmit = theForm.querySelector('button[type="submit"]').parentNode;
256                            nextButton.parentNode.appendChild(theSubmit);
257                            nextButton.remove();
258                        }
259                    }
260                }
261            });
262        };
263
264        Form.switchPage = function (theForm, showPageNumber) {
265            var pages = theForm.querySelectorAll('[data-mautic-form-page]');
266            [].forEach.call(pages, function (page) {
267                // Hide all pages
268                page.style.display = 'none';
269
270                var pageNumber = parseInt(page.getAttribute('data-mautic-form-page'));
271                var pageBreak = theForm.querySelector('[data-mautic-form-pagebreak="' + pageNumber + '"]');
272                if (pageBreak) {
273                    pageBreak.style.display = 'none';
274                }
275            });
276
277            // Show the wanted page
278            var thePage = theForm.querySelector('[data-mautic-form-page="' + showPageNumber + '"]');
279            if (thePage) {
280                thePage.style.display = 'block'
281            }
282            var showPageBreak = theForm.querySelector('[data-mautic-form-pagebreak="' + showPageNumber + '"]');
283            if (showPageBreak) {
284                showPageBreak.style.display = 'block';
285            }
286        };
287
288        Form.getPageForField = function (formId, fieldId, switchPage) {
289            if (typeof switchPage === 'undefined') {
290                switchPage = true;
291            }
292            var containerId = Form.getFieldContainerId(formId, fieldId);
293            var container = document.getElementById(containerId);
294            if (!container) {
295                return;
296            }
297
298            // If within a page break - go back to the page that includes this field
299            var pageBreak = Form.findAncestor(container, 'mauticform-page-wrapper');
300            if (pageBreak) {
301                var page = pageBreak.getAttribute('data-mautic-form-page');
302                if (switchPage) {
303                    Form.switchPage(document.getElementById('mauticform_' + formId), page);
304                }
305
306                return page;
307            }
308        };
309
310        Form.findAncestor = function (el, cls) {
311            var ancestor = false;
312            while (true) {
313                var parent = el.parentElement;
314                if (!parent || Form.hasClass(parent, 'mauticform-innerform')) {
315                    break;
316                } else if (Form.hasClass(parent, cls)) {
317                    ancestor = parent;
318                    break;
319                } else {
320                    el = parent;
321                }
322            }
323
324            return ancestor;
325        };
326
327        Form.hasClass = function (el, cls) {
328            return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
329        };
330
331        Form.validator = function (formId) {
332            var validator = {
333                validateForm: function (submitForm) {
334                    if (!submitForm) {
335                        Form.prepareMessengerForm(formId);
336                    }
337
338                    var elId = 'mauticform_' + formId;
339                    var theForm = document.getElementById(elId);
340                    var formValid = Form.customCallbackHandler(formId, 'onValidate');
341                    var firstInvalidField = false;
342
343                    validator.disableSubmitButton();
344
345                    // If true or false, then a callback handled it
346                    if (formValid === null) {
347                        Form.customCallbackHandler(formId, 'onValidateStart');
348
349                        // Remove success class if applicable
350                        var formContainer = document.getElementById('mauticform_wrapper_' + formId);
351                        if (formContainer) {
352                            formContainer.className = formContainer.className.replace(" mauticform-post-success", "");
353                        }
354
355                        validator.setMessage('', 'message');
356                        validator.setMessage('', 'error');
357
358                        var formValid = true;
359
360                        // Find each required element
361                        for (var fieldKey in MauticFormValidations[formId]) {
362                            if (!validator.validateField(theForm, fieldKey)) {
363                                formValid = false;
364                                firstInvalidField = fieldKey;
365                            }
366                        }
367
368                        if (formValid) {
369                            document.getElementById(elId + '_return').value = document.URL;
370                        }
371                    }
372
373                    if (Form.customCallbackHandler(formId, 'onValidateEnd', formValid) === false) {
374                        // A custom validation failed
375                        formValid = false;
376                    }
377
378                    Form.addParameterToField(elId);
379                    Form.addGaIdToField(elId);
380
381                    if (formValid && submitForm) {
382                        theForm.submit();
383                        // Form.sendDataToService(elId);
384                    } else {
385                        // Activate the page with the first validation error
386                        Form.getPageForField(formId, firstInvalidField);
387
388                        // Enable submit button after response is handled
389                        validator.enableSubmitButton();
390                    }
391
392                    return formValid;
393                },
394
395                validateField: function (theForm, fieldKey) {
396                    var field = MauticFormValidations[formId][fieldKey];
397                    var valid = Form.customCallbackHandler(formId, 'onValidateField', {
398                        fieldKey: fieldKey,
399                        field: field
400                    });
401
402                    // If true, then a callback handled it
403                    if (valid === null) {
404                        var name = 'mauticform[' + field.name + ']';
405
406                        if (field.multiple == 'true' || field.type == 'checkboxgrp') {
407                            name = name + '[]';
408                        }
409
410                        var valid = true;
411                        if (typeof theForm.elements[name] != 'undefined') {
412                            // Validate by element name
413                            if (field.name == 'tinhtp1') {
414                                valid = validator.validateCity(theForm.elements[name].value);
415                            } else {
416                                switch (field.type) {
417                                    case 'radiogrp':
418                                        var elOptions = theForm.elements[name];
419                                        valid = validator.validateOptions(elOptions);
420                                        break;
421
422                                    case 'checkboxgrp':
423                                        var elOptions = theForm.elements[name];
424                                        valid = validator.validateOptions(elOptions);
425                                        break;
426
427                                    case 'email':
428                                        valid = validator.validateEmail(theForm.elements[name].value);
429                                        break;
430
431                                    case 'tel':
432                                        valid = validator.validatePhone(theForm.elements[name].value);
433                                        break;
434
435                                    default:
436                                        valid = (theForm.elements[name].value != '');
437                                        try {
438                                            if(valid && field.name == 'nam_sinh'){
439                                            const d = new Date();
440                                            let year = d.getFullYear();
441                                            const age = year - theForm.elements[name].value;
442                                            $("select").each(function() {                                            
443                                                  var name = $(this).attr("name");
444                                                  name = name.replace("mauticform[", "");
445                                                  name = name.replace("]", "");
446                                                  var id = $(this).attr("id");
447                                                  const itemCampaignname = 'campaign_name';
448                                                  if (id != undefined && name == itemCampaignname) {
449                                                      const mainName = 'mauticform[campaign_main]';
450                                                      let campValid= '';
451                                                      const minAge = 18;
452                                                      const maxAge = 100;
453                                                      const campPhuHuynh = '_Phụ huynh';
454                                                      const campHocSinh = '_Học sinh';
455                                                      if(age > minAge && age < maxAge){
456                                                        campValid = theForm.elements[mainName].value + campPhuHuynh;
457                                            
458                                                      }else{
459                                                        campValid = theForm.elements[mainName].value + campHocSinh;                                                      
460                                                      }
461                                                      
462                                                      $(`#${id}`).val(campValid);  
463                                                  }
464                                              });                                                                                  
465                                            }
466                                          }
467                                          catch(err) {
468                                            console.log(err);
469                                          }
470                                        break;
471                                }
472                            }
473                        }
474
475                        var containerId = Form.getFieldContainerId(formId, fieldKey);
476
477                        if (!valid) {
478                            validator.markError(containerId, valid);
479                        } else {
480                            validator.clearError(containerId);
481                        }
482                    }
483
484                    return valid;
485                },
486
487                validateOptions: function (elOptions) {
488                    if (typeof elOptions === 'undefined') {
489                        return;
490                    }
491
492                    var optionsValid = false;
493
494                    if (elOptions.length == undefined) {
495                        elOptions = [elOptions];
496                    }
497
498                    for (var i = 0; i < elOptions.length; i++) {
499                        if (elOptions[i].checked) {
500                            optionsValid = true;
501                            break;
502                        }
503                    }
504
505                    return optionsValid;
506                },
507
508                validateEmail: function (email) {
509                    var atpos = email.indexOf("@");
510                    var dotpos = email.lastIndexOf(".");
511                    var valid = (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= email.length) ? false : true;
512                    return valid;
513                },
514                validatePhone: function (phone) {
515                    var flag = false;
516                    var phone_number = phone;
517                    if (phone_number.startsWith("(+84)", 0)) {
518                        phone_number = phone_number.replace('(+84)', '0');
519                    }
520                    if (phone_number.startsWith("+84", 0)) {
521                        phone_number = phone_number.replace('+84', '0');
522                    }
523                    if (phone_number.startsWith("0084", 0)) {
524                        phone_number = phone_number.replace('0084', '0');
525                    }
526                    phone_number = phone_number.replace(/ /g, '');
527                    var phone_regex = /^(0)(\s|\.)?((3[02-9])|(5[24689])|(7[06-9])|(8[1-9])|(9[0-9]))(\d)(\s|\.)?(\d{3})(\s|\.)?(\d{3})$/;
528                    if (phone_number != '') {
529                        if (phone_regex.test(phone_number) == true)
530                        {
531                            flag = true;
532                        }
533                    }
534                    return flag;
535                },
536
537                cities: [
538                    'caobang',
539                    'backan',
540                    'tuyenquang',
541                    'laocai',
542                    'yenbai',
543                    'binhthuan',
544                    'langson',
545                    'dienbien',
546                    'laichau',
547                    'sonla',
548                    'hoabinh',
549                    'quangbinh',
550                    'quangtri',
551                    'danang',
552                    'quangnam',
553                    'quangngai',
554                    'phuyen',
555                    'khanhhoa',
556                    'kontum',
557                    'gialai',
558                    'daklak',
559                    'ninhbinh'
560                ],
561
562                validateCity: function (cityName) {
563                    var cityNameNoSign = Core.removeSign(cityName.toLowerCase());
564                    cityNameNoSign = cityNameNoSign.replace(/ /g, '');
565                    return validator.cities.includes(cityNameNoSign);
566                },
567
568                markError: function (containerId, valid, validationMessage) {
569                    var elErrorSpan = false;
570                    var callbackValidationMessage = validationMessage;
571                    var elContainer = document.getElementById(containerId);
572                    if (elContainer) {
573                        elErrorSpan = elContainer.querySelector('.mauticform-errormsg');
574                        if (typeof validationMessage == 'undefined' && elErrorSpan) {
575                            callbackValidationMessage = elErrorSpan.innerHTML;
576                        }
577                    }
578
579                    var callbackData = {
580                        containerId: containerId,
581                        valid: valid,
582                        validationMessage: callbackValidationMessage
583                    };
584
585                    // If true, a callback handled it
586                    if (!Form.customCallbackHandler(formId, 'onErrorMark', callbackData)) {
587                        if (elErrorSpan) {
588                            if (typeof validationMessage !== 'undefined') {
589                                elErrorSpan.innerHTML = validationMessage;
590                            }
591
592                            elErrorSpan.style.display = (valid) ? 'none' : '';
593                            elContainer.className = elContainer.className + " mauticform-has-error";
594                        }
595                    }
596                },
597
598                clearErrors: function () {
599                    var theForm = document.getElementById('mauticform_' + formId);
600                    var hasErrors = theForm.querySelectorAll('.mauticform-has-error');
601                    var that = this;
602                    [].forEach.call(hasErrors, function (container) {
603                        that.clearError(container.id);
604                    });
605                },
606
607                clearError: function (containerId) {
608                    // If true, a callback handled it
609                    if (!Form.customCallbackHandler(formId, 'onErrorClear', containerId)) {
610                        var elContainer = document.getElementById(containerId);
611                        if (elContainer) {
612                            var elErrorSpan = elContainer.querySelector('.mauticform-errormsg');
613                            if (elErrorSpan) {
614                                elErrorSpan.style.display = 'none';
615                                elContainer.className = elContainer.className.replace(" mauticform-has-error", "");
616                            }
617                        }
618                    }
619                },
620
621                parseFormResponse: function (response) {
622                    // Reset the iframe so that back doesn't repost for some browsers
623                    var ifrm = document.getElementById('mauticiframe_' + formId);
624                    if (ifrm) {
625                        ifrm.src = 'about:blank';
626                    }
627
628                    // If true, a callback handled response parsing
629                    if (!Form.customCallbackHandler(formId, 'onResponse', response)) {
630
631                        Form.customCallbackHandler(formId, 'onResponseStart', response);
632                        if (response.download) {
633                            // Hit the download in the iframe
634                            document.getElementById('mauticiframe_' + formId).src = response.download;
635
636                            // Register a callback for a redirect
637                            if (response.redirect) {
638                                setTimeout(function () {
639                                    window.location = response.redirect;
640                                }, 2000);
641                            }
642                        } else if (response.redirect) {
643                            window.location = response.redirect;
644                        } else if (response.validationErrors) {
645                            var firstPage = false;
646                            for (var field in response.validationErrors) {
647                                var elPage = Form.getPageForField(formId, field, false);
648                                if (elPage) {
649                                    elPage = parseInt(elPage);
650                                    if (firstPage) {
651                                        firstPage = (firstPage < elPage) ? firstPage : elPage;
652                                    } else {
653                                        firstPage = elPage;
654                                    }
655                                }
656                                this.markError('mauticform_' + formId + '_' + field, false, response.validationErrors[field]);
657                            }
658
659                            if (firstPage) {
660                                Form.switchPage(document.getElementById('mauticform_' + formId), firstPage);
661                            }
662                        } else if (response.errorMessage) {
663                            this.setMessage(response.errorMessage, 'error');
664                        }
665
666                        if (response.success) {
667                            if (response.successMessage) {
668                                this.setMessage(response.successMessage, 'message');
669                            }
670
671                            // Add a post success class
672                            var formContainer = document.getElementById('mauticform_wrapper_' + formId);
673                            if (formContainer) {
674                                formContainer.className = formContainer.className + " mauticform-post-success";
675                            }
676
677                            // Reset the form
678                            this.resetForm();
679                        }
680
681                        validator.enableSubmitButton();
682
683                        Form.customCallbackHandler(formId, 'onResponseEnd', response);
684                    }
685                },
686
687                setMessage: function (message, type) {
688                    // If true, a callback handled it
689                    if (!Form.customCallbackHandler(formId, 'onMessageSet', {message: message, type: type})) {
690                        var container = document.getElementById('mauticform_' + formId + '_' + type);
691                        if (container) {
692                            container.innerHTML = message;
693                        } else if (message) {
694                            alert(message);
695                        }
696                    }
697                },
698
699                resetForm: function () {
700
701                    this.clearErrors();
702
703                    Form.switchPage(document.getElementById('mauticform_' + formId), 1);
704
705                    document.getElementById('mauticform_' + formId).reset();
706                },
707
708                disableSubmitButton: function () {
709                    // If true, then a callback handled it
710                    if (!Form.customCallbackHandler(formId, 'onSubmitButtonDisable')) {
711                        var submitButton = document.getElementById('mauticform_' + formId).querySelector('.mauticform-button');
712
713                        if (submitButton) {
714                            MauticLang.submitMessage = submitButton.innerHTML;
715                            submitButton.innerHTML = MauticLang.submittingMessage;
716                            submitButton.disabled = 'disabled';
717                        }
718                    }
719                },
720
721                enableSubmitButton: function () {
722                    // If true, then a callback handled it
723                    if (!Form.customCallbackHandler(formId, 'onSubmitButtonEnable')) {
724                        var submitButton = document.getElementById('mauticform_' + formId).querySelector('.mauticform-button');
725                        if (submitButton) {
726                            submitButton.innerHTML = MauticLang.submitMessage;
727                            submitButton.disabled = '';
728                        }
729                    }
730                }
731            };
732
733            return validator;
734        };
735
736        Form.registerFormMessenger = function () {
737            window.addEventListener('message', function (event) {
738                if (Core.debug()) console.log(event);
739
740                // if (MauticDomain.indexOf(event.origin) !== 0) return;
741
742                try {
743                    var response = JSON.parse(event.data);
744                    console.log(response);
745
746                    if (response && response.formName) {
747                        Core.getValidator(response.formName).parseFormResponse(response);
748                    }
749                } catch (err) {
750                    if (Core.debug()) console.log(err);
751                }
752            }, false);
753
754            if (Core.debug()) console.log('Messenger listener started.');
755        };
756
757        Form.getFieldContainerId = function (formId, fieldKey) {
758            var containerId = 'mauticform_' + formId + '_' + fieldKey;
759            if (!document.getElementById(containerId)) {
760                containerId = 'mauticform_' + fieldKey;
761            }
762
763            return containerId;
764        };
765
766        Form.addParameterToField = function (formId) {
767            var keyPairs = [],
768                params = window.location.search.substring(1).split('&');
769
770            params.forEach(function (value) {
771                var tempParams = value.split('=');
772                keyPairs[tempParams[0]] = tempParams[1];
773            });
774            keyPairs = Object.assign({}, keyPairs);
775            keyPairs = JSON.stringify(keyPairs);
776
777            var input = document.createElement("input");
778            input.setAttribute("type", "hidden");
779            input.setAttribute("name", "mauticform[url_parameter]");
780            input.setAttribute("value", keyPairs);
781            document.getElementById(formId).appendChild(input);
782
783            // gclid
784            var url_string = window.location.href;
785            var url = new URL(url_string);
786            var gclid = url.searchParams.get("gclid");
787
788            if (gclid != null) {
789                var input = document.createElement("input");
790                input.setAttribute("type", "hidden");
791                input.setAttribute("name", "mauticform[gclid]");
792                input.setAttribute("value", gclid);
793                document.getElementById(formId).appendChild(input);
794            }
795
796            // fbclid
797            var url_string = window.location.href;
798            var url = new URL(url_string);
799            var fbclid = url.searchParams.get("fbclid");
800
801            if (fbclid != null) {
802                var input = document.createElement("input");
803                input.setAttribute("type", "hidden");
804                input.setAttribute("name", "mauticform[fbclid]");
805                input.setAttribute("value", fbclid);
806                document.getElementById(formId).appendChild(input);
807            }
808
809            // utm_campaign
810            var url_string = window.location.href;
811            var url = new URL(url_string);
812            var utm_campaign = url.searchParams.get("utm_campaign");
813
814            if (utm_campaign != null) {
815                var input = document.createElement("input");
816                input.setAttribute("type", "hidden");
817                input.setAttribute("name", "mauticform[utm_campaign]");
818                input.setAttribute("value", utm_campaign);
819                document.getElementById(formId).appendChild(input);
820            }
821
822            // utm_content
823            var url_string = window.location.href;
824            var url = new URL(url_string);
825            var utm_content = url.searchParams.get("utm_content");
826
827            if (utm_content != null) {
828                var input = document.createElement("input");
829                input.setAttribute("type", "hidden");
830                input.setAttribute("name", "mauticform[utm_content]");
831                input.setAttribute("value", utm_content);
832                document.getElementById(formId).appendChild(input);
833            }
834
835            // utm_medium
836            var url_string = window.location.href;
837            var url = new URL(url_string);
838            var utm_medium = url.searchParams.get("utm_medium");
839
840            if (utm_medium != null) {
841                var input = document.createElement("input");
842                input.setAttribute("type", "hidden");
843                input.setAttribute("name", "mauticform[utm_medium]");
844                input.setAttribute("value", utm_medium);
845                document.getElementById(formId).appendChild(input);
846            }
847
848            // utm_source
849            var url_string = window.location.href;
850            var url = new URL(url_string);
851            var utm_source = url.searchParams.get("utm_source");
852
853            if (utm_source != null) {
854                var input = document.createElement("input");
855                input.setAttribute("type", "hidden");
856                input.setAttribute("name", "mauticform[utm_source]");
857                input.setAttribute("value", utm_source);
858                document.getElementById(formId).appendChild(input);
859            }
860
861            // utm_term
862            var url_string = window.location.href;
863            var url = new URL(url_string);
864            var utm_term = url.searchParams.get("utm_term");
865
866            if (utm_term != null) {
867                var input = document.createElement("input");
868                input.setAttribute("type", "hidden");
869                input.setAttribute("name", "mauticform[utm_term]");
870                input.setAttribute("value", utm_term);
871                document.getElementById(formId).appendChild(input);
872            }
873
874            // landingpage
875            var landingpage = location.protocol + '//' + location.host + location.pathname;
876            var input = document.createElement("input");
877            input.setAttribute("type", "hidden");
878            input.setAttribute("name", "mauticform[landingpage]");
879            input.setAttribute("value", landingpage);
880            document.getElementById(formId).appendChild(input);
881
882            return keyPairs;
883        }
884
885        Form.addGaIdToField = function (formId) {
886            try {
887                var data = ga.getAll()[0].get('clientId');
888                console.log(data);
889                var input = document.createElement("input");
890                input.setAttribute("type", "hidden");
891                input.setAttribute("name", "mauticform[ga_id]");
892                input.setAttribute("value", data);
893                document.getElementById(formId).appendChild(input);
894
895                return trackers[i].get('clientId');
896            } catch (e) {
897            }
898            return 'false';
899        }
900
901        Form.sendDataToService = function (formId) {
902            var form = $('#' + formId);
903            var data = Form.getFormData(form);
904            data = JSON.stringify(data);
905
906            $.ajax({
907                type: "POST",
908                url: "https://attt.edupia.vn/service/service-form-data",
909                data: data,
910                dataType: "json",
911                contentType: "application/json",
912                // success: function () {
913                //     $('.mauticform-message').text('Gửi form thành công');
914                //     $('.mauticform-button').prop("disabled", false).text('Submit');
915                // }
916            });
917        }
918
919        Form.getFormData = function ($form) {
920            var unindexed_array = $form.serializeArray();
921            var indexed_array = {};
922
923            $.map(unindexed_array, function (n, i) {
924                var name = n['name'].match(/\[([^)]+)\]/)[1];
925                indexed_array[name] = n['value'];
926            });
927
928            return indexed_array;
929        }
930
931        Core.getValidator = function (formId) {
932            return Form.validator(formId);
933        };
934
935        Core.validateForm = function (formId, submit) {
936            if (typeof submit == 'undefined') {
937                submit = false;
938            }
939            return Core.getValidator(formId).validateForm(submit);
940        };
941
942        Core.prepareForm = function (formId) {
943            return Form.prepareForm(formId);
944        }
945
946        Modal.loadStyle = function () {
947            if (typeof(config.modal_css) != 'undefined' && parseInt(config.modal_css) != 'Nan' && config.modal_css == 0) {
948                if (Core.debug()) console.log('custom modal css style');
949                return;
950            }
951
952            var s = document.createElement('link');
953            s.rel = "stylesheet"
954            s.type = "text/css"
955            s.href = Core.debug() ? Core.getMauticBaseUrl() + 'media/css/modal.css' : Core.getMauticBaseUrl() + 'media/css/modal.min.css';
956            document.head.appendChild(s);
957            if (Core.debug()) console.log(s);
958        };
959
960        Modal.open = function () {
961            if (arguments[0] && typeof arguments[0] === "object") {
962                this.options = this.extendDefaults(this.defaults, arguments[0]);
963            }
964            this.buildOut();
965            this.initializeEvents();
966            window.getComputedStyle(this.modal).height;
967            this.modal.className = this.modal.className + (this.modal.offsetHeight > window.innerHeight ? " mauticForm-open mauticForm-anchored" : " mauticForm-open");
968            this.overlay.className = this.overlay.className + " mauticForm-open";
969        };
970
971        Modal.buildOut = function () {
972            var content, contentHolder, docFrag;
973            content = typeof(this.options.content) == 'string' ? this.options.content : this.options.content.innerHTML;
974            // Create a DocumentFragment to build with
975            docFrag = document.createDocumentFragment();
976
977            // Create modal element
978            this.modal = document.createElement("div");
979            this.modal.className = "mauticForm-modal " + this.options.className;
980            this.modal.style.width = this.options.width;
981            this.modal.style.height = this.options.height;
982
983            // If closeButton option is true, add a close button
984            if (this.options.closeButton === true) {
985                this.closeButton = document.createElement("button");
986                this.closeButton.className = "mauticForm-close close-button";
987                this.closeButton.innerHTML = "&times;";
988                this.modal.appendChild(this.closeButton);
989            }
990
991            // If overlay is true, add one
992            if (this.options.overlay === true) {
993                this.overlay = document.createElement("div");
994                this.overlay.className = "mauticForm-overlay " + this.options.className;
995                docFrag.appendChild(this.overlay);
996            }
997
998            // Create content area and append to modal
999            contentHolder = document.createElement("div");
1000            contentHolder.className = "mauticForm-content";
1001            contentHolder.innerHTML = content;
1002            this.modal.appendChild(contentHolder);
1003
1004            // Append modal to DocumentFragment
1005            docFrag.appendChild(this.modal);
1006
1007            // Append DocumentFragment to body
1008            document.body.appendChild(docFrag);
1009        };
1010
1011        Modal.extendDefaults = function (source, properties) {
1012            for (var property in properties) {
1013                if (properties.hasOwnProperty(property)) source[property] = properties[property];
1014            }
1015            return source;
1016        };
1017
1018        Modal.initializeEvents = function () {
1019            if (this.closeButton) this.closeButton.addEventListener('click', this.close.bind(this));
1020            if (this.overlay) this.overlay.addEventListener('click', this.close.bind(this));
1021        };
1022
1023        Modal.transitionSelect = function () {
1024            var el = document.createElement("div");
1025            return (el.style.WebkitTransition) ? "webkitTransitionEnd" : (el.style.WebkitTransition) ? "webkitTransitionEnd" : "oTransitionEnd";
1026        };
1027
1028        Modal.close = function () {
1029            var _ = this;
1030            this.modal.className = this.modal.className.replace(" mauticForm-open", "");
1031            this.overlay.className = this.overlay.className.replace(" mauticForm-open", "");
1032            this.modal.addEventListener(this.transitionSelect(), function () {
1033                _.modal.parentNode.removeChild(_.modal);
1034            });
1035            this.overlay.addEventListener(this.transitionSelect(), function () {
1036                if (_.overlay.parentNode) _.overlay.parentNode.removeChild(_.overlay);
1037            });
1038
1039            //remove modal and overlay
1040            this.overlay.parentNode.removeChild(this.overlay);
1041            this.modal.parentNode.removeChild(this.modal);
1042        };
1043
1044        const hasSign = [
1045            "à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ",
1046            "è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ",
1047            "ì","í","ị","ỉ","ĩ",
1048            "ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ",
1049            "ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ",
1050            "ỳ","ý","ỵ","ỷ","ỹ",
1051            "đ",
1052            "À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă","Ằ","Ắ","Ặ","Ẳ","Ẵ",
1053            "È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ",
1054            "Ì","Í","Ị","Ỉ","Ĩ",
1055            "Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ","Ờ","Ớ","Ợ","Ở","Ỡ",
1056            "Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ",
1057            "Ỳ","Ý","Ỵ","Ỷ","Ỹ",
1058            "Đ"
1059        ];
1060
1061        const noSign = [
1062            "a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a",
1063            "e","e","e","e","e","e","e","e","e","e","e",
1064            "i","i","i","i","i",
1065            "o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o",
1066            "u","u","u","u","u","u","u","u","u","u","u",
1067            "y","y","y","y","y",
1068            "d",
1069            "a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a",
1070            "e","e","e","e","e","e","e","e","e","e","e",
1071            "i","i","i","i","i",
1072            "o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o",
1073            "u","u","u","u","u","u","u","u","u","u","u",
1074            "y","y","y","y","y",
1075            "d"
1076        ];
1077
1078        const noSignOnly = [
1079            "a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a",
1080            "e","e","e","e","e","e","e","e","e","e","e",
1081            "i","i","i","i","i",
1082            "o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o",
1083            "u","u","u","u","u","u","u","u","u","u","u",
1084            "y","y","y","y","y",
1085            "d",
1086            "A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A",
1087            "E","E","E","E","E","E","E","E","E","E","E",
1088            "I","I","I","I","I",
1089            "O","O","O","O","O","O","O","O","O","O","O","O","O","O","O","O","O",
1090            "U","U","U","U","U","U","U","U","U","U","U",
1091            "Y","Y","Y","Y","Y",
1092            "D"
1093        ];
1094
1095        Core.removeSign = function(str) {
1096            return Core.replaceArray(str, hasSign, noSign);
1097        };
1098
1099        Core.removeSignOnly = function(str) {
1100            return Core.replaceArray(str, hasSign, noSignOnly);
1101        };
1102
1103        Core.replaceArray = function(str, find, replace) {
1104            var replaceString = str;
1105            var regex;
1106            for (var i = 0; i < find.length; i++) {
1107                regex = new RegExp(find[i], "g");
1108                replaceString = replaceString.replace(regex, replace[i]);
1109            }
1110            return replaceString;
1111        };
1112
1113        Core.parseToObject = function (params) {
1114            return JSON.parse('{"' + decodeURI(params.trim().replace(/&/g, "\",\"").replace(/=/g, "\":\"")) + '"}');
1115        };
1116
1117        Core.setConfig = function (options) {
1118            config = options;
1119        };
1120
1121        Core.getConfig = function () {
1122            return config;
1123        };
1124
1125        Core.debug = function () {
1126            return (typeof(config.debug) != 'undefined' && parseInt(config.debug) != 'Nan' && config.debug == 1) ? true : false;
1127        };
1128
1129        Core.devMode = function () {
1130            return (typeof(config.devmode) != 'undefined' && parseInt(config.devmode) != 'Nan' && config.devmode == 1) ? true : false;
1131        };
1132
1133        Core.setMauticBaseUrl = function (base_url) {
1134            config.mautic_base_url = base_url.split('/').slice(0, -3).join('/') + '/';
1135        };
1136
1137        Core.getMauticBaseUrl = function () {
1138            return config.mautic_base_url;
1139        };
1140
1141        Core.initialize = function (base_url) {
1142            Profiler.startTime();
1143            if (Core.debug()) console.log('SDK initialized');
1144            if (typeof(config.mautic_base_url) == 'undefined') Core.setMauticBaseUrl(base_url);
1145            if (Core.debug()) console.log('Automatic setup mautic_base_url as: ' + config.mautic_base_url);
1146            Modal.loadStyle();
1147            document.addEventListener("DOMContentLoaded", function (e) {
1148                if (Core.debug()) console.log('DOM is ready');
1149                Form.initialize();
1150            });
1151        };
1152
1153        Core.openModal = function (options) {
1154            Modal.open(options);
1155        };
1156
1157        Core.onLoad = function () {
1158            Form.prepareForms();
1159            Form.registerFormMessenger();
1160        };
1161
1162        return Core;
1163    }
1164
1165    if (typeof(MauticSDK) === 'undefined') {
1166        window.MauticSDK = define_library();
1167        var sjs = document.getElementsByTagName('script'), tjs = sjs.length;
1168        for (var i = 0; i < sjs.length; i++) {
1169            if (!sjs[i].hasAttribute('src') || sjs[i].getAttribute("src").indexOf('mautic-form-src.js') == -1) continue;
1170            var sParts = sjs[i].getAttribute("src").split("?");
1171            if (sParts[1]) MauticSDK.setConfig(MauticSDK.parseToObject(sParts[1]));
1172            MauticSDK.initialize(sParts[0]);
1173            break;
1174        }
1175    }
1176    if (typeof window.MauticFormValidations == 'undefined') {
1177        window.MauticFormValidations = {};
1178    }
1179})(window);

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.