PageSourceSearch

https://www.signifyd.com/wp-content/plugins/signifyd-modules/js-marketo/js/marketo-module.js

js signifyd.com collected 2026-10-01 10:27:41 UTC 6,297 bytes, 171 lines download raw bytes

1/**
2 * This file should contain frontend logic for 
3 * all module instances.
4 */
5
6var mktoFormConfig = {
7    podId: "//info.signifyd.com",
8    munchkinId: "331-GFT-117"
9};
10
11window.SignifydMarketoRuntime = window.SignifydMarketoRuntime || (function () {
12    var state = {
13        callbacksBound: false,
14    };
15
16    function bindCallbacks(arrayify) {
17        if (state.callbacksBound || typeof MktoForms2 === 'undefined') {
18            return;
19        }
20
21        state.callbacksBound = true;
22
23        MktoForms2.whenRendered(function (form) {
24            var formEl = form.getFormElem()[0],
25                rando = '_' + new Date().getTime() + Math.random();
26
27            var ctaLabel = formEl.getAttribute('data-content');
28            form.addHiddenFields({ contentName: ctaLabel ? ctaLabel : 'N/A' });
29
30            var btnName = formEl.getAttribute('data-btn');
31            if (btnName && formEl.querySelector('.mktoButton')) {
32                formEl.querySelector('.mktoButton').innerHTML = btnName;
33            }
34
35            if (!document.body.classList.contains('fl-builder-edit')) {
36                arrayify(formEl.querySelectorAll('label[for]'))
37                    .map(function (labelEl) {
38                        return {
39                            label: labelEl,
40                            for: formEl.querySelector('[id="' + labelEl.htmlFor + '"]')
41                        };
42                    })
43                    .forEach(function (labelDesc) {
44                        if (labelDesc.for) {
45                            if (!labelDesc.for.hasAttribute('data-uniquified')) {
46                                labelDesc.for.id = labelDesc.for.id + rando;
47                                labelDesc.for.setAttribute('data-uniquified', 'true');
48                            }
49                            labelDesc.label.htmlFor = labelDesc.for.id;
50                        }
51                    });
52            }
53        });
54
55        MktoForms2.whenReady(function (form) {
56            var formEl = form.getFormElem()[0];
57
58            if (typeof OptanonWrapper !== 'undefined' && typeof OnetrustActiveGroups !== 'undefined') {
59                if (!OnetrustActiveGroups.includes('C0003')) {
60                    formEl.classList.remove('spinner');
61                } else {
62                    setTimeout(function () {
63                        formEl.classList.remove('spinner');
64                    }, 4500);
65                }
66            } else {
67                formEl.classList.remove('spinner');
68            }
69
70            if (typeof LDBookItV2 !== 'undefined') {
71                LDBookItV2.initialize('00Do0000000ZCctEAG', 'Demo Request', 'LD_BookIt_Log_ID__c');
72                LDBookItV2.setFormProvider('marketo');
73            }
74
75            form.onSuccess(function (submittedForm) {
76                if (typeof LDBookItV2 !== 'undefined' && formEl.getAttribute('data-bookit') == 'true') {
77                    window.LDBookItV2.submit({ formData: submittedForm });
78                }
79
80                var parentEl = formEl.parentElement,
81                    successWrapper = parentEl ? parentEl.querySelector('.success-message') : null;
82
83                if (parentEl) {
84                    parentEl.classList.add('form-sent');
85                }
86
87                if (successWrapper) {
88                    var redirect = successWrapper.getAttribute('data-url') ? successWrapper.getAttribute('data-url') : '';
89                    if (redirect) {
90                        var target = successWrapper.getAttribute('data-target') ? successWrapper.getAttribute('data-target') : '_self',
91                            param = (redirect.indexOf('?') >= 0) ? '&lb_email=' : '?lb_email=',
92                            emailInput = formEl.querySelector('input[name="Email"]');
93                        if (successWrapper.getAttribute('data-email-val') && emailInput) {
94                            redirect = redirect + param + emailInput.value;
95                        }
96                        window.open(redirect, target);
97                    }
98                }
99
100                return false;
101            });
102        });
103    }
104
105    function init(config, attrName) {
106        if (typeof MktoForms2 === 'undefined') {
107            return;
108        }
109
110        var arrayify = getSelection.call.bind([].slice),
111            attr = attrName || 'data-form-id',
112            elements = arrayify(document.querySelectorAll('[' + attr + ']')),
113            formIds = [];
114
115        if (!elements.length) {
116            return;
117        }
118
119        elements.forEach(function (element) {
120            var formId = element.getAttribute(attr);
121            if (!formId) {
122                return;
123            }
124            if (formIds.includes(formId)) {
125                var matchCount = formIds.filter(function (id) { return id === formId; }).length;
126                element.setAttribute('data-form-instance', matchCount);
127            } else {
128                formIds.push(formId);
129            }
130        });
131
132        bindCallbacks(arrayify);
133
134        arrayify(formIds).forEach(function (formId) {
135            var loadForm = MktoForms2.loadForm.bind(MktoForms2, config.podId, config.munchkinId, formId),
136                formEls = elements.filter(function (el) {
137                    return el.getAttribute(attr) === formId && !el.hasAttribute('data-mkto-loaded');
138                });
139
140            if (!formEls.length) {
141                return;
142            }
143
144            // Reserve every matching element synchronously so a second init pass can't re-load the chained instances.
145            formEls.forEach(function (el) {
146                el.setAttribute('data-mkto-loaded', '1');
147            });
148
149            (function loadFormCb(queue) {
150                var formEl = queue.shift();
151                formEl.id = 'mktoForm_' + formId;
152
153                loadForm(function () {
154                    formEl.id = '';
155                    if (queue.length) {
156                        loadFormCb(queue);
157                    }
158                });
159            })(formEls);
160        });
161    }
162
163    return {
164        init: init,
165    };
166})();
167
168if (!document.body.classList.contains('fl-builder-edit')) {
169    window.SignifydMarketoRuntime.init(mktoFormConfig, 'data-form-id');
170    window.SignifydMarketoRuntime.init(mktoFormConfig, 'data-formId');
171}

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.