PageSourceSearch

https://reolink-sklep.pl/skins/user/rwd_shoper_3/js/user.js?sci=369

js reolink-sklep.pl collected 2026-09-29 21:41:31 UTC 74,969 bytes, 3,058 lines download raw bytes

1/*shopcademy szablon Dealer - prosimy nie edytować komentarzy*/
2  
3console.log("dev2");
4/*shopcademy menu wrap*/
5$(function() {
6  
7            var wrap = $(".wrap");
8            $(window).scroll(function() {
9                var scroll = $(window).scrollTop();
10                if (scroll >= 230) {
11                    wrap.addClass("menu-fixed");
12                } else {
13                    wrap.removeClass("menu-fixed");
14                }
15            });
16            
17          
18         /*pasek nad nagłowkiem - start - shopcademy.pl */
19
20    var scTopBar = $('#sc_top-bar');
21    if (scTopBar.length > 0) {
22	var scWrap = $('.wrap');
23        scTopBar.prependTo(scWrap);
24    }
25
26
27
28/*pasek nad nagłowkiem - end - shopcademy.pl */
29
30/* menu moduly*/
31
32var scTabsMain = $("#tabs-main");
33
34if (scTabsMain.length > 0) {
35
36var scBestsellers = $("#box_bestsellers");
37var scLastA = $("#box_lastadded");
38var scSpecialO = $("#box_specialoffer");
39var scTab1 = $("#tab1");
40var scTab2 = $("#tab2");
41var scTab3 = $("#tab3");
42
43    scBestsellers.addClass("widok");
44    scLastA.addClass("widok");
45    scSpecialO.addClass("widok");
46
47    scTab1.click(function() {
48        scTab1.addClass("active");
49        scTab2.removeClass("active");
50        scTab3.removeClass("active");
51        scBestsellers.show();
52        scLastA.hide();
53        scSpecialO.hide();
54
55    });
56
57    scTab2.click(function() {
58        scTab2.addClass("active");
59        scTab1.removeClass("active");
60        scTab3.removeClass("active");
61        scLastA.show();
62        scBestsellers.hide();
63        scSpecialO.hide();
64    });
65
66
67    scTab3.click(function() {
68        scTab3.addClass("active");
69        scTab1.removeClass("active");
70        scTab2.removeClass("active");
71        scSpecialO.show();
72        scLastA.hide();
73        scBestsellers.hide();
74
75    });
76	
77}
78
79  
80/*banner footer*/
81var scBannerFooter = $('#sc-banner');
82var scBannerFooterInsert = $('#shoper-foot');
83
84 if(scBannerFooter.length > 0){           
85scBannerFooter.insertBefore(scBannerFooterInsert);  
86}
87  
88  
89  // promo tags
90    var scBoxMainPro = $("#box_mainproducts");
91
92    if (scBoxMainPro.length > 0) {
93        $(".product").each(function(i) {
94            var objDiv = $(this).find("ul.tags li.promo");
95            var objBase = $(this).find('del.price__inactive').text().replace(/\D/g, '') / 100;
96            var objPromo = $(this).find('.price > p > em').text().replace(/\D/g, '') / 100;
97            var wynik = (objBase - objPromo) / objBase;
98            var wynikP = "-" + (wynik * 100).toFixed(0) + "%";
99            objDiv.html(wynikP);
100
101
102        });
103    }
104  
105var scProductFull = $("#box_productfull");
106var scProductFullPromo = $("#box_productfull ul li.promo");
107
108    if (scProductFullPromo.length > 0) {
109
110        var objDiv2 = $("#box_productfull").find("ul.tags li.promo");
111        var objDivPrice = $("#box_productfull .bottomborder .price");
112        var objBase2 = $('.basket .price del').text().replace(/\D/g, '') / 100;
113        var objPromo2 = $('.basket .price em').text().replace(/\D/g, '') / 100;
114        var wynikZl = objBase2 - objPromo2;
115        var wynik2 = wynikZl / objBase2;
116        var wynikP2 = "-" + (wynik2 * 100).toFixed(0) + "%";
117        var txtSave = "taniej"
118        var wynikP3 = "<div class='sc_box-save-price'><span class='sc_spacing--span'> </span>(-"+ (wynik2 * 100).toFixed(0) + "% "  + txtSave + " )</div>";
119
120        objDiv2.html(wynikP2);
121        objDivPrice.append(wynikP3);
122
123    }
124
125
126
127
128// +- input
129  
130  if (scProductFull.length > 0) {
131  
132  var scAddToFav = $(".addtofav");
133  var scPrDetails = $(".links-q");
134  
135  scAddToFav.appendTo(scPrDetails).wrap("<li></li>");
136  
137    $(".shop_product .quantity_wrap .number-wrap").append('<span class="sc-quantity-plus">+</span>');
138    $(".shop_product .quantity_wrap .number-wrap").prepend('<span class="sc-quantity-minus">-</span>');
139    $('.sc-quantity-plus').on('click', function() {
140        var $sc_quantity = $(this).parent().find('input');
141        var sc_checkValue = parseInt($sc_quantity.val());
142        if (!isNaN(sc_checkValue)) {
143            $sc_quantity.val(sc_checkValue + 1).change(function() {});
144            $sc_quantity.trigger('change');
145        }
146    });
147    $('.sc-quantity-minus').on('click', function() {
148        var $sc_quantity = $(this).parent().find('input');
149        var sc_checkValue = parseInt($sc_quantity.val());
150        if (!isNaN(sc_checkValue) && sc_checkValue > 1) {
151            $sc_quantity.val(sc_checkValue - 1).trigger('change');
152        }
153    });
154} //id pr
155
156});
157
158// doc ready
159
160/*zmiana min*/
161
162Shop.include({selectorFunctions:{imgReplace:{selector:'[data-src][data-src-alt]',domready:function($img){$img.on('mouseenter',function(){$(this).attr('src',$(this).data('srcAlt'));}).on('mouseleave',function(){$(this).attr('src',$(this).data('src'));});}}}});
163/*logotypy slider*/
164Shop.include({
165    selectorFunctions: {
166        boxsliderlogo: {
167            selector: '#sc-slider-logo',
168            load: function(slider, shopInstance) {
169                var isAnimated;
170                isAnimated = false;
171                slider.removeClass('loading');
172                shopInstance.lazypicture.lazyLoading();
173                var _initialSlideWidth = 150,
174                    _slideWidth, _sliderWidth, _visibleSlides, _maxHeight = 0,
175                    _autoMove = true,
176                    _autoMoveDuration = 5600;
177                if (slider.hasClass('slider_automove')) {
178                    _autoMove = true;
179                }
180                var slides = slider.find('.item');
181                if (slides.length > 1) {
182                    var sliderWrap = $('<div class="slider-wrap" />').css('text-align', 'left');
183                    var nav = $('<div />').appendTo(slider);
184                    var prev = $('<span class="slider-nav-left" />').css({
185                        'display': 'none'
186                    }).appendTo(nav);
187                    var next = $('<span class="slider-nav-right" />').css({
188                        'display': 'block'
189                    }).appendTo(nav);
190                    slides.wrapAll(sliderWrap);
191                    sliderWrap = slider.find('.slider-wrap');
192                    shopInstance.addEvent('img:change:slider:' + slider.attr('id'), function() {
193                        sliderWrap.css('height', 'auto');
194                        slides.each(function() {
195                            if ($(this).outerHeight() >= _maxHeight) {
196                                _maxHeight = $(this).outerHeight();
197                                sliderWrap.height(_maxHeight + 6);
198                            }
199                        });
200                    });
201                    $(window).on('resize', function() {
202                        _sliderWidth = slider.outerWidth();
203                        _visibleSlides = Math.floor(_sliderWidth / _initialSlideWidth) || 1;
204                        _slideWidth = _sliderWidth / _visibleSlides;
205                        slides.each(function() {
206                            if ($(this).outerHeight() >= _maxHeight) {
207                                _maxHeight = $(this).outerHeight();
208                            }
209                        });
210                        slides.outerWidth(_slideWidth);
211                        sliderWrap.outerWidth((_slideWidth * slides.length) + 3).height(_maxHeight + 6);
212                        slides.css('left', '0');
213                        if (slides.length > _visibleSlides) {
214                            next.show();
215                            prev.hide();
216                        } else {
217                            next.hide();
218                            prev.hide();
219                        }
220                    }).trigger('resize');
221                    next.on('click', function(ev) {
222                        ev.stopPropagation();
223                        if (!isAnimated) {
224                            slides.animate({
225                                left: "-=" + (_slideWidth)
226                            }, {
227                                duration: 400,
228                                start: function() {
229                                    isAnimated = true;
230                                },
231                                complete: function() {
232                                    var pos = parseInt($(this).css('left'));
233                                    if ((slides.length - _visibleSlides) * Math.floor(_slideWidth) <= -pos) {
234                                        next.hide();
235                                    }
236                                    if (-pos > 0) {
237                                        prev.show();
238                                    }
239                                    isAnimated = false;
240                                }
241                            });
242                        }
243                    });
244                    prev.on('click', function(ev) {
245                        ev.stopPropagation();
246                        if (!isAnimated) {
247                            slides.animate({
248                                left: "+=" + (_slideWidth)
249                            }, {
250                                duration: 400,
251                                start: function() {
252                                    isAnimated = true;
253                                },
254                                complete: function() {
255                                    var pos = parseInt($(this).css('left'));
256                                    if (-pos <= 0) {
257                                        prev.hide();
258                                    }
259                                    if ((slides.length - _visibleSlides) * Math.floor(_slideWidth) >= -pos) {
260                                        next.show();
261                                    }
262                                    isAnimated = false;
263                                }
264                            });
265                        }
266                    });
267                    slider.on('swipeleft', function() {
268                        if (next.is(':visible')) {
269                            next.trigger('click');
270                        }
271                    });
272                    slider.on('swiperight', function() {
273                        if (prev.is(':visible')) {
274                            prev.trigger('click');
275                        }
276                    });
277                    if (_autoMove) {
278                        setInterval(function() {
279                            if (next.is(':visible')) {
280                                next.trigger('click');
281                            } else {
282                                slides.animate({
283                                    left: 0
284                                }, 600, function() {
285                                    next.show();
286                                    prev.hide();
287                                })
288                            }
289                        }, _autoMoveDuration)
290                   }
291                }
292            }
293        },
294    }
295});
296// end logotypy slider
297
298
299
300//megamenu start
301$( document ).ready(function() {
302var scMenu = $(".menu .menu-list");
303    if (scMenu.length > 0) {
304  
305 // kategoria 1 - o id: 59
306$( "li#hcategory_59 div.level1 > ul > li:first-child " )
307.after('<div class="promo1"><a href="#"><img src="/public/assets/promo2.jpg"/></a></div>');
308  
309 
310    }
311});
312
313
314//megamenu end
315
316/*shopcademy szablon Dealer - prosimy nie edytować komentarzy end*/
317
318/* product placement */
319var productPlacement = function(config){
320var init = function(){
321if ($(window).width() <= 768) {
322mobileEvents();
323}
324else{
325desktopEvents();
326}
327
328};
329
330var desktopEvents = function(){
331$('body').on('mouseenter', "a[href*='#prod_id_']", function(e){
332var $btn = $(this);
333var id = parseIds( $btn.attr("href") );
334
335if ($btn.hasClass("product-placed")) {
336return;
337}
338
339this.wait = setTimeout(function(){
340productRequest(id, function(product){
341$btn.addClass('product-placed');
342var $c = renderContaienr();
343var $p = renderProduct(product, false);
344
345$btn.attr("href", product.url);
346$btn.attr("target", "_blank");
347$c.find(".items-wrap-inner").append($p);
348
349$btn.append($c);
350
351setTimeout(function () {
352$btn.addClass("hover");
353}, 10);
354
355$btn.hover(function () {
356$(this).addClass("hover");
357}, function () {
358$(this).removeClass("hover");
359});
360});
361}, 30);
362});
363
364$('body').on('mouseout', "a[href*='#prod_id_']", function(e){
365if(typeof this.wait != 'undefined'){
366clearTimeout(this.wait);
367}
368});
369};
370
371var mobileEvents = function(){
372$('body').on('click', "a[href*='#prod_id_']", function(e) {
373var id = parseIds( $(this).attr("href") );
374var title = $(this).attr("title");
375
376productRequest(id, function (product) {
377var $p = $("<div/>").append( renderProduct(product, true) );
378
379var productPlacementModal = new Shop.Modal({
380showMask: true,
381position: 'center',
382positionType: 'absolute',
383offset: 20,
384header: typeof title == 'string' ? title : "",
385content: $p.html()
386});
387
388productPlacementModal.createModal();
389
390});
391});
392};
393
394var productRequest = function(id, callback){
395frontAPI.getProduct(function (product) {
396callback(product);
397
398
399}, {
400lang: Shop.lang.name,
401currency: Shop.values.currency,
402id: id
403});
404};
405
406var parseIds = function(href){
407var ids = href.replace("#prod_id_", "");
408ids = ids.split("-");
409return parseInt(ids[0]);
410};
411
412var renderProduct = function(p, clickable){
413var $item = $("<span class='item placed-item r--l-flex r--l-flex-vcenter'/>").append($("<span class='side-left'/>"), $("<span class='side-right'/>"));
414
415if(typeof clickable != 'undefined' && clickable == true){
416$item = $("<a href='"+p.url+"' target='_blank' class='item placed-item r--l-flex r--l-flex-vcenter'/>").append($("<span class='side-left'/>"), $("<span class='side-right'/>"));
417}
418
419var src = typeof p.main_image != 'undefined' ? p.main_image : "__overlay";
420var $img = $("<i class='item-img'/>").append($("<img src='/environment/cache/images/150_150_productGfx_"+src+".jpg' alt=''/>"));
421var $name = $("<span class='item-name'/>").text(p.name);
422
423var $avail = config.showAvailability == true ? $("<span class='item-row item-avail'/>").html("<span>"+Shop.lang.quickview.availability+"</span><b>"+p.availability.name+"</b>") : "";
424var $deliv = config.showDelivery == true ? $("<span class='item-row item-deliv'/>").html("<span>"+Shop.lang.quickview.delivery+"</span><b>"+p.delivery.name+"</b>") : "";
425
426var $price = $("<span class='item-price'/>");
427
428var $rate = config.showEvaluation == true ? renderRate(p) : "";
429
430if(typeof p.price != 'undefined'){
431if(config.priceMode == "brutto"){
432$price.append(renderPrice(p.price.gross, "item-price-gross"));
433}
434else if(config.priceMode == "netto"){
435$price.append(renderPrice(p.price.net, "item-price-net"));
436}
437}
438
439$item.find(".side-left").append($img);
440$item.find(".side-right").append($rate, $name, $avail, $deliv, $price);
441return $item;
442};
443
444var renderPrice = function(price, cssClass){
445var $tmp = $("<span class='"+cssClass+"'/>");
446if(price.base_float > price.final_float){
447$tmp.append(
448$("<em/>").text(price.final),
449$("<del/>").text(price.base),
450);
451}
452else{
453$tmp.append(
454$("<em/>").text(price.final)
455);
456}
457
458
459return $tmp.children().length > 0 ? $tmp : "";
460};
461
462var renderRate = function(data){
463if(typeof data.rate != 'undefined'){
464var rate = data.rate;
465var bComma = Math.floor(rate);
466var aComma = rate - bComma;
467var $evaluation = $("<span/>", {
468class: 'evaluation'
469}).append(
470$("<span class='votestars'/>"),
471$("<span class='none'>").text(rate)
472)
473
474for(var i=1; i <= 5; i++){
475var $img = $("<img/>", {
476class: 'px1',
477src: window.shoper.url("libraries/images/1px.gif"),
478alt: ''
479});
480$evaluation.find(".votestars").append(
481$img
482);
483
484if(rate > aComma){
485$img.addClass("star1");
486rate--;
487}
488else if(rate > 0){
489if(aComma >= 0.25 && aComma < 0.75){
490$img.addClass("star0-5");
491}
492else if(aComma >= 0.75){
493$img.addClass("star1");
494}
495rate--;
496}
497else{
498$img.addClass("star0");
499}
500}
501
502return $evaluation;
503}
504return "";
505};
506
507var renderContaienr = function(){
508var html = "<span class='items-wrap'><span class='items-wrap-inner'></span></span>";
509
510return $(html);
511};
512
513var maxAttempt = 20;
514var attempt = 0;
515var _wait = function(){
516if(maxAttempt <= attempt){
517return;
518}
519
520attempt++;
521
522if(typeof window.frontAPI != 'undefined'){
523init();
524}
525else{
526setTimeout(function () {
527_wait();
528}, 50);
529}
530};
531
532_wait();
533};
534
535$(window).ready(function () {
536productPlacement({
537priceMode: "brutto",
538showAvailability: true,
539showDelivery: true,
540showEvaluation: false
541});
542});
543/* eof product placement */
544/* =========================================================
545   POPUP VIDEO - REOLINK
546   ========================================================= */
547document.addEventListener("DOMContentLoaded", function () {
548
549    document.querySelectorAll(".openVideoBox").forEach(function(button){
550
551        button.addEventListener("click", function(){
552
553            var videoURL = this.getAttribute("data-video");
554
555            var modal = document.getElementById("videoModal");
556            var frame = document.getElementById("youtubeFrame");
557
558            /* Jeśli iframe nie istnieje, utwórz go w pustym kontenerze */
559            if (!frame && modal) {
560
561                var container = modal.querySelector("div > div:last-child");
562
563                if (container) {
564
565                    frame = document.createElement("iframe");
566
567                    frame.id = "youtubeFrame";
568                    frame.style.position = "absolute";
569                    frame.style.left = "0";
570                    frame.style.top = "0";
571                    frame.style.width = "100%";
572                    frame.style.height = "100%";
573                    frame.style.border = "0";
574
575                    frame.setAttribute("allowfullscreen", "allowfullscreen");
576
577                    container.appendChild(frame);
578                }
579            }
580
581            if (frame && modal) {
582
583                var separator = videoURL.indexOf("?") !== -1 ? "&" : "?";
584
585                frame.src = videoURL + separator + "autoplay=1";
586                modal.style.display = "block";
587
588            }
589
590        });
591
592    });
593
594
595    var close = document.getElementById("closeVideoBox");
596
597    if(close){
598        close.onclick = function(){
599
600            document.getElementById("videoModal").style.display = "none";
601
602            var frame = document.getElementById("youtubeFrame");
603
604            if(frame){
605                frame.src = "";
606            }
607
608        };
609    }
610
611});
612document.addEventListener("DOMContentLoaded", function () {
613
614    /* ==========================
615       EDYTUJ TYLKO TE DANE
616    =========================== */
617
618    const promoId = "lipiec2026";
619
620    const promoEnds = new Date("2026-09-14T23:59:59");
621
622    const buttonLink = "https://reolink-sklep.pl/pl/promotions";
623
624    const buttonText = "Sprawdź";
625
626    const message = "🎒 Bezpieczny powrót do szkoły. Więcej spokoju dla rodzica — do -31% taniej";
627
628    /* TEKST NA MOBILE */
629    const mobileMessage = "🎒 Back to school! Rabaty do nawet -31%";
630
631
632    /* ========================== */
633
634    // Jeśli promocja już się skończyła — nie pokazuj paska
635    if (new Date() >= promoEnds) {
636        return;
637    }
638
639
640    const bar = document.createElement("div");
641
642    bar.id = "promo-bar";
643
644
645    /*
646       MOBILE / DESKTOP
647       Wykrywamy szerokość ekranu
648    */
649
650    const isMobile = window.innerWidth <= 768;
651
652
653    if (isMobile) {
654
655        /* ==========================================
656           MOBILE — minimalistyczny pasek
657           ========================================== */
658
659        bar.innerHTML = `
660            <a href="${buttonLink}" class="promo-container promo-mobile-link">
661
662                <div class="promo-text">
663                    ${mobileMessage}
664                    <span class="promo-arrow">›</span>
665                </div>
666
667                <div class="promo-close">&times;</div>
668
669            </a>
670        `;
671
672    } else {
673
674        /* ==========================================
675           DESKTOP — obecna wersja
676           ========================================== */
677
678        bar.innerHTML = `
679            <div class="promo-container">
680
681                <div class="promo-text">
682                    ${message}
683                    <span class="promo-countdown"></span>
684                </div>
685
686                <a href="${buttonLink}" class="promo-btn">
687                    ${buttonText}
688                </a>
689
690                <div class="promo-close">&times;</div>
691
692            </div>
693        `;
694
695    }
696
697
698    document.body.appendChild(bar);
699
700
701    /* ==================================================
702       MOBILE
703       ================================================== */
704
705    if (isMobile) {
706
707        bar.querySelector(".promo-close").addEventListener("click", function (e) {
708
709            e.preventDefault();
710            e.stopPropagation();
711
712            bar.remove();
713
714        });
715
716        return;
717    }
718
719
720    /* ==================================================
721       DESKTOP — LICZNIK
722       ================================================== */
723
724    const countdown = bar.querySelector(".promo-countdown");
725
726
727    function updateTimer(){
728
729        const now = new Date();
730
731        const diff = promoEnds - now;
732
733
734        // Po zakończeniu promocji usuń pasek
735        if(diff <= 0){
736
737            bar.remove();
738
739            return;
740
741        }
742
743
744        const days = Math.floor(diff / 86400000);
745
746        const hours = Math.floor((diff % 86400000) / 3600000);
747
748        const minutes = Math.floor((diff % 3600000) / 60000);
749
750
751        if(days > 0){
752
753            countdown.textContent =
754                ` Pozostało: ${days}d ${hours}godz ${minutes}min`;
755
756        } else {
757
758            countdown.textContent =
759                ` Pozostało: ${hours}h ${minutes}min`;
760
761        }
762
763    }
764
765
766    updateTimer();
767
768
769    // Odświeżanie licznika co minutę
770    const timer = setInterval(function(){
771
772        updateTimer();
773
774        if(!document.body.contains(bar)){
775            clearInterval(timer);
776        }
777
778    }, 60000);
779
780
781    /* ==================================================
782       ZAMKNIĘCIE — DESKTOP
783       ================================================== */
784
785    bar.querySelector(".promo-close").addEventListener("click", function () {
786
787        bar.remove();
788
789    });
790
791});
792/* =====================================================
793   BLOG SLIDER MOBILE
794===================================================== */
795
796document.addEventListener("DOMContentLoaded", function () {
797
798    const blogBox = document.querySelector("#box_articlelistsmall");
799
800    if (!blogBox) return;
801
802
803    const container = blogBox.querySelector(".innerbox");
804    const articles = blogBox.querySelectorAll("article.article-small");
805
806
807    if (!container || articles.length === 0) return;
808
809
810    // tylko mobile
811
812    function initBlogSlider(){
813
814        if(window.innerWidth > 768){
815
816            container.style.transform = "";
817            return;
818
819        }
820
821
822        let currentSlide = 0;
823
824
825        // dodanie strzałek
826
827        if(!blogBox.querySelector(".blog-slider-prev")){
828
829
830            const prev = document.createElement("div");
831
832            prev.className = "blog-slider-arrow blog-slider-prev";
833
834            prev.innerHTML = "‹";
835
836
837            const next = document.createElement("div");
838
839            next.className = "blog-slider-arrow blog-slider-next";
840
841            next.innerHTML = "›";
842
843
844            blogBox.appendChild(prev);
845            blogBox.appendChild(next);
846
847
848
849         function moveSlider(){
850
851    container.scrollTo({
852    left: articles[currentSlide].offsetLeft,
853    behavior: "smooth"
854});
855
856}
857
858
859
860            next.addEventListener("click", function(){
861
862                if(currentSlide < articles.length - 1){
863
864                    currentSlide++;
865
866                    moveSlider();
867
868                }
869
870            });
871
872
873
874            prev.addEventListener("click", function(){
875
876                if(currentSlide > 0){
877
878                    currentSlide--;
879
880                    moveSlider();
881
882                }
883
884            });
885
886
887
888            // obsługa przesuwania palcem
889
890            let startX = 0;
891            let endX = 0;
892
893
894            container.addEventListener("touchstart", function(e){
895
896                startX = e.touches[0].clientX;
897
898            });
899
900
901            container.addEventListener("touchend", function(e){
902
903                endX = e.changedTouches[0].clientX;
904
905
906                if(startX - endX > 50){
907
908                    if(currentSlide < articles.length - 1){
909
910                        currentSlide++;
911
912                        moveSlider();
913
914                    }
915
916                }
917
918
919                if(endX - startX > 50){
920
921                    if(currentSlide > 0){
922
923                        currentSlide--;
924
925                        moveSlider();
926
927                    }
928
929                }
930
931
932            });
933
934
935        }
936
937    }
938
939
940    initBlogSlider();
941
942
943    window.addEventListener("resize", initBlogSlider);
944
945
946});
947/* ==========================================
948PRODUCT SLIDER
949Bestsellery + Nowości + Promocje
950Mobile + Desktop
951========================================== */
952
953document.addEventListener("DOMContentLoaded", function () {
954
955    function initProductSlider(boxSelector, sliderSelector) {
956
957        const box = document.querySelector(boxSelector);
958
959        if (!box) return;
960
961        const slider = box.querySelector(sliderSelector);
962
963        if (!slider) return;
964
965        const products = slider.querySelectorAll(".product");
966
967        if (!products.length) return;
968
969
970        /* ==========================================
971        STRZAŁKI
972        ========================================== */
973
974        const prev = document.createElement("div");
975
976        prev.className = "blog-slider-arrow products-slider-prev";
977
978        prev.innerHTML = "‹";
979
980
981        const next = document.createElement("div");
982
983        next.className = "blog-slider-arrow products-slider-next";
984
985        next.innerHTML = "›";
986
987
988        box.appendChild(prev);
989
990        box.appendChild(next);
991
992
993        /* ==========================================
994        AKTUALIZACJA STRZAŁEK
995        ========================================== */
996
997        function updateArrows() {
998
999            const maxScroll =
1000                slider.scrollWidth - slider.clientWidth;
1001
1002
1003            if (maxScroll > 2) {
1004
1005                prev.style.display =
1006                    slider.scrollLeft > 2
1007                        ? "flex"
1008                        : "none";
1009
1010
1011                next.style.display =
1012                    slider.scrollLeft < maxScroll - 2
1013                        ? "flex"
1014                        : "none";
1015
1016            } else {
1017
1018                prev.style.display = "none";
1019                next.style.display = "none";
1020
1021            }
1022
1023        }
1024
1025
1026        /* ==========================================
1027        PRZESUNIĘCIE O JEDNĄ KARTĘ
1028        ========================================== */
1029
1030        function moveSlider(direction) {
1031
1032            const firstProduct = products[0];
1033
1034            if (!firstProduct) return;
1035
1036
1037            const productWidth =
1038                firstProduct.getBoundingClientRect().width;
1039
1040
1041            const computed =
1042                window.getComputedStyle(firstProduct);
1043
1044
1045            const marginLeft =
1046                parseFloat(computed.marginLeft) || 0;
1047
1048
1049            const marginRight =
1050                parseFloat(computed.marginRight) || 0;
1051
1052
1053            const move =
1054                productWidth +
1055                marginLeft +
1056                marginRight;
1057
1058
1059            slider.scrollBy({
1060
1061                left: direction * move,
1062
1063                behavior: "smooth"
1064
1065            });
1066
1067        }
1068
1069
1070        /* ==========================================
1071        KLIK NEXT
1072        ========================================== */
1073
1074        next.addEventListener("click", function () {
1075
1076            moveSlider(1);
1077
1078        });
1079
1080
1081        /* ==========================================
1082        KLIK PREV
1083        ========================================== */
1084
1085        prev.addEventListener("click", function () {
1086
1087            moveSlider(-1);
1088
1089        });
1090
1091
1092        /* ==========================================
1093        SCROLL
1094        ========================================== */
1095
1096        slider.addEventListener(
1097            "scroll",
1098            updateArrows
1099        );
1100
1101
1102        /* ==========================================
1103        RESIZE
1104        ========================================== */
1105
1106        window.addEventListener(
1107            "resize",
1108            updateArrows
1109        );
1110
1111
1112        /* ==========================================
1113        OBSERWATOR ZMIANY ROZMIARU
1114        ========================================== */
1115
1116        if (typeof ResizeObserver !== "undefined") {
1117
1118            const observer =
1119                new ResizeObserver(function () {
1120
1121                    requestAnimationFrame(function () {
1122
1123                        updateArrows();
1124
1125                    });
1126
1127                });
1128
1129
1130            observer.observe(slider);
1131
1132        }
1133
1134
1135        /* ==========================================
1136        INICJALIZACJA
1137        ========================================== */
1138
1139        function refreshSlider() {
1140
1141            /* wymuszenie przeliczenia layoutu */
1142
1143            void slider.offsetWidth;
1144
1145            updateArrows();
1146
1147        }
1148
1149
1150        /* natychmiast */
1151
1152        refreshSlider();
1153
1154
1155        /* po pełnym załadowaniu */
1156
1157        window.addEventListener(
1158            "load",
1159            refreshSlider
1160        );
1161
1162
1163        /* dodatkowe zabezpieczenie
1164           dla elementów ładowanych przez Shoper */
1165
1166        requestAnimationFrame(function () {
1167
1168            requestAnimationFrame(function () {
1169
1170                refreshSlider();
1171
1172            });
1173
1174        });
1175
1176    }
1177
1178
1179    /* ==========================================
1180    BESTSELLERY
1181    ========================================== */
1182
1183    initProductSlider(
1184        "#box_bestsellers",
1185        ".products-slider"
1186    );
1187
1188
1189    /* ==========================================
1190    NOWOŚCI
1191    ========================================== */
1192
1193    initProductSlider(
1194        "#box_lastadded",
1195        ".innerbox"
1196    );
1197
1198
1199    /* ==========================================
1200    PROMOCJE
1201    ========================================== */
1202
1203    initProductSlider(
1204        "#box_specialoffer",
1205        ".innerbox"
1206    );
1207 /* ==========================================
1208REOLINK - PRODUKTY POWIĄZANE
1209Slider dla 6+ produktów
1210========================================== */
1211
1212function initReolinkRelatedSlider() {
1213
1214    const box = document.querySelector(
1215        "#reolink-related-top"
1216    );
1217
1218    if (!box) return false;
1219
1220
1221    const slider = box.querySelector(
1222        ".reolink-related-top-products"
1223    );
1224
1225    if (!slider) return false;
1226
1227
1228    const products = slider.querySelectorAll(
1229        ".reolink-related-product"
1230    );
1231
1232
1233    /* ==========================================
1234    JEŚLI 5 LUB MNIEJ
1235    ========================================== */
1236
1237    if (products.length <= 5) {
1238
1239        slider.classList.remove(
1240            "reolink-related-slider"
1241        );
1242
1243        return true;
1244
1245    }
1246
1247
1248    /* ==========================================
1249    JEŚLI SLIDER JUŻ ZOSTAŁ URUCHOMIONY
1250    ========================================== */
1251
1252    if (
1253        slider.classList.contains(
1254            "reolink-related-slider"
1255        )
1256    ) {
1257
1258        updateReolinkRelatedArrows(
1259            box,
1260            slider
1261        );
1262
1263        return true;
1264
1265    }
1266
1267
1268    /* ==========================================
1269    WŁĄCZ SLIDER
1270    ========================================== */
1271
1272    slider.classList.add(
1273        "reolink-related-slider"
1274    );
1275
1276
1277    /* ==========================================
1278    STRZAŁKA LEWA
1279    ========================================== */
1280
1281    const prev =
1282        document.createElement("div");
1283
1284    prev.className =
1285        "blog-slider-arrow reolink-related-prev";
1286
1287    prev.innerHTML = "‹";
1288
1289
1290    /* ==========================================
1291    STRZAŁKA PRAWA
1292    ========================================== */
1293
1294    const next =
1295        document.createElement("div");
1296
1297    next.className =
1298        "blog-slider-arrow reolink-related-next";
1299
1300    next.innerHTML = "›";
1301
1302
1303    box.appendChild(prev);
1304
1305    box.appendChild(next);
1306
1307
1308    /* ==========================================
1309    PRZESUWANIE O JEDNĄ KARTĘ
1310    ========================================== */
1311
1312    function moveSlider(direction) {
1313
1314        const firstProduct =
1315            slider.querySelector(
1316                ".reolink-related-product"
1317            );
1318
1319        if (!firstProduct) return;
1320
1321
1322        const productWidth =
1323            firstProduct.getBoundingClientRect()
1324                .width;
1325
1326
1327        const gap =
1328            parseFloat(
1329                window.getComputedStyle(slider)
1330                    .columnGap
1331            ) || 16;
1332
1333
1334        slider.scrollBy({
1335
1336            left:
1337                direction *
1338                (productWidth + gap),
1339
1340            behavior: "smooth"
1341
1342        });
1343
1344    }
1345
1346
1347    /* ==========================================
1348    NEXT
1349    ========================================== */
1350
1351    next.addEventListener(
1352        "click",
1353        function () {
1354
1355            moveSlider(1);
1356
1357        }
1358    );
1359
1360
1361    /* ==========================================
1362    PREV
1363    ========================================== */
1364
1365    prev.addEventListener(
1366        "click",
1367        function () {
1368
1369            moveSlider(-1);
1370
1371        }
1372    );
1373
1374
1375    /* ==========================================
1376    AKTUALIZACJA STRZAŁEK
1377    ========================================== */
1378
1379    function updateArrows() {
1380
1381        updateReolinkRelatedArrows(
1382            box,
1383            slider
1384        );
1385
1386    }
1387
1388
1389    slider.addEventListener(
1390        "scroll",
1391        updateArrows
1392    );
1393
1394
1395    window.addEventListener(
1396        "resize",
1397        updateArrows
1398    );
1399
1400
1401    /* ==========================================
1402    START
1403    ========================================== */
1404
1405    requestAnimationFrame(
1406        function () {
1407
1408            requestAnimationFrame(
1409                function () {
1410
1411                    updateArrows();
1412
1413                }
1414            );
1415
1416        }
1417    );
1418
1419
1420    return true;
1421
1422}
1423
1424
1425/* ==========================================
1426AKTUALIZACJA STRZAŁEK
1427========================================== */
1428
1429function updateReolinkRelatedArrows(
1430    box,
1431    slider
1432) {
1433
1434    const prev =
1435        box.querySelector(
1436            ".reolink-related-prev"
1437        );
1438
1439    const next =
1440        box.querySelector(
1441            ".reolink-related-next"
1442        );
1443
1444
1445    if (!prev || !next) return;
1446
1447
1448    const maxScroll =
1449        slider.scrollWidth -
1450        slider.clientWidth;
1451
1452
1453    if (maxScroll > 2) {
1454
1455        prev.style.display =
1456            slider.scrollLeft > 2
1457                ? "flex"
1458                : "none";
1459
1460
1461        next.style.display =
1462            slider.scrollLeft <
1463            maxScroll - 2
1464                ? "flex"
1465                : "none";
1466
1467    } else {
1468
1469        prev.style.display = "none";
1470
1471        next.style.display = "none";
1472
1473    }
1474
1475}
1476
1477
1478/* ==========================================
1479PIERWSZA PRÓBA
1480========================================== */
1481
1482initReolinkRelatedSlider();
1483
1484
1485/* ==========================================
1486PO ZAŁADOWANIU STRONY
1487========================================== */
1488
1489window.addEventListener(
1490    "load",
1491    function () {
1492
1493        initReolinkRelatedSlider();
1494
1495    }
1496);
1497
1498
1499/* ==========================================
1500DODATKOWE SPRAWDZENIE
1501Dla Shoper / dynamicznego DOM
1502========================================== */
1503
1504setTimeout(
1505    function () {
1506
1507        initReolinkRelatedSlider();
1508
1509    },
1510    300
1511);
1512
1513
1514setTimeout(
1515    function () {
1516
1517        initReolinkRelatedSlider();
1518
1519    },
1520    1000
1521);
1522
1523
1524setTimeout(
1525    function () {
1526
1527        initReolinkRelatedSlider();
1528
1529    },
1530    2000
1531);
1532});
1533document.addEventListener('DOMContentLoaded', function () {
1534
1535    const boxes = [
1536        '#box_bestsellers',
1537        '#box_lastadded',
1538        '#box_specialoffer'
1539    ];
1540
1541    boxes.forEach(function (boxSelector) {
1542
1543        const box = document.querySelector(boxSelector);
1544
1545        if (!box) {
1546            return;
1547        }
1548
1549        const products = box.querySelectorAll('.product');
1550
1551        products.forEach(function (product) {
1552
1553            /* Tylko produkty promocyjne */
1554            const regularPrice = product.querySelector('.price__regular del');
1555            const currentPrice = product.querySelector('.price > p:first-child em');
1556
1557            if (!regularPrice || !currentPrice) {
1558                return;
1559            }
1560
1561            /* Pobranie cen */
1562            const regularText = regularPrice.textContent
1563                .replace(/\s/g, '')
1564                .replace(',', '.')
1565                .replace(/[^\d.]/g, '');
1566
1567            const currentText = currentPrice.textContent
1568                .replace(/\s/g, '')
1569                .replace(',', '.')
1570                .replace(/[^\d.]/g, '');
1571
1572            const regular = parseFloat(regularText);
1573            const current = parseFloat(currentText);
1574
1575            if (
1576                !Number.isFinite(regular) ||
1577                !Number.isFinite(current) ||
1578                regular <= 0 ||
1579                current >= regular
1580            ) {
1581                return;
1582            }
1583
1584            /* Obliczenie rabatu */
1585            const discount = Math.round(
1586                ((regular - current) / regular) * 100
1587            );
1588
1589            if (discount <= 0) {
1590                return;
1591            }
1592
1593            /* Nie dodawaj badge'a drugi raz */
1594            if (product.querySelector('.promo-badge')) {
1595                return;
1596            }
1597
1598            /* Utworzenie badge'a */
1599            const badge = document.createElement('div');
1600
1601            badge.className = 'promo-badge';
1602
1603            badge.textContent = discount + '% TANIEJ';
1604
1605            product.appendChild(badge);
1606
1607        });
1608
1609    });
1610console.log(
1611    "REOLINK TEST:",
1612    document.querySelector("#reolink-related-top")
1613);
1614
1615console.log(
1616    "REOLINK PRODUCTS:",
1617    document.querySelectorAll(
1618        "#reolink-related-top .reolink-related-product"
1619    ).length
1620);
1621});
1622document.addEventListener('DOMContentLoaded', function () {
1623
1624    document.querySelectorAll('.avail').forEach(function (availabilityBox) {
1625
1626        const statuses = availabilityBox.querySelectorAll('.availability');
1627
1628        if (statuses.length < 2) {
1629            return;
1630        }
1631
1632        const status = statuses[1].textContent.trim().toLowerCase();
1633
1634        if (status !== 'na wyczerpaniu') {
1635            return;
1636        }
1637
1638        const product = availabilityBox.closest('.product');
1639
1640        if (!product) {
1641            return;
1642        }
1643
1644        if (product.querySelector('.last-pieces-badge')) {
1645            return;
1646        }
1647
1648        const imageBox = product.querySelector('.prodimage');
1649
1650        if (!imageBox) {
1651            return;
1652        }
1653
1654        imageBox.style.position = 'relative';
1655
1656        const badge = document.createElement('span');
1657
1658        badge.className = 'last-pieces-badge';
1659        badge.textContent = 'OSTATNIE SZTUKI';
1660
1661        imageBox.appendChild(badge);
1662
1663    });
1664
1665});
1666document.addEventListener('DOMContentLoaded', function () {
1667
1668    document.querySelectorAll('#box_articlelist article').forEach(function (article) {
1669
1670        var image = article.querySelector('.article-image');
1671
1672        if (image) {
1673            article.insertBefore(image, article.firstElementChild);
1674        }
1675
1676    });
1677
1678});
1679document.addEventListener("DOMContentLoaded", function () {
1680
1681    var module = document.getElementById("bts-battery-module");
1682
1683    if (!module) {
1684        return;
1685    }
1686
1687    var track =
1688        document.getElementById("bts-battery-track");
1689
1690    var categoryUrl =
1691        "/pl/c/Kamery-Akumulatorowe/13";
1692
1693    var limit = 5;
1694
1695
1696    console.log("BTS: moduł znaleziony");
1697
1698
1699    fetch(categoryUrl)
1700
1701        .then(function (response) {
1702
1703            if (!response.ok) {
1704                throw new Error(
1705                    "HTTP " + response.status
1706                );
1707            }
1708
1709            return response.text();
1710
1711        })
1712
1713        .then(function (html) {
1714
1715            var parser =
1716                new DOMParser();
1717
1718            var doc =
1719                parser.parseFromString(
1720                    html,
1721                    "text/html"
1722                );
1723
1724
1725            var products =
1726                Array.prototype.slice.call(
1727                    doc.querySelectorAll(
1728                        "#box_mainproducts .product[data-product-id]"
1729                    )
1730                );
1731
1732
1733            console.log(
1734                "BTS: znaleziono produktów:",
1735                products.length
1736            );
1737
1738
1739            /*
1740            ===============================
1741            TYLKO DOSTĘPNE
1742            ===============================
1743            */
1744
1745            products = products.filter(
1746                function (product) {
1747
1748                    var availability =
1749                        product.querySelector(".avail");
1750
1751                    if (!availability) {
1752                        return true;
1753                    }
1754
1755                    var text =
1756                        availability.textContent
1757                            .trim()
1758                            .toLowerCase();
1759
1760                    return (
1761                        text.indexOf(
1762                            "brak towaru"
1763                        ) === -1
1764                    );
1765
1766                }
1767            );
1768
1769
1770            /*
1771            ===============================
1772            LOSOWANIE
1773            ===============================
1774            */
1775
1776            products.sort(function () {
1777                return Math.random() - 0.5;
1778            });
1779
1780
1781            /*
1782            ===============================
1783            8 PRODUKTÓW
1784            ===============================
1785            */
1786
1787            products =
1788                products.slice(0, limit);
1789
1790
1791            track.innerHTML = "";
1792
1793
1794            /*
1795            ===============================
1796            KLONOWANIE
1797            ===============================
1798            */
1799
1800            products.forEach(
1801                function (product) {
1802
1803                    var card =
1804                        product.cloneNode(true);
1805var promoBadge = card.querySelector(".tags .promo span");
1806
1807if (promoBadge) {
1808
1809    var currentPriceElement =
1810        card.querySelector(".price em");
1811
1812    var regularPriceElement =
1813        card.querySelector(".price__regular del");
1814
1815    if (
1816        currentPriceElement &&
1817        regularPriceElement
1818    ) {
1819
1820        var currentPrice =
1821            parseFloat(
1822                currentPriceElement.textContent
1823                    .replace(/\s/g, "")
1824                    .replace(",", ".")
1825                    .replace("zł", "")
1826            );
1827
1828        var regularPrice =
1829            parseFloat(
1830                regularPriceElement.textContent
1831                    .replace(/\s/g, "")
1832                    .replace(",", ".")
1833                    .replace("zł", "")
1834            );
1835
1836        if (
1837            !isNaN(currentPrice) &&
1838            !isNaN(regularPrice) &&
1839            regularPrice > currentPrice
1840        ) {
1841
1842            var discount =
1843                Math.round(
1844                    ((regularPrice - currentPrice) /
1845                    regularPrice) * 100
1846                );
1847
1848            promoBadge.textContent =
1849                "" + discount + "% TANIEJ";
1850
1851        }
1852
1853    }
1854
1855}
1856
1857                    /*
1858                    ZDJĘCIA
1859                    */
1860
1861                    var images =
1862                        card.querySelectorAll(
1863                            "img[data-src]"
1864                        );
1865
1866
1867                    Array.prototype.forEach.call(
1868                        images,
1869                        function (img) {
1870
1871                            var src =
1872                                img.getAttribute(
1873                                    "data-src"
1874                                );
1875
1876                            if (src) {
1877                                img.src = src;
1878                            }
1879
1880                        }
1881                    );
1882
1883
1884                    /*
1885                    DODAJEMY WŁASNĄ KLASĘ
1886                    */
1887
1888                    card.classList.add(
1889                        "bts-battery-card"
1890                    );
1891
1892
1893                    track.appendChild(card);
1894
1895                }
1896            );
1897
1898
1899            console.log(
1900                "BTS: wyświetlono:",
1901                products.length
1902            );
1903
1904        })
1905
1906        .catch(function (error) {
1907
1908            console.error(
1909                "BTS ERROR:",
1910                error
1911            );
1912
1913            track.innerHTML =
1914                "Nie udało się pobrać produktów.";
1915
1916        });
1917
1918});
1919document.addEventListener("DOMContentLoaded", function () {
1920
1921    var module = document.getElementById("bts-wireless-module");
1922
1923    if (!module) {
1924        return;
1925    }
1926
1927    var track =
1928        document.getElementById("bts-wireless-track");
1929
1930    var categoryUrl =
1931        "/pl/c/Kamery-Bezprzewodowe/14";
1932
1933    var limit = 5;
1934
1935
1936    console.log("BTS WIRELESS: moduł znaleziony");
1937
1938
1939    fetch(categoryUrl)
1940
1941        .then(function (response) {
1942
1943            if (!response.ok) {
1944                throw new Error(
1945                    "HTTP " + response.status
1946                );
1947            }
1948
1949            return response.text();
1950
1951        })
1952
1953        .then(function (html) {
1954
1955            var parser =
1956                new DOMParser();
1957
1958            var doc =
1959                parser.parseFromString(
1960                    html,
1961                    "text/html"
1962                );
1963
1964
1965            var products =
1966                Array.prototype.slice.call(
1967                    doc.querySelectorAll(
1968                        "#box_mainproducts .product[data-product-id]"
1969                    )
1970                );
1971
1972
1973            console.log(
1974                "BTS WIRELESS: znaleziono produktów:",
1975                products.length
1976            );
1977
1978
1979            /*
1980            ===============================
1981            TYLKO DOSTĘPNE
1982            ===============================
1983            */
1984
1985            products = products.filter(
1986                function (product) {
1987
1988                    var availability =
1989                        product.querySelector(".avail");
1990
1991                    if (!availability) {
1992                        return true;
1993                    }
1994
1995                    var text =
1996                        availability.textContent
1997                            .trim()
1998                            .toLowerCase();
1999
2000                    return (
2001                        text.indexOf(
2002                            "brak towaru"
2003                        ) === -1
2004                    );
2005
2006                }
2007            );
2008
2009
2010            /*
2011            ===============================
2012            LOSOWANIE
2013            ===============================
2014            */
2015
2016            products.sort(function () {
2017                return Math.random() - 0.5;
2018            });
2019
2020
2021            /*
2022            ===============================
2023            5 PRODUKTÓW
2024            ===============================
2025            */
2026
2027            products =
2028                products.slice(0, limit);
2029
2030
2031            track.innerHTML = "";
2032
2033
2034            /*
2035            ===============================
2036            KLONOWANIE
2037            ===============================
2038            */
2039
2040            products.forEach(
2041                function (product) {
2042
2043                    var card =
2044                        product.cloneNode(true);
2045
2046
2047                    /*
2048                    ===============================
2049                    BADGE PROMOCJI
2050                    ===============================
2051                    */
2052
2053                    var promoBadge =
2054                        card.querySelector(
2055                            ".tags .promo span"
2056                        );
2057
2058
2059                    if (promoBadge) {
2060
2061                        var currentPriceElement =
2062                            card.querySelector(
2063                                ".price em"
2064                            );
2065
2066                        var regularPriceElement =
2067                            card.querySelector(
2068                                ".price__regular del"
2069                            );
2070
2071
2072                        if (
2073                            currentPriceElement &&
2074                            regularPriceElement
2075                        ) {
2076
2077                            var currentPrice =
2078                                parseFloat(
2079                                    currentPriceElement.textContent
2080                                        .replace(/\s/g, "")
2081                                        .replace(",", ".")
2082                                        .replace("zł", "")
2083                                );
2084
2085
2086                            var regularPrice =
2087                                parseFloat(
2088                                    regularPriceElement.textContent
2089                                        .replace(/\s/g, "")
2090                                        .replace(",", ".")
2091                                        .replace("zł", "")
2092                                );
2093
2094
2095                            if (
2096                                !isNaN(currentPrice) &&
2097                                !isNaN(regularPrice) &&
2098                                regularPrice > currentPrice
2099                            ) {
2100
2101                                var discount =
2102                                    Math.round(
2103                                        (
2104                                            (regularPrice - currentPrice) /
2105                                            regularPrice
2106                                        ) * 100
2107                                    );
2108
2109
2110                                promoBadge.textContent =
2111                                    discount + "% TANIEJ";
2112
2113                            }
2114
2115                        }
2116
2117                    }
2118
2119
2120                    /*
2121                    ===============================
2122                    ZDJĘCIA
2123                    ===============================
2124                    */
2125
2126                    var images =
2127                        card.querySelectorAll(
2128                            "img[data-src]"
2129                        );
2130
2131
2132                    Array.prototype.forEach.call(
2133                        images,
2134                        function (img) {
2135
2136                            var src =
2137                                img.getAttribute(
2138                                    "data-src"
2139                                );
2140
2141                            if (src) {
2142                                img.src = src;
2143                            }
2144
2145                        }
2146                    );
2147
2148
2149                    /*
2150                    ===============================
2151                    DODAJEMY WŁASNĄ KLASĘ
2152                    ===============================
2153                    */
2154
2155                    card.classList.add(
2156                        "bts-wireless-card"
2157                    );
2158
2159
2160                    track.appendChild(card);
2161
2162                }
2163            );
2164
2165
2166            console.log(
2167                "BTS WIRELESS: wyświetlono:",
2168                products.length
2169            );
2170
2171        })
2172
2173        .catch(function (error) {
2174
2175            console.error(
2176                "BTS WIRELESS ERROR:",
2177                error
2178            );
2179
2180            track.innerHTML =
2181                "Nie udało się pobrać produktów.";
2182
2183        });
2184
2185});
2186document.addEventListener("DOMContentLoaded", function () {
2187
2188    var module = document.getElementById("bts-poe-module");
2189
2190    if (!module) {
2191        return;
2192    }
2193
2194    var track =
2195        document.getElementById("bts-poe-track");
2196
2197    var categoryUrl =
2198        "/pl/c/Kamery-POE/15";
2199
2200    var limit = 5;
2201
2202
2203    console.log("BTS POE: moduł znaleziony");
2204
2205
2206    fetch(categoryUrl)
2207
2208        .then(function (response) {
2209
2210            if (!response.ok) {
2211                throw new Error(
2212                    "HTTP " + response.status
2213                );
2214            }
2215
2216            return response.text();
2217
2218        })
2219
2220        .then(function (html) {
2221
2222            var parser =
2223                new DOMParser();
2224
2225            var doc =
2226                parser.parseFromString(
2227                    html,
2228                    "text/html"
2229                );
2230
2231
2232            var products =
2233                Array.prototype.slice.call(
2234                    doc.querySelectorAll(
2235                        "#box_mainproducts .product[data-product-id]"
2236                    )
2237                );
2238
2239
2240            console.log(
2241                "BTS POE: znaleziono produktów:",
2242                products.length
2243            );
2244
2245
2246            /*
2247            ===============================
2248            TYLKO DOSTĘPNE
2249            ===============================
2250            */
2251
2252            products = products.filter(
2253                function (product) {
2254
2255                    var availability =
2256                        product.querySelector(".avail");
2257
2258                    if (!availability) {
2259                        return true;
2260                    }
2261
2262                    var text =
2263                        availability.textContent
2264                            .trim()
2265                            .toLowerCase();
2266
2267                    return (
2268                        text.indexOf(
2269                            "brak towaru"
2270                        ) === -1
2271                    );
2272
2273                }
2274            );
2275
2276
2277            /*
2278            ===============================
2279            LOSOWANIE
2280            ===============================
2281            */
2282
2283            products.sort(function () {
2284                return Math.random() - 0.5;
2285            });
2286
2287
2288            /*
2289            ===============================
2290            5 PRODUKTÓW
2291            ===============================
2292            */
2293
2294            products =
2295                products.slice(0, limit);
2296
2297
2298            track.innerHTML = "";
2299
2300
2301            /*
2302            ===============================
2303            KLONOWANIE
2304            ===============================
2305            */
2306
2307            products.forEach(
2308                function (product) {
2309
2310                    var card =
2311                        product.cloneNode(true);
2312
2313
2314                    /*
2315                    ===============================
2316                    OBLICZANIE RABATU
2317                    ===============================
2318                    */
2319
2320                    var promoBadge =
2321                        card.querySelector(
2322                            ".tags .promo span"
2323                        );
2324
2325
2326                    if (promoBadge) {
2327
2328                        var currentPriceElement =
2329                            card.querySelector(
2330                                ".price em"
2331                            );
2332
2333                        var regularPriceElement =
2334                            card.querySelector(
2335                                ".price__regular del"
2336                            );
2337
2338
2339                        if (
2340                            currentPriceElement &&
2341                            regularPriceElement
2342                        ) {
2343
2344                            var currentPrice =
2345                                parseFloat(
2346                                    currentPriceElement.textContent
2347                                        .replace(/\s/g, "")
2348                                        .replace(",", ".")
2349                                        .replace("zł", "")
2350                                );
2351
2352
2353                            var regularPrice =
2354                                parseFloat(
2355                                    regularPriceElement.textContent
2356                                        .replace(/\s/g, "")
2357                                        .replace(",", ".")
2358                                        .replace("zł", "")
2359                                );
2360
2361
2362                            if (
2363                                !isNaN(currentPrice) &&
2364                                !isNaN(regularPrice) &&
2365                                regularPrice > currentPrice
2366                            ) {
2367
2368                                var discount =
2369                                    Math.round(
2370                                        (
2371                                            (regularPrice - currentPrice) /
2372                                            regularPrice
2373                                        ) * 100
2374                                    );
2375
2376
2377                                promoBadge.textContent =
2378                                    discount + "% TANIEJ";
2379
2380                            }
2381
2382                        }
2383
2384                    }
2385
2386
2387                    /*
2388                    ===============================
2389                    ZDJĘCIA
2390                    ===============================
2391                    */
2392
2393                    var images =
2394                        card.querySelectorAll(
2395                            "img[data-src]"
2396                        );
2397
2398
2399                    Array.prototype.forEach.call(
2400                        images,
2401                        function (img) {
2402
2403                            var src =
2404                                img.getAttribute(
2405                                    "data-src"
2406                                );
2407
2408                            if (src) {
2409                                img.src = src;
2410                            }
2411
2412                        }
2413                    );
2414
2415
2416                    /*
2417                    ===============================
2418                    WŁASNA KLASA KARTY
2419                    ===============================
2420                    */
2421
2422                    card.classList.add(
2423                        "bts-poe-card"
2424                    );
2425
2426
2427                    track.appendChild(card);
2428
2429                }
2430            );
2431
2432
2433            console.log(
2434                "BTS POE: wyświetlono:",
2435                products.length
2436            );
2437
2438        })
2439
2440        .catch(function (error) {
2441
2442            console.error(
2443                "BTS POE ERROR:",
2444                error
2445            );
2446
2447            track.innerHTML =
2448                "Nie udało się pobrać produktów.";
2449
2450        });
2451
2452});
2453document.addEventListener("DOMContentLoaded", function () {
2454
2455    var module = document.getElementById("bts-professional-module");
2456
2457    if (!module) {
2458        return;
2459    }
2460
2461    var track =
2462        document.getElementById("bts-professional-track");
2463
2464    var categoryUrl =
2465        "/pl/c/Kamery-Professional/19";
2466
2467    var limit = 5;
2468
2469
2470    console.log("BTS PROFESSIONAL: moduł znaleziony");
2471
2472
2473    fetch(categoryUrl)
2474
2475        .then(function (response) {
2476
2477            if (!response.ok) {
2478                throw new Error(
2479                    "HTTP " + response.status
2480                );
2481            }
2482
2483            return response.text();
2484
2485        })
2486
2487        .then(function (html) {
2488
2489            var parser =
2490                new DOMParser();
2491
2492            var doc =
2493                parser.parseFromString(
2494                    html,
2495                    "text/html"
2496                );
2497
2498
2499            var products =
2500                Array.prototype.slice.call(
2501                    doc.querySelectorAll(
2502                        "#box_mainproducts .product[data-product-id]"
2503                    )
2504                );
2505
2506
2507            console.log(
2508                "BTS PROFESSIONAL: znaleziono produktów:",
2509                products.length
2510            );
2511
2512
2513            /*
2514            ===============================
2515            TYLKO DOSTĘPNE
2516            ===============================
2517            */
2518
2519            products = products.filter(
2520                function (product) {
2521
2522                    var availability =
2523                        product.querySelector(".avail");
2524
2525                    if (!availability) {
2526                        return true;
2527                    }
2528
2529                    var text =
2530                        availability.textContent
2531                            .trim()
2532                            .toLowerCase();
2533
2534                    return (
2535                        text.indexOf(
2536                            "brak towaru"
2537                        ) === -1
2538                    );
2539
2540                }
2541            );
2542
2543
2544            /*
2545            ===============================
2546            LOSOWANIE
2547            ===============================
2548            */
2549
2550            products.sort(function () {
2551                return Math.random() - 0.5;
2552            });
2553
2554
2555            /*
2556            ===============================
2557            5 PRODUKTÓW
2558            ===============================
2559            */
2560
2561            products =
2562                products.slice(0, limit);
2563
2564
2565            track.innerHTML = "";
2566
2567
2568            /*
2569            ===============================
2570            KLONOWANIE
2571            ===============================
2572            */
2573
2574            products.forEach(
2575                function (product) {
2576
2577                    var card =
2578                        product.cloneNode(true);
2579
2580
2581                    /*
2582                    ===============================
2583                    OBLICZANIE RABATU
2584                    ===============================
2585                    */
2586
2587                    var promoBadge =
2588                        card.querySelector(
2589                            ".tags .promo span"
2590                        );
2591
2592
2593                    if (promoBadge) {
2594
2595                        var currentPriceElement =
2596                            card.querySelector(
2597                                ".price em"
2598                            );
2599
2600                        var regularPriceElement =
2601                            card.querySelector(
2602                                ".price__regular del"
2603                            );
2604
2605
2606                        if (
2607                            currentPriceElement &&
2608                            regularPriceElement
2609                        ) {
2610
2611                            var currentPrice =
2612                                parseFloat(
2613                                    currentPriceElement.textContent
2614                                        .replace(/\s/g, "")
2615                                        .replace(",", ".")
2616                                        .replace("zł", "")
2617                                );
2618
2619
2620                            var regularPrice =
2621                                parseFloat(
2622                                    regularPriceElement.textContent
2623                                        .replace(/\s/g, "")
2624                                        .replace(",", ".")
2625                                        .replace("zł", "")
2626                                );
2627
2628
2629                            if (
2630                                !isNaN(currentPrice) &&
2631                                !isNaN(regularPrice) &&
2632                                regularPrice > currentPrice
2633                            ) {
2634
2635                                var discount =
2636                                    Math.round(
2637                                        (
2638                                            (regularPrice - currentPrice) /
2639                                            regularPrice
2640                                        ) * 100
2641                                    );
2642
2643
2644                                promoBadge.textContent =
2645                                    discount + "% TANIEJ";
2646
2647                            }
2648
2649                        }
2650
2651                    }
2652
2653
2654                    /*
2655                    ===============================
2656                    ZDJĘCIA
2657                    ===============================
2658                    */
2659
2660                    var images =
2661                        card.querySelectorAll(
2662                            "img[data-src]"
2663                        );
2664
2665
2666                    Array.prototype.forEach.call(
2667                        images,
2668                        function (img) {
2669
2670                            var src =
2671                                img.getAttribute(
2672                                    "data-src"
2673                                );
2674
2675                            if (src) {
2676                                img.src = src;
2677                            }
2678
2679                        }
2680                    );
2681
2682
2683                    /*
2684                    ===============================
2685                    WŁASNA KLASA KARTY
2686                    ===============================
2687                    */
2688
2689                    card.classList.add(
2690                        "bts-professional-card"
2691                    );
2692
2693
2694                    track.appendChild(card);
2695
2696                }
2697            );
2698
2699
2700            console.log(
2701                "BTS PROFESSIONAL: wyświetlono:",
2702                products.length
2703            );
2704
2705        })
2706
2707        .catch(function (error) {
2708
2709            console.error(
2710                "BTS PROFESSIONAL ERROR:",
2711                error
2712            );
2713
2714            track.innerHTML =
2715                "Nie udało się pobrać produktów.";
2716
2717        });
2718
2719});
2720/* =========================================================
2721   REOLINK - PRODUKTY POWIĄZANE
2722   SLIDER DLA >5 PRODUKTÓW
2723   ========================================================= */
2724
2725document.addEventListener("DOMContentLoaded", function () {
2726
2727    const box = document.querySelector("#reolink-related-top");
2728
2729    if (!box) return;
2730
2731    const slider = box.querySelector(
2732        ".reolink-related-top-products.reolink-related-slider"
2733    );
2734
2735    if (!slider) return;
2736
2737    const products = slider.querySelectorAll(
2738        ".reolink-related-product"
2739    );
2740
2741    if (products.length <= 5) return;
2742
2743
2744    /* =====================================================
2745       SZEROKOŚĆ KART
2746       ===================================================== */
2747
2748    function setProductWidths() {
2749
2750        const sliderWidth = slider.clientWidth;
2751
2752        if (!sliderWidth) return;
2753
2754        const gap = 16;
2755
2756
2757        /* =================================================
2758           MOBILE
2759           Jedna duża karta + fragment kolejnej
2760           ================================================= */
2761
2762        if (window.innerWidth <= 767) {
2763
2764            const productWidth =
2765                sliderWidth - 24;
2766
2767            products.forEach(function (product) {
2768
2769                product.style.setProperty(
2770                    "flex",
2771                    "0 0 " + productWidth + "px",
2772                    "important"
2773                );
2774
2775                product.style.setProperty(
2776                    "width",
2777                    productWidth + "px",
2778                    "important"
2779                );
2780
2781                product.style.setProperty(
2782                    "min-width",
2783                    productWidth + "px",
2784                    "important"
2785                );
2786
2787                product.style.setProperty(
2788                    "max-width",
2789                    productWidth + "px",
2790                    "important"
2791                );
2792
2793                product.style.setProperty(
2794                    "flex-shrink",
2795                    "0",
2796                    "important"
2797                );
2798
2799            });
2800
2801            return;
2802        }
2803
2804
2805        /* =================================================
2806           DESKTOP
2807           ORYGINALNA LOGIKA - BEZ ZMIAN
2808           ================================================= */
2809
2810        const productWidth =
2811            (sliderWidth - (gap * 4)) / 5;
2812
2813
2814        products.forEach(function (product) {
2815
2816            product.style.setProperty(
2817                "flex",
2818                "0 0 " + productWidth + "px",
2819                "important"
2820            );
2821
2822            product.style.setProperty(
2823                "width",
2824                productWidth + "px",
2825                "important"
2826            );
2827
2828            product.style.setProperty(
2829                "min-width",
2830                productWidth + "px",
2831                "important"
2832            );
2833
2834            product.style.setProperty(
2835                "max-width",
2836                productWidth + "px",
2837                "important"
2838            );
2839
2840            product.style.setProperty(
2841                "flex-shrink",
2842                "0",
2843                "important"
2844            );
2845
2846        });
2847
2848    }
2849
2850
2851    /* =====================================================
2852       STRZAŁKI
2853       ===================================================== */
2854
2855    const prev =
2856        document.createElement("div");
2857
2858    prev.className =
2859        "reolink-related-slider-prev";
2860
2861    prev.innerHTML = "‹";
2862
2863
2864    const next =
2865        document.createElement("div");
2866
2867    next.className =
2868        "reolink-related-slider-next";
2869
2870    next.innerHTML = "›";
2871
2872
2873    box.appendChild(prev);
2874    box.appendChild(next);
2875
2876
2877    /* =====================================================
2878       AKTUALIZACJA STRZAŁEK
2879       ===================================================== */
2880
2881    function updateArrows() {
2882
2883        if (window.innerWidth <= 767) {
2884
2885            prev.style.display = "none";
2886            next.style.display = "none";
2887
2888            return;
2889        }
2890
2891
2892        const maxScroll =
2893            slider.scrollWidth -
2894            slider.clientWidth;
2895
2896
2897        if (maxScroll > 2) {
2898
2899            prev.style.display =
2900                slider.scrollLeft > 2
2901                    ? "flex"
2902                    : "none";
2903
2904            next.style.display =
2905                slider.scrollLeft <
2906                maxScroll - 2
2907                    ? "flex"
2908                    : "none";
2909
2910        } else {
2911
2912            prev.style.display = "none";
2913            next.style.display = "none";
2914
2915        }
2916
2917    }
2918
2919
2920    /* =====================================================
2921       PRZESUNIĘCIE O JEDNĄ KARTĘ
2922       ===================================================== */
2923
2924    function moveSlider(direction) {
2925
2926        const firstProduct =
2927            products[0];
2928
2929        if (!firstProduct) return;
2930
2931
2932        const productWidth =
2933            firstProduct.getBoundingClientRect().width;
2934
2935
2936        const gap =
2937            window.innerWidth <= 767
2938                ? 12
2939                : 16;
2940
2941
2942        slider.scrollBy({
2943
2944            left:
2945                direction *
2946                (productWidth + gap),
2947
2948            behavior: "smooth"
2949
2950        });
2951
2952    }
2953
2954
2955    /* =====================================================
2956       STRZAŁKI
2957       ===================================================== */
2958
2959    next.addEventListener(
2960        "click",
2961        function () {
2962
2963            moveSlider(1);
2964
2965        }
2966    );
2967
2968
2969    prev.addEventListener(
2970        "click",
2971        function () {
2972
2973            moveSlider(-1);
2974
2975        }
2976    );
2977
2978
2979    /* =====================================================
2980       SCROLL
2981       ===================================================== */
2982
2983    slider.addEventListener(
2984        "scroll",
2985        updateArrows
2986    );
2987
2988
2989    /* =====================================================
2990       ODŚWIEŻANIE
2991       ===================================================== */
2992
2993    function refreshSlider() {
2994
2995        setProductWidths();
2996
2997        requestAnimationFrame(
2998            updateArrows
2999        );
3000
3001    }
3002
3003
3004    window.addEventListener(
3005        "resize",
3006        refreshSlider
3007    );
3008
3009
3010    /* =====================================================
3011       RESIZE OBSERVER
3012       ===================================================== */
3013
3014    if (
3015        typeof ResizeObserver !==
3016        "undefined"
3017    ) {
3018
3019        const observer =
3020            new ResizeObserver(
3021                function () {
3022
3023                    requestAnimationFrame(
3024                        refreshSlider
3025                    );
3026
3027                }
3028            );
3029
3030        observer.observe(slider);
3031
3032    }
3033
3034
3035    /* =====================================================
3036       START
3037       ===================================================== */
3038
3039    refreshSlider();
3040
3041
3042    window.addEventListener(
3043        "load",
3044        refreshSlider
3045    );
3046
3047
3048    requestAnimationFrame(
3049        function () {
3050
3051            requestAnimationFrame(
3052                refreshSlider
3053            );
3054
3055        }
3056    );
3057
3058});

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.