PageSourceSearch

https://www.aquael.pl/wp-content/plugins/prestawp/views/js/prestawp.js?ver=1.25

js aquael.pl collected 2026-09-26 17:43:18 UTC 15,762 bytes, 452 lines download raw bytes

1var avail;
2var mapapi;
3var storename;
4var storeid;
5var idprod;
6var idprodattr = 0;
7var txt_headersklep = "(Znajdź inny sklep)";
8var txt_btnselected = "Wybrany";
9var txt_btndefault = "Wybierz ten sklep";
10
11
12jQuery(function () {
13    if (typeof pswp_ajax_url !== 'undefined') {
14        pswp_updateCart();
15    }
16    if (typeof iFrameResize === 'function') {
17        iFrameResize({heightCalculationMethod: 'bodyOffset', checkOrigin: false}, '.pswp-iframe')
18    }
19    /*updateCnC();*/
20    updateOmnibus();
21});
22
23function updateOmnibus() {
24    if ($('#id_product').length) {
25        var idProduct = $('#id_product').val();
26        jQuery.ajax({
27            type: 'POST',
28            url: pswp_ajax_url + '?rand=' + new Date().getTime(),
29            async: true,
30            cache: false,
31            dataType: "json",
32            xhrFields: {
33                withCredentials: true
34            },
35            data: {getOmnibus: 1, wp_domain: pswp_wp_domain, idProduct: idProduct},
36            success: function (jsonData) {
37                if (jsonData) {
38                    $("#omnibus").html(jsonData.after_price_html);
39                }
40            }
41        });
42    }
43}
44
45function updateCnC() {
46    if ($('#id_product').length) {
47        var idProduct = $('#id_product').val();
48        var refreshURL = $('#refresh-url').val();
49        var requestData = {
50            id_product_attribute: 0,
51            id_product: idProduct,
52            action: 'getCncInfo'
53        };
54        $.post(refreshURL, requestData).then(function (resp) {
55            jQuery('#cncAvailable').html(resp.cncAvailable);
56            jQuery('#displayChangeLocation').html(resp.displayChangeLocation);
57
58            avail = resp.js_avail;
59            mapapi = resp.js_mapapi;
60            storeid = resp.js_storeid;
61            storename = resp.js_storename;
62            idprod = resp.js_idprod;
63
64            if (avail == 0) {
65                $(".add-to-cart-cnc").attr('disabled', true);
66            } else {
67                $(".add-to-cart-cnc").attr('disabled', false);
68            }
69
70            $(".storeNameClass").html(storename);
71
72        }).fail(function (resp) {
73
74        });
75    }
76}
77
78function pswp_updateCart(withSynerise = false) {
79    jQuery.ajax({
80        type: 'POST',
81        url: pswp_ajax_url + '?rand=' + new Date().getTime(),
82        async: true,
83        cache: false,
84        dataType: "json",
85        xhrFields: {
86            withCredentials: true
87        },
88        data: {getCart: 1, wp_domain: pswp_wp_domain},
89        success: function (jsonData) {
90            if (jsonData) {
91                if (jsonData.token) {
92                    jQuery('.pswp-token').val(jsonData.token);
93                }
94                if (jsonData.nb_products > 0) {
95                    jQuery('.shop.shop_cart').find('a.list-group-item').attr('href', jsonData.cart_url);
96                    jQuery('.shop.shop_cart').find('a.list-group-item span').html('Koszyk (' + jsonData.total + ')');
97                    jQuery('#cart-products-count').html(jsonData.nb_products);
98                    jQuery('.cart-products-count-mass').html(jsonData.nb_products);
99                    if (withSynerise) {
100                        SR.event.trackCustomEvent('cart.status', {
101                                products: jsonData.products,
102                                totalAmount: jsonData.total_float,
103                                totalQuantity: jsonData.nb_products
104                            },
105                            'CartStatus');
106                    }
107                } else {
108                    jQuery('.shop.shop_cart').find('a.list-group-item span').html('Koszyk');
109                    if (withSynerise) {
110                        SR.event.trackCustomEvent('cart.status', {
111                                products: [],
112                                totalAmount: 0,
113                                totalQuantity: 0
114                            },
115                            'CartStatus');
116                    }
117                }
118            }
119        }
120    });
121}
122
123function pswp_hideLoader(elem) {
124    jQuery(elem).parent().addClass('loaded');
125}
126
127
128jQuery(function () {
129    var $body = $('body');
130
131    var showModal = function (modal) {
132        var $body = $('body');
133        $body.append(modal);
134        $('#blockcart-modal').modal('show').on('hidden.bs.modal', function () {
135            $('#blockcart-modal').remove();
136        });
137        // $body.one('click', '#blockcart-modal', function (event) {
138        //     if (event.target.id === 'blockcart-modal') {
139        //         $(event.target).remove();
140        //     }
141        // });
142    };
143
144    $body.on(
145        'click',
146        '[data-button-action="add-to-cart"]',
147        (event) => {
148            event.preventDefault();
149            var num = parseInt($("#quantity_wanted").val());
150
151            let $form = $(event.target).closest('form');
152            var idproduct = $('#id_product').val();
153            let query = $form.serialize() + '&add=1&action=update&cnc=4&id_product=' + idproduct;
154            let actionURL = $form.attr('action');
155            let $button = $form.find('.add-to-cart');
156
157            var refreshURL = $('#refresh-url').val();
158
159            var productName = $('#id_product').text();
160            $button.addClass('sending').blur();
161            var floatPrice = parseFloat($("#product_price_float").html());
162            var specific_price_float = parseFloat($("#specific_price_float").html());
163            var current_url = $("#current_url").html();
164
165            window.dataLayer.push({
166                'event': 'addToCart',
167                'ecommerce': {
168                    'currencyCode': 'PLN',
169                    'add': {
170                        'products': [{
171                            'name': productName,
172                            'id': idproduct,
173                            'price': floatPrice,
174                            'quantity': num
175                        }]
176                    }
177                }
178            });
179
180            SR.event.trackCustomEvent("product.addToCart", {
181                "ItemUrlAddress": current_url,
182                "$sku": idproduct,
183                "name": productName,
184                "quantity": num,
185                "regularUnitPrice": specific_price_float,
186                "discountedUnitPrice": floatPrice,
187                "finalUnitPrice": floatPrice * num,
188                "currency": "PLN",
189            }, "ProductAddToCart")
190
191            $.post(actionURL, query, null, 'json').then((resp) => {
192
193                var requestData = {
194                    id_product_attribute: 0,
195                    id_product: idproduct,
196                    action: 'add-to-cart',
197                    cnc_blocker: resp.cnc_blocker
198                };
199
200                $.post(refreshURL, requestData).then(function (resp) {
201                    //$('.blockcart').replaceWith($(resp.preview).find('.blockcart'));
202                    if (resp.modal) {
203                        showModal(resp.modal);
204                    }
205                    pswp_updateCart(true);
206                    $button.removeClass('sending').blur();
207
208
209                }).fail(function (resp) {
210                    $button.removeClass('sending').blur();
211                });
212            }).fail((resp) => {
213                $button.removeClass('sending').blur();
214            });
215        }
216    );
217
218    $body.on(
219        'click',
220        '[data-button-action="add-to-cart-cnc"]',
221        (event) => {
222            event.preventDefault();
223
224            let $form = $(event.target).closest('form');
225            var idproduct = $('#id_product').val();
226            let query = $form.serialize() + '&add=1&action=update&cnc=1&id_product=' + idproduct;
227            let actionURL = $form.attr('action');
228            let $button = $form.find('.add-to-cart-cnc');
229
230            var refreshURL = $('#refresh-url').val();
231
232            $button.addClass('sending').blur();
233            var productName = $('#id_product').text();
234            var floatPrice = $("#product_price_float").html();
235
236            window.dataLayer.push({
237                'event': 'addToCart',
238                'ecommerce': {
239                    'currencyCode': 'PLN',
240                    'add': {
241                        'products': [{
242                            'name': productName,
243                            'id': idproduct,
244                            'price': floatPrice,
245                            'quantity': 1
246                        }]
247                    }
248                }
249            });
250
251            $.post(actionURL, query, null, 'json').then((resp) => {
252
253                var requestData = {
254                    id_product_attribute: 0,
255                    id_product: idproduct,
256                    action: 'add-to-cart',
257                    cnc_blocker: resp.cnc_blocker
258                };
259
260                $.post(refreshURL, requestData).then(function (resp) {
261                    //$('.blockcart').replaceWith($(resp.preview).find('.blockcart'));
262                    if (resp.modal) {
263                        showModal(resp.modal);
264                    }
265                    pswp_updateCart(true);
266                    $button.removeClass('sending').blur();
267
268                }).fail(function (resp) {
269                    $button.removeClass('sending').blur();
270                });
271            }).fail((resp) => {
272                $button.removeClass('sending').blur();
273            });
274        }
275    );
276
277    $(document).on('change', '#id_product', function (e) {
278        var selectedId = this.value;
279        var obj = JSON.parse(cart_products);
280        obj.forEach(function (entry) {
281            if (entry['id_produktu_prestashop'] == selectedId) {
282
283                if(entry['in_stock']){
284                    $(".cartContainerActive").css('display', 'block');
285                    $("#cartContainerInactive").css('display', 'none');
286                }else{
287                    $(".cartContainerActive").css('display', 'none');
288                    $("#cartContainerInactive").css('display', 'block');
289                }
290                $("#product_price").html(entry['price']);
291                $("#product_price_float").html(entry['price_float']);
292                $("#specific_price_float").html(entry['specific_price_float']);
293
294                if (entry['price'] != entry['specific_price']) {
295                    $("#regular_price").html(entry['specific_price']);
296                    $('.prices_box').addClass('with-discount');
297                } else {
298                    $("#regular_price").html('0');
299                    $('.prices_box').removeClass('with-discount');
300                }
301            }
302        });
303        /*updateCnC();*/
304        updateOmnibus();
305    });
306
307    $(document).on('click', '.bootstrap-touchspin-up', function (e) {
308        var num = parseInt($("#quantity_wanted").val());
309        num += 1;
310        $("#quantity_wanted").val(num);
311    });
312
313    $(document).on('click', '.bootstrap-touchspin-down', function (e) {
314        var num = parseInt($("#quantity_wanted").val());
315        num -= 1;
316        if (num <= 0) {
317            num = 1;
318        }
319
320        $("#quantity_wanted").val(num);
321    });
322});
323
324
325
326/* x13pricehistory */
327
328const x13pricehistory = {
329    getCurrency: function (number) {
330        let value = new Intl.NumberFormat('pl-PL', {
331            style: 'currency', currency: 'PLN'
332        }).format(number);
333
334        return value;
335    },
336    generateData: function (parent) {
337        let labels = [];
338        let data = [];
339        let lowest = 0;
340        let json = parent.querySelector('.x13pricehistory-json');
341        json = JSON.parse(json.textContent);
342
343        Object.values(json).forEach((value) => {
344            labels = [...labels, value.date_add];
345            data = [...data, value.price];
346
347            if (value.lowest) {
348                lowest = value.date_add;
349            }
350        });
351
352        return {labels, data, lowest};
353    },
354    generateChart: function (parent, {labels, data, lowest}) {
355        let chart = parent.querySelector('.x13pricehistory-chart');
356        let chartStyle = chart.dataset.style === 'chart' ? 'bar' : 'line';
357        let ctx = chart.getContext('2d');
358        let gradient = ctx.createLinearGradient(0, 0, 0, 300);
359        gradient.addColorStop(0, `${x13pricehistoryChartBackground}88`);
360        gradient.addColorStop(1, `${x13pricehistoryChartBackground}00`);
361
362        const type = {
363            line: {
364                labels: labels,
365                datasets: [{
366                    fill: true,
367                    backgroundColor: gradient,
368                    borderColor: x13pricehistoryChartBackground,
369                    pointBackgroun
369dColor: labels.map((label) => {
370                        if (label == lowest) return x13pricehistoryChartBackgroundLowest;
371
372                        return x13pricehistoryChartBackground;
373                    }),
374                    data: data,
375                }]
376            },
377            bar: {
378                labels: labels,
379                datasets: [{
380                    fill: true,
381                    backgroundColor: labels.map((label) => {
382                        if (label == lowest) return x13pricehistoryChartBackgroundLowest;
383
384                        return x13pricehistoryChartBackground;
385                    }),
386                    data: data,
387                }]
388            }
389        }
390
391        const options = {
392            legend: {
393                display: false,
394            },
395            tooltips: {
396                callbacks: {
397                    label: function (tooltipItem, data) {
398                        let label = parseFloat(tooltipItem.value);
399                        return x13pricehistory.getCurrency(label);
400                    }
401                }
402            },
403            scales: {
404                yAxes: [{
405                    ticks: {
406                        min: 0,
407                        callback: function (value, index, ticks) {
408                            return x13pricehistory.getCurrency(value);
409                        }
410                    },
411                }],
412            }
413        };
414
415        let chartJs = new Chart(ctx, {
416            type: chartStyle,
417            data: type[chartStyle],
418            options: options,
419        })
420
421        if (chartJs.config.data.datasets.length === 0) return;
422        if (chartJs.options.scales.yAxes.length === 0) return;
423
424        let maxValue = parseInt(Math.max(...chartJs.config.data.datasets[0].data) * 1.1);
425
426        chartJs.options.scales.yAxes[0].ticks.max = maxValue;
427        chartJs.update();
428    }
429};
430
431document.addEventListener('click', (e) => {
432    if (!e.target.classList.contains('x13pricehistory__button')) return;
433
434    let parent = e.target.closest('.x13pricehistory');
435    let chart = parent.querySelector('.x13pricehistory-chart');
436    let modal = document.querySelector('.x13pricehistory-modal');
437
438    if (!parent.classList.contains('inited')) {
439        parent.classList.add('inited');
440        let data = x13pricehistory.generateData(parent);
441
442        let html = $('.x13pricehistory-modal-body-replace').html();
443        $('.x13pricehistory-modal .modal-body').html(html);
444
445        if (chart !== null) {
446            x13pricehistory.generateChart(modal, data);
447        }
448    }
449
450    // jQuery + Bootstrap Modal
451    $('.x13pricehistory-modal').modal('show');
452})

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.