PageSourceSearch

https://hotelfrancuski.pl/assets/modules/promo_popups/js/promo_popups.js

js hotelfrancuski.pl collected 2026-10-06 13:17:29 UTC 8,176 bytes, 284 lines download raw bytes

1(function()
2{
3/*    
4    var scriptUrl = new URL(document.currentScript.getAttribute('src'), 'http://localhost');
5    var scriptParams = Object.fromEntries(scriptUrl.searchParams);
6*/
7    var locale = $('html').attr('lang') ? $('html').attr('lang') : 'pl';
8
9    var popups = [];
10    var alerts = [];
11    
12    $(document).ready(function()
13    {
14        init();
15
16        function init()
17        {
18            var sessionData = getSessionData();
19
20            if (sessionData.popups == null || sessionData.locale != locale)
21            {
22                $.get(PromoPopups.getActiveUrl, function(data)
23                {
24                    for (var i in data.popups)
25                    {
26                        var popup = data.popups[i];
27                        
28                        if (popup.type == 'standard')
29                            popups.push(popup);
30                        else if (popup.type == 'top_alert' || popup.type == 'bottom_alert')
31                            alerts.push(popup);
32                    }
33
34                    sessionData.popups = popups;
35                    sessionData.alerts = alerts;
36                    sessionData.locale = locale;
37
38                    setSessionData(sessionData);
39
40                    show();
41                    showAlerts();
42                }, 'json');
43            }
44            else
45            {
46                popups = sessionData.popups;
47                alerts = sessionData.alerts;
48
49                show();
50                showAlerts();
51            }
52        }
53        
54        // standard popup
55
56        function show()
57        {
58            var data = getLocalData();
59
60            data.last_popup_ids.forEach(function(id)
61            {
62                for (var i in popups)
63                {
64                    if (popups[i].id == id)
65                    {
66                        popups.splice(i, 1);
67
68                        break;
69                    }
70                }
71            });
72
73            if (PromoPopups.pageId && popups.length)
74            {
75                for (var i = popups.length - 1; i >= 0; i--)
76                {
77                    if (popups[i].structure_item_ids.length &&
78                            popups[i].structure_item_ids.indexOf(PromoPopups.pageId.toString()) < 0)
79                        popups.splice(i, 1);
80                }
81            }
82
83            if (!popups.length)
84                return;
85
86            if (popups.length > 1)
87            {
88                var html = '';
89
90                popups.forEach(function(popup)
91                {
92                    html += '<div class="popup_one">' + popup.html + '</div>';
93                });
94
95                html = '<div class="slickmodal">' + html + '</div>';
96            }
97            else
98            {
99                var html = popups[0].html;
100            }
101
102            var html = `
103                    <div id="promo_popup">
104                        <div class="text-end h3 mb-1">
105                            <a href="#" onclick="PromoPopups.close(); return false" class="text-white">&#x2715;</a>
106                        </div>
107                        ` + html + `
108                    </div>`;
109
110            $('body').append(html);
111
112            if (popups.length > 1)
113            {
114                $('.slickmodal', $('#promo_popup')).slick({
115                    slidesToShow: 1,
116                    slidesToScroll: 1,
117                    arrows: false,
118                    dots: true,
119                    fade: true,
120                    autoplay: true,
121                    autoplaySpeed: 3000,
122                    speed: 2000,
123                    pauseOnFocus: false
124                });
125            }
126        }
127
128        PromoPopups.close = function()
129        {
130            var popupIds = [];
131
132            popups.forEach(function(popup)
133            {
134                if (popup.permament_close)
135                    popupIds.push(popup.id);
136            });
137            
138            if (popupIds.length)
139            {
140                var data = getLocalData();
141
142                data.last_popup_ids = data.last_popup_ids.concat(popupIds);
143
144                if (data.last_popup_ids.length > 20)
145                     data.last_popup_ids = data.last_popup_ids.slice(data.last_popup_ids.length - 20);
146
147                setLocalData(data);
148            }
149            
150            $('#promo_popup').remove();
151        };
152        
153        // alerts
154        
155        function showAlerts()
156        {
157            var data = getLocalData();
158            
159            data.last_popup_ids.forEach(function(id)
160            {
161                for (var i in alerts)
162                {
163                    if (alerts[i].id == id)
164                    {
165                        alerts.splice(i, 1);
166
167                        break;
168                    }
169                }
170            });
171            
172            var html = '';
173
174            for (var i in alerts)
175            {
176                var alertData = alerts[i];
177                
178                if (PromoPopups.pageId && alertData.structure_item_ids.length)
179                {
180                    if (alertData.structure_item_ids.indexOf(PromoPopups.pageId.toString()) < 0)
181                        continue;
182                }
183                
184                html += '<div id="popup_alert_' + alertData.id + '" class="alert alert-dark pe-5 ' + (alertData.type == 'to
184p_alert' ? 'fixed-top' : 'fixed-bottom') + '" role="alert">' +
185                        alertData.html + 
186                        '<button type="button" onclick="PromoPopups.closeAlert(' + alertData.id + ')" class="btn-close btn-close-white float-end" aria-label="Close"></button>' +
187                    '</div>';
188            }
189            
190            $('body').append(html);
191        }
192        
193        PromoPopups.closeAlert = function(id)
194        {
195            var alert = null;
196            
197            alerts.forEach(function(_alert)
198            {
199                if (_alert.id == id)
200                    alert = _alert;
201            });
202            
203            if (!alert)
204                return;
205            
206            if (alert.permament_close)
207            {
208                var data = getLocalData();
209
210                data.last_popup_ids = data.last_popup_ids.concat([id]);
211
212                if (data.last_popup_ids.length > 20)
213                     data.last_popup_ids = data.last_popup_ids.slice(data.last_popup_ids.length - 20);
214
215                setLocalData(data);
216            }
217            
218            $('#popup_alert_' + id).remove();
219        };
220        
221        function getSessionData()
222        {
223            var data = sessionStorage.getItem('promo_popups');
224
225            if (data != null)
226            {
227                try
228                {
229                    data = JSON.parse(data);
230                }
231                catch(e)
232                {
233                    data = null;
234                }
235            }
236
237            if (!data)
238            {
239                data = {
240                    popups: null,
241                    locale: null
242                };
243            }
244
245            return data;
246        }
247
248        function setSessionData(data)
249        {
250            sessionStorage.setItem('promo_popups', JSON.stringify(data));
251        }
252
253        function getLocalData()
254        {
255            var data = localStorage.getItem('promo_popups');
256
257            if (data != null)
258            {
259                try
260                {
261                    data = JSON.parse(data);
262                }
263                catch(e)
264                {
265                    data = null;
266                }
267            }
268
269            if (!data)
270            {
271                data = {
272                    last_popup_ids: []
273                };
274            }
275
276            return data;
277        }
278
279        function setLocalData(data)
280        {
281            localStorage.setItem('promo_popups', JSON.stringify(data));
282        }
283    });
284})();

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.