PageSourceSearch

https://seranking.com/wp-content/themes/se_theme/js/forms/hubspot-form.js?v=3333

js seranking.com collected 2026-09-24 07:25:04 UTC 7,623 bytes, 172 lines download raw bytes

1var HubspotForm = (function () {
2    var createdFormContainerClasses = [];
3    var isCallbackExecuted = false;
4    var isHubspotScriptLoaded = false;
5    var isNewHubspotScriptLoaded = false;
6    var REGION = 'na1';
7    var PORTAL_ID = '539802';
8    var isSubscription2026 = document.querySelector('.page-template-subscription-2026');
9
10    function getSubscriptionTestVersionFromCookie() {
11        var expsCookieMatch = document.cookie.match(/(?:^|;\s*)exps=([^;]*)/);
12        var cookieValue = expsCookieMatch ? decodeURIComponent(expsCookieMatch[1]) : '';
13        var testVersionMatch = cookieValue.match(/subs_mar26\.(.)/);
14        return testVersionMatch ? testVersionMatch[1] : '';
15    }
16
17    function handleScheduleDemoFormData($form) {
18        var countryInput = $form.find('input[name="country"]');
19        countryInput.val(country);
20
21        var pageInput = $form.find('input[name="demo_request_page"]');
22        var isPopUpForm = document.querySelector('.se-modal-window__backdrop_popup');
23        pageInput.val(location.href + (isPopUpForm ? '?pop_up=true' : ''));
24
25        var dateInput = $form.find('input[name="demo_conversion_date"]');
26        var date = new Date();
27        date.setUTCHours(0, 0, 0, 0);
28        dateInput.val(date.getTime());
29
30        var isAgencyInput = $form.find('input[name="is_agency"]');
31        var selectValue = $form.find('select[name="demo_type"]').val();
32        var isAgencies = selectValue === 'agencies' ? 1 : 0;
33        isAgencyInput.val(isAgencies);
34
35        if (isSubscription2026) {
36            var demoTestInput = $form.find('input[name="demo_test"]');
37            var testVersion = getSubscriptionTestVersionFromCookie();
38            demoTestInput.val(testVersion);
39        }
40
41        var emailInput = $form.find('input[name="email"]');
42        dataLayer.push({
43            'event': 'interaction',
44            'location': 'hubspot_calendar',
45            'account_email': emailInput.val(),
46            'value': 'submit',
47            'is_agency': isAgencies,
48        });
49    }
50
51    function handleContactAgencyFormData($form, callback) {
52        var countryInput = $form.find('input[name="country"]');
53        countryInput.val(country);
54        callback({
55            firstname: $form.find('input[name="firstname"]').val(),
56            lastname: $form.find('input[name="lastname"]').val(),
57            email: $form.find('input[name="email"]').val(),
58            company: $form.find('input[name="company"]').val(),
59            website: $form.find('input[name="website"]').val(),
60            description: $form.find('textarea[name="comment"]').val(),
61            services: $form.find('textarea[name="message"]').val(),
62        });
63    }
64
65    function handleSubscriptionFormData($form) {
66        var countryInput = $form.find('input[name="country"]');
67        countryInput.val(country);
68        var pageInput = $form.find('input[name="contact_us_page"]');
69        pageInput.val(location.href);
70        var leadSourceInput = $form.find('input[name="lead_source"]');
71        leadSourceInput.val('demo_request');
72        var dateInput = $form.find('input[name="contact_us_date"]');
73        var date = new Date();
74        date.setUTCHours(0, 0, 0, 0);
75        dateInput.val(date.getTime());
76    }
77
78    return {
79        initHubspotForm: function (formContainerClass, formId, formType = 'schedule-demo', onBeforeFormSubmitCallBack) {
80            if (isHubspotScriptLoaded) {
81                if (!createdFormContainerClasses.includes(formContainerClass)) {
82                    createHubspotForm();
83                    createdFormContainerClasses.push(formContainerClass);
84                }
85            } else {
86                var scriptElement = document.createElement('script');
87                scriptElement.type = 'text/javascript';
88                scriptElement.src = '//js.hsforms.net/forms/embed/v2.js';
89                document.body.insertAdjacentElement('afterbegin', scriptElement);
90                scriptElement.addEventListener('load', function () {
91                    isHubspotScriptLoaded = true;
92                    createHubspotForm();
93                    createdFormContainerClasses.push(formContainerClass);
94                });
95            }
96
97            function createHubspotForm() {
98                hbspt.forms.create({
99                    region: REGION,
100                    portalId: PORTAL_ID,
101                    formId: formId,
102                    target: formContainerClass,
103                    onBeforeFormSubmit: function ($form) {
104                        switch (formType) {
105                            case 'schedule-demo':
106                                handleScheduleDemoFormData($form);
107                                break;
108                            case 'contact-agency':
109                                handleContactAgencyFormData($form, onBeforeFormSubmitCallBack);
110                                isCallbackExecuted = true;
111                                break;
112                            case 'subscription-form':
113                                handleSubscriptionFormData($form);
114                                break;
115                        }
116                        if (onBeforeFormSubmitCallBack && !isCallbackExecuted) {
117                            onBeforeFormSubmitCallBack();
118                        }
119                    },
120                });
121            }
122        },
123
124        initNewHubspotForm: function (formContainerClass, formId, formType = 'schedule-demo') {
125            if (isNewHubspotScriptLoaded) {
126                return;
127            }
128
129            createNewHubspotForm(formContainerClass, formId, formType);
130
131            function createNewHubspotForm(formContainerClass, formId) {
132                var formContainerWrapper = document.querySelector(formContainerClass);
133                var formContainer = document.createElement('div');
134                formContainer.className = 'hs-form-frame';
135                formContainer.setAttribute('data-region', REGION);
136                formContainer.setAttribute('data-form-id', formId);
137                formContainer.setAttribute('data-portal-id', PORTAL_ID);
138
139                formContainerWrapper.insertAdjacentElement('afterbegin', formContainer);
140
141                var scriptElement = document.createElement('script');
142                scriptElement.src = 'https://js.hsforms.net/forms/embed/539802.js';
143                scriptElement.defer = true;
144
145                document.head.appendChild(scriptElement);
146                isNewHubspotScriptLoaded = true;
147            }
148
149            window.addEventListener('hs-form-event:on-ready', async (event) => {
150                const form = HubSpotFormsV4.getFormFromEvent(event);
151                form.setFieldValue('0-1/country', country);
152                form.setFieldValue('0-1/demo_request_page', location.href);
153                form.setFieldValue('0-1/demo_conversion_date', new Date().toISOString());
154                if (isSubscription2026) {
155                    form.setFieldValue('0-1/demo_test', getSubscriptionTestVersionFromCookie());
156                }
157            });
158
159            window.addEventListener('hs-form-event:on-submission:success', async (event) => {
160                const form = HubSpotFormsV4.getFormFromEvent(event);
161                var emailInput = await form.getFieldValue('0-1/email');
162                dataLayer.push({
163                    'event': 'interaction',
164                    'location': 'hubspot_calendar',
165                    'account_email': emailInput,
166                    'value': 'submit',
167                    'is_agency': '',
168                });
169            });
170        },
171    };
172})();

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.