PageSourceSearch

https://www.rvf.eu/user/documents/dp/map-noobfus.js?v=175

js rvf.eu collected 2026-10-09 02:44:57 UTC 13,262 bytes, 383 lines download raw bytes

1const mapModalHtml = `<div class="modal micromodal-slide" id="modal-map" aria-hidden="true">
2<div class="modal__overlay" tabindex="-1">
3  <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
4    <main class="modal__content" id="modal-1-content">
5      <div class="modal-content-wrapper">
6        <div class="map-heading">
7        <h2>${dpDeliveryHeading}</h2>
8        <p>${dpDeliveryText}</p>
9        </div>
10        <div class="map-adress-wrapper">
11          <form id="map-address">
12            <div class="address-input-wrapper">
13              <div class="adress-input-section">
14                <div class="adress-input-label">
15                  <span>Ulice a číslo domu</span>
16                </div>
17                <div class="address-input">
18                  <input type="text" id="addressStreetNumber" required>
19                </div>
20              </div>
21              <div class="adress-input-section">
22                <div class="adress-input-label">
23                  <span>Město</span>
24                </div>
25                <div class="address-input">
26                  <input type="text" id="addressCity" required>
27                </div>
28              </div>
29              <div class="adress-input-section">
30                <div class="adress-input-label">
31                  <span>PSČ</span>
32                </div>
33                <div class="address-input">
34                  <input type="text" id="addressZip" required>
35                </div>
36              </div>
37            </div>
38            <div class="address-button-wrapper">
39              <button class="btn btn-primary" type="submit" id="check-address">Ověřit adresu</button>
40            </div>
41          </form>
42        </div>
43        <div class="map-loader"></div>
44      </div>
45    </main>
46  </div>
47</div>
48</div>`
49
50$("body").append(mapModalHtml);
51MicroModal.init();
52
53function dpRemoveFromCartbyPriceId(priceId, dpCallback) {
54  var getCartContentXhr = $.getJSON("/action/Cart/GetCartContent/?simple_ajax_cart=1", function (data) {
55
56    var dpItemId = $(".cart-widget-product-delete input[name='priceId'][value='" + priceId + "']", data.payload.content).parent().find("input[name='itemId']").attr("value");
57
58    shoptet.cartShared.removeFromCart({ itemId: dpItemId });
59
60    setTimeout(() => {
61      dpCallback();
62    }, 250);
63
64  }).fail(function () {
65    console.log("DP Error: cannot load JS cart");
66  });
67}
68
69function dpAddtoCart(payload, dpCallback) {
70  document.addEventListener("ShoptetDOMCartCountUpdated", function () {
71    dpCallback();
72  });
73
74  shoptet.cartShared.addToCart(payload);
75}
76
77function dpCalculateBillingWeight(dpCallback) {
78  let weightPromises = [];
79  let totalWeight = 0;
80
81  $(".cart-item").each(function () {
82    var dfd = $.Deferred();
83
84    let amount = parseInt($(".cart-item-amount", this).text().trim());
85
86    let url = $(".cart-item-name > a", this).attr("href");
87
88    if (typeof url == 'undefined') return;
89
90
91    $.get(url, (data) => {
92      let ownerDocument = document.implementation.createHTMLDocument('virtual');
93      let weight = parseInt($(data, ownerDocument).find(".detail-parameters>tbody>tr:contains('Hmotnost')").find('td').text().trim());
94
95      if (!isNaN(weight)) {
96        totalWeight += (weight * amount);
97      }
98      dfd.resolve();
99    });
100    weightPromises.push(dfd);
101
102  });
103
104  $.when.apply($, weightPromises).done(function () {
105    console.log("total weight: " + totalWeight.toFixed(2));
106
107    dpCallback(totalWeight);
108  });
109}
110
111function dpPaletteCounter() {
112  var palettes = 0;
113  $(".cart-item").each(function () {
114    if ($(".unit-value", this).text().indexOf("paleta") != -1) {
115      palettes += (parseInt($(".cart-item-amount", this).text().trim()));
116    }
117  });
118  return palettes;
119}
120
121function dpCalculateShippingAndReload() {
122  var dpCounty = JSON.parse(localStorage.getItem('dpDeliveryAddress')).county;
123
124  dpRemoveFromCartbyPriceId(deliveryProductPriceId, function () {
125    console.log("Deleted old shipping products..");
126
127    setTimeout(() => {
128      Papa.parse("/user/documents/dp/dopravy.csv?v=2", {
129        download: true,
130        header: true,
131        complete: function (results) {
132          var countyTable = results.data;
133
134          var locationRow = countyTable.filter(x => x.name == dpCounty);
135          locationRow = locationRow[0];
136
137          dpCalculateBillingWeight(function (totalWeight) {
138            var shippingPriceTier = 0;
139
140            if (totalWeight < t1) {
141              shippingPriceTier = locationRow.t1;
142            }
143            else if (totalWeight >= t1 && totalWeight < t2) {
144              shippingPriceTier = locationRow.t2;
145            }
146            else if (totalWeight >= t2 && totalWeight < t3) {
147              shippingPriceTier = locationRow.t3;
148            }
149            else {
150              shippingPriceTier = locationRow.t4;
151            }
152
153            shippingPriceTier = parseInt(shippingPriceTier);
154
155            var palettes = dpPaletteCounter();
156
157            dpAddtoCart({
158              priceId: deliveryProductPriceId,
159              amount: (palettes * shippingPriceTier)
160            }, function () {
161              console.log("Added shipping products to cart");
162
163              localStorage.setItem('dpPalleteCounter', palettes);
164
165              localStorage.setItem('dpShippingPrice', (palettes * shippingPriceTier));
166
167              setTimeout(() => {
168                location.reload();
169              }, 500);
170            });
171          });
172        }
173      });
174    }, 250);
175  });
176}
177
178function showMapModal() {
179  MicroModal.show('modal-map');
180
181  var dpDeliveryAddress = localStorage.getItem('dpDeliveryAddress');
182  if (dpDeliveryAddress != null) {
183    doprava = JSON.parse(dpDeliveryAddress);
184
185    $("#addressStreetNumber").val(doprava.streetNumber);
186    $("#addressCity").val(doprava.city);
187    $("#addressZip").val(doprava.zip);
188  }
189
190  $("#map-address").submit(function () {
191    let fullAddress = $("#addressStreetNumber").val() + ", " + $("#addressCity").val() + " " + $("#addressZip").val();
192    const apiKey = "eFzgRjIX2APDguGla8-UX5Lfop_VM-XRI0IXfyJApqE";
193    const apiUrl = `https://api.mapy.cz/v1/geocode?query=${encodeURIComponent(fullAddress)}&lang=cs&apikey=${apiKey}`;
194
195    fetch(apiUrl)
196      .then(res => res.json())
197      .then(result => geoResult(result))
198      .catch(error => {
199        $(".map-loader").html(`<div class="error-message">Nastala chyba při ověřování adresy. Zkontrolujte prosím zadané údaje.</div>`);
200      });
201
202    $(".address-button-wrapper").hide();
203    $(".map-loader").html(`<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>`);
204
205    return false;
206  });
207
208  var geoResult = function (result) {
209    const item = result.items[0];
210
211    // Najdi kraj bez prefixu "okres "
212    const regionObj = item.regionalStructure.find(r =>
213      r.type === "regional.region" && r.name.startsWith("okres ")
214    );
215
216    // Odstraň prefix "okres " z názvu
217    const region = regionObj ? regionObj.name.replace(/^okres\s+/i, "") : null;
218
219    // Najdi město (municipality)
220    const cityObj = item.regionalStructure.find(r => r.type === "regional.municipality");
221    const city = cityObj ? cityObj.name : null;
222
223    // Street number z name (např. "Dolní Lukavice 106")
224    const streetNumber = item.name;
225
226    const postalcode = item.zip; // ZIP code
227
228    console.log("Kraj:", region);
229    console.log("Město:", city);
230    console.log("Číslo popisné:", streetNumber);
231    console.log("PSČ:", postalcode);
232
233    localStorage.setItem('dpDeliveryAddress', JSON.stringify({
234      county: region, // kraj bez prefixu "okres "
235      streetNumber: streetNumber,
236      city: city,
237      zip: postalcode
238    }));
239
240    if (shoptet.checkoutShared.activeShipping.id == ('shipping-' + customShippingId)) {
241      dpCalculateShippingAndReload()
242    }
243    else {
244      location.reload();
245    }
246  }
247}
248
249$(function () {
250  if (dataLayer[0].shoptet.pageType == "billingAndShipping") {
251    if ($("#shipping-" + customShippingId).length) {
252      if (localStorage.getItem("dpLastShipping") != null) {
253        $("label[for='" + localStorage.getItem("dpLastShipping") + "']").trigger("click");
254      }
255
256      $("label[for^='shippingId-']").click(function () {
257        localStorage.setItem("dpLastShipping", $(this).attr("for"));
258      })
259
260      var doprava = localStorage.getItem('dpDeliveryAddress');
261      if (doprava != null) {
262        doprava = JSON.parse(doprava);
263
264        $(".order-delivery").after(`<div class="delivery-address-info">Vaše zvolená adresa a datum doručení je: <b>${doprava.streetNumber} , ${doprava.city} ${doprava.zip}</b> <a onclick="showMapModal()">změnit adresu</a></div>`);
265
266        var countyID = $('#deliveryRegionId option').filter(function () { return $(this).html().trim() == doprava.county; }).val();
267        if (countyID != $('#deliveryRegionId').val()) {
268          setTimeout(() => {
269            $('#deliveryRegionId').val(countyID);
270            $('#deliveryRegionId').trigger("change");
271
272            $('#deliveryRegionId').attr("disabled", true);
273          }, 500);
274        }
275        else {
276          $('#deliveryRegionId').attr("disabled", true);
277        }
278      }
279      else {
280        showMapModal();
281      }
282
283      if (localStorage.getItem("dpPalleteCounter") != null && dpPaletteCounter() != localStorage.getItem("dpPalleteCounter")) {
284        dpCalculateShippingAndReload();
285      }
286
287      document.addEventListener("ShoptetShippingMethodUpdated", function () {
288        if (shoptet.checkoutShared.activeShipping.id == ('shipping-' + customShippingId) && typeof shoptet.tracking.productsList[deliveryProductPriceId] == 'undefined') {
289          dpCalculateShippingAndReload();
290        }
291        if (shoptet.checkoutShared.activeShipping.id != ('shipping-' + customShippingId)) {
292          if (typeof shoptet.tracking.productsList[deliveryProductPriceId] != 'undefined') {
293            dpRemoveFromCartbyPriceId(deliveryProductPriceId, function () {
294              location.reload();
295            });
296          }
297        }
298      });
299
300      if (localStorage.getItem("dpShippingPrice") != null) {
301        $(".shipping-billing-table label[for='shippingId-" + customShippingId + "'] .payment-shipping-price").text(parseFloat(localStorage.getItem("dpShippingPrice")).ShoptetFormatAsCurrency("Kč"));
302        $(".shipping-billing-table label[for='shippingId-" + customShippingId + "'] .payment-shipping-price").removeClass("for-free").attr("style", "visibility: visible !important;");
303      }
304
305      $("#order-form").submit(function (event) {
306        event.preventDefault();
307
308        $('#deliveryRegionId').attr("disabled", false);
309
310        $("#order-form").unbind('submit').submit();
311      });
312    }
313    else {
314      $("#select-country-payment .form-group:contains('Region doručení')").hide();
315
316      if (typeof shoptet.tracking.productsList[deliveryProductPriceId] != 'undefined') {
317        dpRemoveFromCartbyPriceId(deliveryProductPriceId, function () {
318          location.reload();
319        });
320      }
321    }
322  }
323});
324
325
326if (dataLayer[0].shoptet.pageType == "customerDetails") {
327  var doprava = localStorage.getItem('dpDeliveryAddress');
328
329  if (localStorage.getItem("dpShippingPrice") != null) {
330    $(".recapitulation-single:contains('" + customShippingName + "') > strong > span").text(parseFloat(localStorage.getItem("dpShippingPrice")).ShoptetFormatAsCurrency("Kč"));
331  }
332
333  if (doprava != null) {
334    doprava = JSON.parse(doprava);
335
336    $("#note").addClass("visible");
337    $("#add-note").attr("checked", true);
338
339    $("#shipping-address").addClass("visible");
340    $("#another-shipping").attr("checked", true);
341    $('#another-shipping').attr('disabled', true);
342    $('#another-shipping').parent().hide();
343
344    $("#deliveryStreet").val(doprava.streetNumber);
345    $("#deliveryStreet").attr('disabled', true);
346
347    $("#billStreet").val(doprava.streetNumber);
348
349    $("#deliveryCity").val(doprava.city);
350    $("#deliveryCity").attr('disabled', true);
351
352    $("#billCity").val(doprava.city);
353
354    $("#deliveryZip").val(doprava.zip);
355    $("#deliveryZip").attr('disabled', true);
356
357    $("#billZip").val(doprava.zip);
358
359    $("#order-form").submit(function (event) {
360      event.preventDefault();
361
362      $('#another-shipping').attr('disabled', false);
363      $("#deliveryStreet").attr('disabled', false);
364      $("#deliveryCity").attr('disabled', false);
365      $("#deliveryZip").attr('disabled', false);
366
367      $("#order-form").unbind('submit').submit();
368    });
369  }
370  else {
371    setTimeout(() => {
372      $(".co-billing-address .form-group:contains('Region')").hide();
373      $(".co-shipping-address .form-group:contains('Region')").hide();
374    }, 50);
375  }
376}
377
378if (dataLayer[0].shoptet.pageType == "thankYou") {
379  localStorage.removeItem('dpDeliveryAddress');
380  localStorage.removeItem('dpShippingPrice');
381  localStorage.removeItem('dpLastShipping');
382  localStorage.removeItem('dpPalleteCounter');
383}

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.