PageSourceSearch

https://www.absoluteplumbingsolutions.com.au/wp-content/plugins/in…/intel/js/l10intel_formtracker.js?ver=7.1.2

js absoluteplumbingsolutions.com.au collected 2026-10-06 11:06:26 UTC 6,714 bytes, 221 lines download raw bytes

1var _ioq = _ioq || [];
2
3function L10iFormTracker(_ioq, config) {
4    var ioq = _ioq;
5    var io = _ioq.io;
6    var $ = jQuery;
7
8    var ths = {};
9
10    this.formDefs = [];
11    this.formDefsIndex = {};
12
13
14    this.init = function init() {
15        var ths = this;
16        //$('form').not('.formtracker-0').on('submit', ths.eventHandler);
17        //$('a').on('mouseover', {eventType: 'click'}, ths.eventHandler); // for testing event sends
18    };
19
20    this.trackForm = function trackForm(def) {
21        if (ioq.isArray(def)) {
22            for (var i = 0; i < def.length; i++) {
23                this.trackFormInit(def[i]);
24            }
25        }
26        else {
27            this.trackFormInit(def);
28        }
29    };
30
31    this.trackFormInit = function trackFormInit(def) {
32        //console.log('trackFormInit()');
33        //console.log(def);
34        var ths = _ioq.plugins.formtracker;
35
36        var $obj, $this, $onObj, enable = 1, $dataField, def2;
37        var key = def.key || def.formId;
38
39        if (ioq.isNull(def)) {
40            def = {};
41        }
42        if (!ioq.isNull(def.landingpage) && !ioq.isNull(ioq.plugins.convtracker)) {
43            def.landingpage = ioq.plugins.convtracker.trackLandingpage(def.landingpage);
44        }
45
46        if (ioq.isNull(def.selector)) {
47            def.selector = 'body';
48            def.onSelector = def.onSelector||'form';
49        }
50
51        def.oa = def.oa || {};
52        def.oa.rc = def.oa.rc || 'form';
53        if (!def.oa.rt && def.formType) {
54            def.oa.rt = def.formType;
55        }
56        if (!def.oa.rk && def.formId) {
57            def.oa.rk = def.formId;
58        }
59        if (!def.oa.ri) {
60            def.oa.ri = def.formUri || ':' + def.formType + ':' + def.formId;
61        }
62
63        def.eventAction = def.eventAction || def.formTitle || ioq.settings.pageTitle;
64        def.eventLabel = def.eventLabel || def.oa.ri;
65
66
67        $obj = ioq.jQuerySelect(def);
68        if (def.onSelector) {
69            $onObj = $obj.find(def.onSelector);
70        }
71        else {
72            $onObj = $obj;
73        }
74
75        // loop through each form found by the selector to check if any special fields exist to disable the onSubmit tracking.
76        $onObj.each(function() {
77            $this = $(this);
78            if (ths.processFormSpecialFields(def, $this)) {
79                enable = 0;
80            }
81        });
82
83        if ($onObj.length && def.trackView) {
84            delete def.trackView;
85            evtDef = ioq.objectMerge({}, def);
86            evtDef.eventCategory = 'Form view';
87            evtDef.onEvent = 'pageview';
88            evtDef.eid = 'formView';
89            evtDef.nonInteraction = 1;
90            io('event', evtDef);
91        }
92        if ($onObj.length && def.trackSubmission) {
93            //delete def.trackView;
94            evtDef = ioq.objectMerge({}, def);
95            evtDef.eventCategory = 'Form submission';
96            evtDef.onEvent = 'submission';
97            evtDef.eid = 'formSubmission';
98            evtDef.nonInteraction = 1;
99            io('event', evtDef);
100        }
101
102        /* Disabling logic until full conversion tracking can be implemented
103        if (ioq.isNull(def.onEvent)) {
104            def.onEvent = 'submit';
105        }
106
107        def.triggerCallback = ths.saveFormSubmit;
108
109
110        $obj = ioq.jQuerySelect(def);
111        if (def.onSelector) {
112            $onObj = $obj.find(def.onSelector);
113        }
114        else {
115            $onObj = $obj;
116        }
117
118        // loop through each form found by the selector to check if any special fields exist to disable the onSubmit tracking.
119        $onObj.each(function() {
120            $this = $(this);
121            if (ths.processFormSpecialFields(def, $this)) {
122                enable = 0;
123            }
124        });
125
126        if (enable) {
127            def.onHandler = function (event) {
128                window._ioq.push(['triggerFormSubmitEvent', def, jQuery(this), event]);
129            };
130            def.eid = 'formSubmit';
131            io('event', def);
132
133            def2 = ioq.objectMerge({}, def);
134            def2.onEvent = 'click';
135            ioq.jQueryOn(def2, $obj, function(event) {
136                $(this).removeClass('l10-form-submit-processed');
137            });
138        }
139        */
140
141        // only set loc form cookie for pro level
142        if (ioq._apiLevel == 'pro') {
143            ths.setCookie('l10i_lf', ioq.settings.pageUri, 1);
144        }
145
146
147        if (key) {
148            if (!ths.formDefsIndex[key]) {
149                ths.formDefsIndex[key] = ths.formDefs.length;
150                ths.formDefs.push(def);
151            }
152        }
153
154        return def;
155
156    };
157
158    this.processFormSpecialFields = function (def, $obj, event) {
159        var pf = 'io';
160        if ($obj.is('form')) {
161            // check if field has been set to not track
162            var enabled = $obj.find('input[name="' + pf + '_track_form"]').val();
163            if ((enabled == '0') || (enabled == 'false')) {
164                //ths.removeCallback(def.triggerCallback, ths.saveFormSubmit);
165                return true;  // jQuery.each() equivalent to "continue";
166            }
167
168            // check for data field used to store submit data rather than attaching js submit event
169            var $dataField = $obj.find('input[name="' + pf + '_submit_data"]');
170            if ($dataField.length == 0) {
171                // TODO: this is the format of Webform's hidden fields
172                $dataField = $obj.find('input[name="submitted[' + pf + '_submit_data]"]');
173            }
174            if ($dataField.length == 1) {
175                var formSubmit = ths.constFormSubmit(null, $obj);
176
177                formSubmit = JSON.stringify(formSubmit);
178
179                $dataField.val(formSubmit);
180                //ths.removeCallback(def.triggerCallback, ths.saveFormSubmit);
181                return true;
182            }
183        }
184        return false;
185    };
186
187    this.setFormDef = function setFormDef(name, def) {
188        var i, a;
189        if (ioq.isArray(name)) {
190            for (var i = 0; i < name.length; i++) {
191                a = name[i];
192                if (a[0] && a[1] && ioq.isObject(a[1])) {
193                    this.formDefs[a[0]] = a[1];
194                }
195            }
196        }
197        else {
198            this.formDefs[name] = obj;
199        }
200    };
201
202    this.getFormDef = function getFormDef(name, defaultValue) {
203        if (name == undefined) {
204            return this.linkTypeDefs;
205        }
206        if (this.linkTypeDefs[name] === undefined) {
207            return defaultValue;
208        }
209        return this.linkTypeDefs[name];
210    };
211
212    this.eventHandler = function eventHandler(event) {
213
214
215    };
216
217    this.init();
218
219}
220
221_ioq.push(['providePlugin', 'formtracker', L10iFormTracker, {}]);

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.