PageSourceSearch

https://www.lavanda.sk/wa_script/js/bs_fce.js?_=2026-09-02-11-10

js lavanda.sk collected 2026-09-27 15:11:46 UTC 18,239 bytes, 561 lines download raw bytes

1/*
2 * @author Tomas Opekar <[email protected]>
3 *
4 */
5
6var BS = BS || {};
7
8BS.Fce = {
9  top_loading_container_stop_run: 0,
10  top_loading_container_start_run: 0,
11  loading_run: 0,
12  explode: function(delimiter, string, limit) {
13    if (arguments.length < 2 || typeof delimiter === 'undefined' || typeof string === 'undefined')
14      return null;
15    if (delimiter === '' || delimiter === false || delimiter === null)
16      return false;
17    if (typeof delimiter === 'function' || typeof delimiter === 'object' || typeof string === 'function' || typeof string === 'object') {
18      return {0: ''};
19    }
20    if (delimiter === true)
21      delimiter = '1';
22    // Here we go...
23    delimiter += '';
24    string += '';
25    var s = string.split(delimiter);
26    if (typeof limit === 'undefined')
27      return s;
28    // Support for limit
29    if (limit === 0)
30      limit = 1;
31    // Positive limit
32    if (limit > 0) {
33      if (limit >= s.length)
34        return s;
35      return s.slice(0, limit - 1).concat([s.slice(limit - 1).join(delimiter)]);
36    }
37
38// Negative limit
39    if (-limit >= s.length)
40      return [];
41    s.splice(s.length + limit);
42    return s;
43  },
44  /**
45   * Spusti opakujici se animaci tob bar loadingu
46   *
47   * @author Michal Schwarz
48   */
49  start_top_bar: function (){
50    jQuery('#top_loading_bar').width(0);
51    jQuery('#top_loading_bar').animate({
52      width: "100%"
53    }, 4000, function (){
54      BS.Fce.start_top_bar();
55    });
56  },
57  /**
58   * Zobrazi top bar loading
59   * Funguje jako zasobnik, animaci spusti jen prvni volani a zastavuje posledni volani
60   * hide_top_bar_loading()
61   *
62   * @author Michal Schwarz
63   */
64  show_top_bar_loading: function ()
65  {
66    BS.Fce.loading_run = !BS.Fce.loading_run ? 1 : BS.Fce.loading_run + 1;
67    if(BS.Fce.top_loading_container_stop_run ||
68        (!jQuery('#top_loading_container').is(':animated') &&
69         !jQuery('#top_loading_bar').is(':animated')))
70    {
71      BS.Fce.loading_run = 1;
72      jQuery('#top_loading_bar').stop().width('0');
73      jQuery('#top_loading_container').stop().height('0');
74      BS.Fce.top_loading_container_start_run = 1;
75      jQuery('#top_loading_container').animate({
76        height: "15" 
77      }, 500, function (){
78        BS.Fce.top_loading_container_start_run = 0;
79        BS.Fce.start_top_bar();
80      });
81    }
82  },
83  /**
84   * Zastavi top bar loading
85   * Funguje jako zasobnik, animaci spusti jen prvni volani show_top_bar_loading() a zastavuje posledni volani
86   *
87   * @author Michal Schwarz
88   */
89  hide_top_bar_loading: function ()
90  {
91    if(BS.Fce.loading_run <= 1)
92    {
93      BS.Fce.loading_run = 0;
94      jQuery('#top_loading_bar').stop().width('100%');
95
96      BS.Fce.top_loading_container_stop_run = 1;
97      jQuery('#top_loading_container').stop().animate({
98        height: "0"
99      }, 500, function (){
100        BS.Fce.top_loading_container_stop_run = 0;
101      });
102    }
103    else
104    {
105      BS.Fce.loading_run--;
106    }
107  },
108  showLoadingOverlay: function (title, text, image = '/images/order_finish_animation.gif'){
109
110  var $background = '<div id="czpost_window_postbackground">&nbsp;</div>';
111  var $main_window = '<div id="czpost_window_background"><div id="main-window"><div id="top_bar">'+ title+ '</div> <div id="main_area"><p style="margin: auto; text-align: left; color: black; width: 90%">
111<img src="' + image +'" align="left" style="margin-right:10px" /><br style="line-height:10px" />'+ text +'</p></div></div></div>'
112
113  $('body').prepend($background);
114  $('body').prepend($main_window);
115
116  $('body #czpost_window_background #main-window').css({
117    'background-color': '#FFF',
118    position: 'fixed',
119    top: '35%',
120    right: '0',
121    left: '0',
122    'margin-right': 'auto',
123    'margin-left': 'auto',
124    width: '25%',
125    height: '133px',
126    'border-radius': '0px',
127    border: '0px none',
128    'box-shadow': '0px 0px 8px rgba(0, 0, 0, 0.39)'
129  });
130
131  $('#czpost_window_background').show();
132  $('#czpost_window_postbackground').show();
133  },
134  restricted_popup2: function(data, button)
135  {
136    var dialog_question = data["18plus_text"];
137    var btn = {};
138    btn[data["18plus_btn_abort"]] = function() {
139      $(this).dialog("close");
140    };
141    btn[data["18plus_btn_confirm"]] = function() {
142      var $expires_date = new Date();
143      $expires_date.setTime($expires_date.getTime() + (7 * 24 * 60 * 60 * 1000));
144      document.cookie = data["cookie_name"] + "=true;expires=" + $expires_date.toGMTString() + ";path=/";
145      button.click();
146      $(this).dialog("close");
147    };
148    var $custom_data = {closeOnEscape: false, open: function(event, ui) {
149        $(".ui-dialog-titlebar-close").hide();
150      }, resizable: false};
151    WA.Dialog.confirm_dialog(data["warning_title"], dialog_question, btn, "restriction_18plus_dialog", 450, 300, $custom_data);
152
153    if (BS.Design.template.name === 'palladium') {
154      var $uiDlg = $("#restriction_18plus_dialog").closest('.ui-dialog');
155      if ($uiDlg.length && !$uiDlg.find('.dialog-logo-box').length) {
156        var $logoSrc = $('.logo-wrapper').first();
157        if ($logoSrc.length) {
158          var $logoClone = $logoSrc.clone().addClass('dialog-logo-box').css({position: 'static', top: 'auto', 'text-align': 'center', margin: '0 auto', 'margin-bottom': '1rem', display: 'block', width: '100%'});
159          $logoClone.find('#site_logo, a.mylogo').css({'display': 'inline-block', 'background-position': 'center', 'background-size': 'contain', width: '100%'});
160          $uiDlg.prepend($logoClone);
161        }
162      }
163    }
164
165    if(!BS.Design.third_generation()) {
166      $(".ui-widget-overlay").addClass("restricted-popup");
167      $(".ui-dialog").addClass("restricted-popup");
168    }
169    else {
170      $(".ui-dialog").css({position: "absolute", padding: ".2em", overflow: "hidden"});
171      $(".ui-widget-overlay").css({position: "fixed", top: "0" ,left: "0", width: "100%", height: "100%"});
172    }
173    window.scrollTo(0, 0);
174  },
175  restricted_popup: function ($data, func, args)
176   {
177     var dialog_question = $data["18plus_text"];
178     var btn = {};
179     btn[$data["18plus_btn_abort"]] = function() {
180       $(this).dialog("close");
181   };
182     btn[$data["18plus_btn_confirm"]] = function() {
183     var $expires_date = new Date();
184     $expires_date.setTime($expires_date.getTime() + (7 * 24 * 60 * 60 * 1000));
185     document.cookie = $data["cookie_name"] + "=true;expires=" + $expires_date.toGMTString() + ";path=/";
186     func.forEach( function (func_name, key)
187     {
188         func_name.apply(null, args[key]);
189     });
190     $(this).dialog("close");
191   };
192     var $custom_data = {closeOnEscape: false, open: function(event, ui) {
193         $(".ui-dialog-titlebar-close").hide();
194       }, resizable: false};
195     WA.Dialog.confirm_dialog($data["warning_title"], dialog_question, btn, "restriction_18plus_dialog", 450, 300, $custom_data);
196
197     if (BS.Design.template.name === 'palladium') {
198       var $uiDlg2 = $("#restriction_18plus_dialog").closest('.ui-dialog');
199       if ($uiDlg2.length && !$uiDlg2.find('.dialog-logo-box').length) {
200         var $logoSrc2 = $('.logo-wrapper').first();
201         if ($logoSrc2.length) {
202           var $logoClone2 = $logoSrc2.clone().addClass('dialog-logo-box').css({position: 'static', top: 'auto', 'text-align': 'center', margin: '0 auto', 'margin-bottom': '1rem', display: 'block', width: '100%'});
203           $logoClone2.find('#site_logo, a.mylogo').css({'display': 'inline-block', 'background-position': 'center', 'background-size': 'contain', width: '100%'});
204           $uiDlg2.prepend($logoClone2);
205         }
206       }
207     }
208
209     if(!BS.Design.third_generation()) {
210       $(".ui-widget-overlay").addClass("restricted-popup");
211       $(".ui-dialog").addClass("restricted-popup");
212     }
213     else {
214       $(".ui-dialog").css({position: "absolute", padding: ".2em", overflow: "hidden"});
215       $(".ui-widget-overlay").css({position: "fixed", top: "0" ,left: "0", width: "100%", height: "100%"});
216     }
217     window.scrollTo(0, 0);
218   },
219  call_conversion_request: function (event, data) {
220    const request = BS.extend(BS.Request.$default, {
221      method: 'POST',
222      data: {
223        action: 'Ga_conversion_events',
224        event: event,
225        data: data,
226        id_zakaznik: BS.User.id
227      },
228    });
229
230    $.ajax(request).done(function (response) {
231      // TODO: Unify conversion responses to a provider list instead of hardcoded data/sem keys.
232      if (response.data && typeof gtag === "function") {
233        gtag('event', event, response.data);
234      }
235      if (response.sem && typeof SEM === "function") {
236        SEM('track', response.sem.event, response.sem.data);
237      }
238    });
239  }
240};
241
242(function(utils){
243  'use strict';
244
245  utils.validate_email = function(val) {
246    var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,10})+$/;
247    if(typeof val !== "string") return false;
248
249    return val.test(regex);
250  }
251
252})(BS.utils || {});
253
254/**
255 * Převod na camelCase používaný například v jS pro CSS property
256 * Např. padding-top -> paddingTop
257 * @returns {string}
258 */
259String.prototype.toCamelCase = function() {
260  return this.replace(/[-_]([a-z]+)/g, function(match, $1, offset) {
261    return offset > 0 ? $1.charAt(0).toUpperCase() + $1.slice(1).toLowerCase() : $1.toLowerCase();
262  });
263};
264
265/**
266 * Zaokrouhlení čísla.
267 * Narozdíl od standradní Math.round() umí zaokrouhlovat i desetinná čísla
268 * @param number
269 * @param precision
270 * @returns {number}
271 */
272Math.roundFloat = function(number, precision)
273{
274  precision = !isNaN(precision) ? parseInt(precision) : 0;
275  var factor = Math.pow(10, precision);
276  return Math.round(number * factor) / factor;
277};
278
279BS.cookie = {
280  set: function(name, value, expires) {
281    var cookie = name + "=" + value,
282      date = new Date();
283    cookie += ";path=/";
284    expires = expires || (60 * 60 * 24 * 356);
285    cookie += ";max-age=" + expires;
286    date.setTime(date.getTime() + expires * 1000);
287    cookie += ";expires=" + date.toUTCString();
288    document.cookie = cookie;
289  },
290  get: function(name) {
291    var regex = new RegExp("(?:(?:^|.*;\\s*)" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"),
292      cookie;
293    cookie = regex.exec(document.cookie);
294    return cookie ? cookie[1] : false;
295  },
296  delete: function (name)
297  {
298    document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;';
299  }
300};
301
302BS.Conversion = {
303  add_to_cart: function (data, clientIP, currencyISObyServer) {
304    window.dataLayer = window.dataLayer || [];
305    window.dataLayer.push({
306                            event: 'eec.add',
307                            clientIP: clientIP,
308                            ecommerce: {
309                              add: {
310                                value: data[0]['metric2'],
311                                currencyISObyServer: currencyISObyServer,
312                                actionField: {
313                                  list: 'Shopping cart'
314                                },
315                                products: data
316                              }
317                            }
318                          });
319  },
320  remove_from_cart: function (data, clientIP, currencyISObyServer){
321    window.dataLayer = window.dataLayer || [];
322    window.dataLayer.push({
323                            event: 'eec.remove',
324                            clientIP: clientIP,
325                            ecommerce: {
326                              remove: {
327                                value: data[0]['metric2'],
328                                currencyISObyServer: currencyISObyServer,
329                                actionField: {
330                                  list: 'Shopping cart'
331                                },
332                                products: data
333                              }
334                            }
335                          });
336
337  },
338  getEvent: function (products, variants, count , event_name) {
339    var _this = this;
340    var $request = BS.extend(BS.Request.$default, {
341      data: {
342        action: "Conversion_events",
343        products: products,
344        variants: variants,
345        count: count,
346        event: event_name
347      },
348      success: function($data) {
349        if ($data.success)
350        {
351          _this[event_name]($data.params.data, $data.params.clientIP, $data.params.currencyISObyServer);
352        }
353      }
354    });
355    $.ajax($request);
356  }
357};
358
359BS.Homecredit = {
360  dataToCalc: function (data) {
361    showHcCalc( data.productSetCode,
362                data.price,
363                data.downPayment,
364                data.fixDownPayment,
365                data.dataCalculatorBaseUrl,
366                data.apiKey,
367                this.processCalcResult);
368    },
369    processCalcResult: function (calcResult) {
370      // uložené data výběru zákazníka z kalkulačky
371    },
372    showHcCalcV10 : function (data)
373    {
374      var app = document.createElement('hc-calc');
375      app.callback = this.processCalcResult;
376      app.apiKey =  data.apiKey;
377      app.dataCalculatorBaseUrl =  data.dataCalculatorBaseUrl;
378      app.productSetCode = data.productSetCode;
379      app.price = data.price;
380      app.downPayment = data.downPayment;
381      app.fixDownPayment = data.fixDownPayment;
382      app.language = data.calcLang;
383      app.debug = false;
384      app.isModal = true;
385      document.body.appendChild(app);
386    }
387};
388BS.price_history_widget = {
389  widget: function ($type, $id_zakaznik)
390  {
391   var $request = BS.extend(BS.Request.$default, {
392      data: {
393        action: "Price_history_public",
394        operation: "widget",
395        type: $type,
396        id_zakaznik: $id_zakaznik,
397        data: BS.price_history_widget.data
398      },
399      success: function($data) {
400        if ($data.success)
401        {
402          $.magnificPopup.open({
403            items: {
404              src: $data.params.content
405            },
406            modal: false,
407            closeOnContentClick: false,
408            closeOnBgClick: true,
409            closeBtnInside: true,
410            mainClass: "mf-pht-widget",
411            showCloseBtn: true
412
413          });
414
415          BS.Charts.stepped.widget(
416              $data.params.name,
417              $data.params.dates,
418              $data.params.prices
419          );
420        }
421      }
422    });
423    $.ajax($request);
424
425
426  },
427  set_active: function (e, type, $id_zakaznik)
428  {
429    BS.price_history_widget.widget(type, $id_zakaznik);
430  },
431  remove_active: function ()
432  {
433    const periods = document.querySelectorAll('.product-history-widget a');
434
435    periods.forEach(function (period) {
436      period.classList.remove('active');
437    });
438  }
439};
440
441BS.h1_paging = {
442  append_html: function ()
443  {
444    var page_prop = document.getElementById("products_params_form").querySelector('input[name="page"]');
445    var paging_html = document.querySelector(".h1-paging");
446    var h1 = document.querySelector('h1.title_page.def_color');
447    if(page_prop) {
448      var page = parseInt(page_prop.value) + 1;
449      if(paging_html) {
450        paging_html.remove();
451      }
452      if(h1 && page > 1) {
453
454        var html = '<span class="h1-paging"> - #transl# #page#</span>';
455        html = html.replace(/#transl#/g, WA.Translation._h1_page);
456        html = html.replace(/#page#/g, page);
457        h1.innerHTML += html;
458      }
459    }
460  }
461}
462
463BS.multiples = {
464  checkIncDec: function (val, product_info, state)
465  {
466     if(!state) {
467       state = "+";
468     }
469      if(typeof product_info === 'object' && product_info !== null && product_info.hasOwnProperty('count_type') && product_info.count_type === 1 ) {
470        var increment_num = parseFloat(product_info.multiples);
471        val = parseFloat(val);
472        var operators = {
473          '+': function(inc, val) { return Math.ceil(val/inc)*inc },
474          '-': function(inc, val) { if(val < inc) { return inc; } return Math.floor(val/inc)*inc;
475          }};
476        return parseFloat(operators[state](increment_num, val).toFixed(2));
477      }
478
479    return val;
480  },
481  // funkce pro šablony které nemají InputSpinner
482  ifNotISpinner: function (){
483    if (!document.querySelector('.input-spinner-group')) {
484      const _self = this;
485      const product_input_count = document.querySelectorAll(".items_count, #kusy.quantity-input, .prKs");
486
487      if(product_input_count !== undefined)
488      {
489        // projedeme elementy které obsahují kusy produktu
490        product_input_count.forEach(function (item ){
491          const productInfo = item.getAttribute('data-product-info');
492          // zjistíme jestli máme data atribut, který obsahuje informace o násobcích
493          if (productInfo) {
494            try {
495              const infoObj = JSON.parse(productInfo);
496
497              if (infoObj.count_type === 1 && infoObj.multiples > 0) {
498                item.addEventListener("change", function (e){
499                  e.target.value = _self.checkIncDec(e.target.value, infoObj, "+");
500                });
501              }
502            } catch (error) {
503              console.error('data-product-info: Missing', error);
504            }
505          } else {
506            console.log('data-product-info: Missing.');
507          }
508
509        })
510      }
511    }
512  }
513
514}
515
516BS.seznamIdentity = {
517  clearIdentity: function ()
518  {
519    if(window.sznIVA && window.sznIVA.IS){
520      window.sznIVA.IS.clearIdentities(['said', 'secid', 'eid', 'aid', 'tid']);
521    }
522  }
523}
524
525function escapeHtml(value) {
526  var chars = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' };
527  var regex = new RegExp('[' + Object.keys(chars).join('') + ']', 'g');
528  return value.replace(regex, function(m) { return chars[m]; });
529}
530
531(function() {
532  "use strict";
533  var listeners = {};
534  var eventDispatcher = {
535    on: function(event, callback) {
536      if (!listeners[event]) {
537        listeners[event] = [];
538      }
539      listeners[event].push(callback);
540    },
541    off: function(event, callback) {
542      if (!listeners[event]) {
543        return;
544      }
545      var index = listeners[event].indexOf(callback);
546      if (index !== -1) {
547        listeners[event].splice(index, 1);
548      }
549    },
550    trigger: function(event, data) {
551      if (!listeners[event]) {
552        return;
553      }
554      listeners[event].forEach(function(callback) {
555        callback(Object.assign({}, data, { type: event }));
556      });
557    }
558  };
559
560  BS.event = eventDispatcher;
561})(BS);

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.