PageSourceSearch

https://packagingproductsonline.co.uk/wp-content/plugins/pixelyoursite-bing/dist/scripts/public.js

js packagingproductsonline.co.uk collected 2026-10-10 01:35:49 UTC 10,478 bytes, 304 lines download raw bytes

1/* global pysOptions */
2
3!function ($) {
4
5
6    var Bing = function () {
7
8        var initialized = false;
9
10
11        function getUtils() {
12            return window.pys.Utils;
13        }
14
15        function getOptions() {
16            return window.pysOptions;
17        }
18        function fireEvent(name, event) {
19            if(typeof window.pys_event_data_filter === "function" && window.pys_disable_event_filter(name,'bing')) {
20                return;
21            }
22            var copyParams = getUtils().copyProperties(event.params, {});
23            var params = mapParamsToBing(name,copyParams)
24
25            var utils = getUtils();
26            var ids = event.pixel_ids.filter(function (pixelId) {
27                if (utils.hasOwnProperty('hideMatchingPixel')) {
28                    return !utils.hideMatchingPixel(pixelId, 'bing');
29                } else {
30                    return true;
31                }
32            });
33            params.event_id = getUtils().generateUniqueId(event);
34            if (ids.length) {
35                if (getOptions().debug) {
36                    console.log('[Bing] ' + name, params);
37                }
38
39                window.uetq = window.uetq || [];
40                window.uetq.push('event', name, params);
41            }
42
43
44        }
45        function mapParamsToBing(name,param) {
46            //GA4 automatically collects a number of parameters for all events
47             param.page_title;
48            delete param.event_url;
49            delete param.event_month;
50            delete param.event_time;
51            delete param.event_day;
52            delete param.landing_page;
53            delete param.page_title;
54            delete param.post_type;
55            delete param.post_id;
56            delete param.plugin;
57            delete param.user_role;
58            delete param.traffic_source;
59            delete param.cartlows;
60            delete param.cartflows_flow;
61            delete param.cartflows_step;
62
63
64            return param;
65        }
66        /**
67         * Public API
68         */
69        return {
70            tag: function() {
71                return "bing";
72            },
73            isEnabled: function () {
74                return getOptions().hasOwnProperty('bing');
75            },
76            getHidePixel: function(){
77                if(this.isEnabled() && getOptions().bing.hasOwnProperty('hide_pixels'))
78                {
79                    return getOptions().bing.hide_pixels;
80                }
81                return [];
82            },
83            disable: function () {
84                initialized = false;
85            },
86
87            /**
88             * Load pixel's JS
89             *
90             * @link: https://developers.pinterest.com/docs/ad-tools/enhanced-match/
91             */
92            loadPixel: function () {
93
94                if (initialized || !this.isEnabled() || !getUtils().consentGiven('bing')) {
95                    return;
96                }
97
98                var tagId = getOptions().bing.pixelId;
99                var runtrack = true;
100                if (getUtils().hasOwnProperty('hideMatchingPixel')) {
101                    runtrack = !getUtils().hideMatchingPixel(tagId, 'bing')
102                }else{
103                    runtrack = true;
104                }
105                if(runtrack){
106                    // load base tag
107                    (function (w, d, t, r, u) {
108                        var f, n, i;
109                        w[u] = w[u] || [], f = function () {
110                            var o = { ti: tagId };
111                            o.q = w[u], w[u] = new UET(o), w[u].push("pageLoad")
112                        }, n = d.createElement(t), n.src = r, n.async = 1, n.onload = n.onreadystatechange = function () {
113                            var s = this.readyState;
114                            s && s !== "loaded" && s !== "complete" || (f(), n.onload = n.onreadystatechange = null)
115                        }, i = d.getElementsByTagName(t)[0], i.parentNode.insertBefore(n, i)
116                    })(window, document, "script", "//bat.bing.com/bat.js", "uetq");
117
118                    initialized = true;
119                }
120
121                if ( getOptions().bing.consent_mode.ad_storage.enabled ) {
122                    window.uetq = window.uetq || [];
123                    window.uetq.push('consent', 'default', {
124                        'ad_storage': getOptions().bing.consent_mode.ad_storage.value
125                    });
126                }
127
128                getUtils().fireStaticEvents('bing');
129
130            },
131
132            fireEvent: function (name, data) {
133
134                if (!initialized || !this.isEnabled()) {
135                    return false;
136                }
137
138                data.delay = data.delay || 0;
139                data.params = data.params || {};
140
141                if (data.delay === 0) {
142
143                    fireEvent(name, data);
144
145                } else {
146
147                    setTimeout(function (name, params) {
148                        fireEvent(name, params);
149                    }, data.delay * 1000, name, data);
150
151                }
152
153                return true;
154
155            },
156
157            onAdSenseEvent: function () {
158                // not supported
159            },
160
161            onClickEvent: function (event) {
162
163                if (initialized && this.isEnabled() ) {
164
165                    this.fireEvent(event.name, event);
166
167                }
168
169            },
170
171            onWatchVideo: function (event) {
172
173                if (initialized && this.isEnabled() ) {
174                    this.fireEvent(event.name, event);
175                }
176
177            },
178
179            onCommentEvent: function (event) {
180
181                if (initialized && this.isEnabled() ) {
182                    this.fireEvent(event.name, event);
183                }
184
185            },
186
187            onFormEvent: function (event) {
188
189                if (initialized && this.isEnabled() ) {
190                    this.fireEvent(event.name, event);
191                }
192
193            },
194
195            onDownloadEvent: function (event) {
196
197                if (initialized && this.isEnabled() ) {
198                    this.fireEvent(event.name, event);
199                }
200
201            },
202
203            onWooAddToCartOnButtonEvent: function (product_id) {
204                if(!getOptions().dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
205                    return;
206
207                if (window.pysWooProductData.hasOwnProperty(product_id)) {
208                    if (window.pysWooProductData[product_id].hasOwnProperty('bing')) {
209
210                        var event = getUtils().clone(getOptions().dynamicEvents.woo_add_to_cart_on_button_click[this.tag()])
211                        getUtils().copyProperties(window.pysWooProductData[product_id][this.tag()].params, event.params)
212
213
214                        this.fireEvent(event.name, event);
215                    }
216                }
217
218            },
219
220            onWooAddToCartOnSingleEvent: function (product_id, qty, product_type, is_external, $form) {
221
222                window.pysWooProductData = window.pysWooProductData || [];
223                if(!getOptions().dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
224                    return;
225
226
227                if (window.pysWooProductData.hasOwnProperty(product_id)) {
228                    if (window.pysWooProductData[product_id].hasOwnProperty('bing')) {
229                        var event = getUtils().clone(getOptions().dynamicEvents.woo_add_to_cart_on_button_click[this.tag()])
230                        getUtils().copyProperties(window.pysWooProductData[product_id]['bing'].params, event.params);
231
232                        if(product_type === getUtils().PRODUCT_GROUPED ) {
233                            var quantity = 0
234                            $form.find(".woocommerce-grouped-product-list .qty").each(function(index){
235                                var qty =parseInt($(this).val());
236                                if(isNaN(qty)) {
237                                    qty = 0;
238                                }
239                                quantity += qty;
240                            });
241                            if(quantity == 0) return;// skip if no items selected
242                        }
243
244                        this.fireEvent(event.name, event);
245                    }
246                }
247
248            },
249
250            onWooRemoveFromCartEvent: function (cart_item_hash) {
251                // not supported
252            },
253
254            onWooAffiliateEvent: function (product_id) {
255                // not supported
256            },
257
258            onWooPayPalEvent: function (event) {
259                // not supported
260            },
261
262            onEddAddToCartOnButtonEvent: function (download_id, price_index, qty) {
263                if(!getOptions().dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
264                    return;
265                var event = getOptions().dynamicEvents.edd_add_to_cart_on_button_click[this.tag()];
266
267                if (window.pysEddProductData.hasOwnProperty(download_id)) {
268
269                    if (window.pysEddProductData[download_id].hasOwnProperty(download_id)) {
270                        if (window.pysEddProductData[download_id][download_id].hasOwnProperty('bing')) {
271                            event = getUtils().copyProperties(event, {})
272                            getUtils().copyProperties(window.pysEddProductData[download_id][download_id]['bing'].params, event.params);
273
274                            this.fireEvent(event.name, event);
275
276                        }
277                    }
278
279                }
280
281            },
282
283            onEddRemoveFromCartEvent: function (item) {
284                // not supported
285            },
286            onPageScroll: function (event) {
287                if (initialized && this.isEnabled()) {
288                    this.fireEvent(event.name, event);
289                }
290            },
291            onTime: function (event) {
292                if (initialized && this.isEnabled()) {
293                    this.fireEvent(event.name, event);
294                }
295            },
296        };
297
298    }();
299
300    window.pys = window.pys || {};
301    window.pys.Bing = Bing;
302
303
304}(jQuery);

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.