PageSourceSearch

https://www.tiendasel.com/files/minicart.min.js

js tiendasel.com collected 2026-10-01 02:04:54 UTC 16,597 bytes, 527 lines download raw bytes

1function formatMoney(e, c, d, t) {
2  var n = e,
3    c = isNaN((c = Math.abs(c))) ? 2 : c,
4    d = d == undefined ? "." : d,
5    t = t == undefined ? "," : t,
6    s = n < 0 ? "-" : "",
7    i = parseInt((n = Math.abs(+n || 0).toFixed(c))) + "",
8    j = (j = i.length) > 3 ? j % 3 : 0;
9  return (
10    s +
11    (j ? i.substr(0, j) + t : "") +
12    i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) +
13    (c
14      ? d +
15        Math.abs(n - i)
16          .toFixed(c)
17          .slice(2)
18      : "")
19  );
20}
21function formatMoneyCheckout(e, c, d, t) {
22  e = e.toString();
23  if (e.indexOf(".") < 0 && e.indexOf(",") < 0) {
24    e = e.substr(0, e.length - 2) + "." + e.substr(-2);
25  }
26  var n = e,
27    c = isNaN((c = Math.abs(c))) ? 2 : c,
28    d = d == undefined ? "." : d,
29    t = t == undefined ? "," : t,
30    s = n < 0 ? "-" : "",
31    i = parseInt((n = Math.abs(+n || 0).toFixed(c))) + "",
32    j = (j = i.length) > 3 ? j % 3 : 0;
33  return (
34    s +
35    (j ? i.substr(0, j) + t : "") +
36    i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) +
37    (c
38      ? d +
39        Math.abs(n - i)
40          .toFixed(c)
41          .slice(2)
42      : "")
43  );
44}
45function getQueryParam(param) {
46  var found;
47  window.location.search
48    .substr(1)
49    .split("&")
50    .forEach(function (item) {
51      if (param == item.split("=")[0]) {
52        found = item.split("=")[1];
53      }
54    });
55  return found;
56}
57function stringToSlug(str) {
58  str = str.replace(/^\s+|\s+$/g, "");
59  str = str.toLowerCase();
60  var f = "à áäâèéëêìíïîòóöôùúüûñç·/_,:;";
61  var t = "aaaaeeeeiiiioooouuuunc------";
62  for (var i = 0, l = f.length; i < l; i++) {
63    str = str.replace(new RegExp(f.charAt(i), "g"), t.charAt(i));
64  }
65  str = str
66    .replace(/[^a-z0-9 -]/g, "")
67    .replace(/\s+/g, "-")
68    .replace(/-+/g, "-");
69  return str;
70}
71$(document).ready(function () {
72  $body = $("body");
73  var HTML_BTN_NORMAL = "Agregar al carrito";
74  var HTML_BTN_ATUALIZAR =
75    '<i class="fa fa-refresh" aria-hidden="true"></i> Actualizar';
76  var HTML_BTN_CARREGANDO =
77    '<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>';
78  var updateMyCart = function (callback) {
79    vtexjs.checkout.getOrderForm().done(function (orderForm) {
80      var $myCartItems = $(".my-cart-items .scroll-bar");
81      $(".my-cart-badge").html(parseInt(orderForm.items.length));
82      $(".my-cart-footer .sub-total strong").html(
83        "S/ " + formatMoneyCheckout(orderForm.value, 2, ".", ",")
84      );
85      $myCartItems.html("");
86      for (var x = 0; x < orderForm.items.length; x++) {
87        var item = orderForm.items[x];
88        if ($('.btn-buy[data-id="' + item.productId + '"]').length) {
89          $('.btn-buy[data-id="' + item.productId + '"]').html(
90            HTML_BTN_ATUALIZAR
91          );
92        }
93        var qtd =
94          $(".buy-button .qty-box .qty").val() <= 0
95            ? 1
96            : $(".buy-button .qty-box .qty").val();
97        var itemsList =
98          '<div class="my-cart-item clearfix" product-id="' +
99          item.productId +
100          '" data-id="' +
101          item.id +
102      '" data-productid="' +
103          item.productId +
104      '" data-name="' +
105          item.name +
106      '" data-price="S/ ' +
107          formatMoneyCheckout(
108            item.sellingPrice * orderForm.items[x].quantity,
109            2,
110            ".",
111            ","
112          ) +
113      '" data-brand="' +
114          item.additionalInfo.brandName +
115      '" data-category="' +
116          item.productCategoryIds +
117          '">' +
118          '   <a href="' +
119          item.detailUrl +
120          '" title="' +
121          item.name +
122          '">' +
123          '   <span class="image pull-left"><img src="' +
124          item.imageUrl +
125          '" alt="' +
126          item.name +
127          '" class="img-responsive"/></span>' +
128          '     <span class="detail overflow-hidden"><b>' +
129          item.name +
130          "</b>" +
131          '   <span class="qty">Cantidad: ' +
132          orderForm.items[x].quantity +
133          " - </span>" +
134          '       <span class="money"> S/ ' +
135          formatMoneyCheckout(
136            item.sellingPrice * orderForm.items[x].quantity,
137            2,
138            ".",
139            ","
140          ) +
141          "</span>";
142        if (item.sellingPrice != item.price) {
143          itemsList +=
144            '   <br/><span class="normal-price-label">
144Precio normal: </span>' +
145            '       <span class="normal-price-money"> S/ ' +
146            formatMoneyCheckout(
147              item.price * orderForm.items[x].quantity,
148              2,
149              ".",
150              ","
151            ) +
152            "</span>";
153        }
154        itemsList +=
155          " </span></a>" +
156          ' <button class="btn-remove" product-id="' +
157          item.productId +
158          '" data-id="' +
159          item.id +
160          '" data-index="' +
161          x +
162          '"><i class="fa fa-trash icon-remove-from-cart" aria-hidden="true"></i></button>' +
163          "</div>";
164        $myCartItems.append(itemsList);
165      }
166      if (callback !== undefined && callback !== null) {
167        openMyCart;
168      }
169    });
170  };
171  var removeItemCart = function (index) {
172    vtexjs.checkout
173      .getOrderForm()
174      .then(function (orderForm) {
175        var item = orderForm.items[index];
176        item.index = index;
177        return vtexjs.checkout.removeItems([item]);
178      })
179      .done(function (orderForm) {
180        updateMyCart();
181        /*
182        $.alert({
183          title: "Producto",
184          content: "item eliminado",
185          animationBounce: 1.5,
186          icon: "fa fa-check",
187        });*/
188      });
189  };
190  var geraVariacoes = function (product, qtd) {
191    var variacoesDisponiveis = "";
192    var variacoesIndisponiveis = "";
193    for (var x = 0; x < product.skus.length; x++) {
194      var i = product.skus[x];
195      if (i.available == !1) {
196        variacoesIndisponiveis +=
197          '<li><button class="label-variation indisponivel sku-' +
198          stringToSlug(i.skuname) +
199          '" product-id="' +
200          product.productId +
201          '" data-qtd="' +
202          qtd +
203          '" data-id="' +
204          i.sku +
205          '" title="' +
206          i.skuname +
207          '">' +
208          i.skuname +
209          "</button></li>";
210      } else {
211        variacoesDisponiveis +=
212          '<li><button class="label-variation disponivel sku-' +
213          stringToSlug(i.skuname) +
214          '" product-id="' +
215          product.productId +
216          '" data-qtd="' +
217          qtd +
218          '" data-id="' +
219          i.sku +
220          '" title="' +
221          i.skuname +
222          '">' +
223          i.skuname +
224          "</button></li>";
225      }
226    }
227    $("body").append(
228      '<div id="add-to-cart-variations">' +
229        ' <div class="mask"></div>' +
230        '   <div class="center">' +
231        '       <button class="btn-close">Cerrar</button>' +
232        '       <div class="row">' +
233        '           <div class="col-xs-4">' +
234        '               <img src="' +
235        product.skus[0].image +
236        '" alt="' +
237        product.name +
238        '" class="img-responsive ad-imagem">' +
239        "           </div>" +
240        '           <div class="details col-xs-8">
240' +
241        "               <h3>" +
242        product.name +
243        "</h3>" +
244        '               <div class="variations">' +
245        "                   <b>Selecione uma opcion</b>" +
246        '                   <ul class="list-inline">' +
247        variacoesDisponiveis +
248        "</ul>" +
249        "               </div>" +
250        "           </div>" +
251        "       </div>" +
252        "   </div>" +
253        "</div>"
254    );
255  };
256  var closeVariations = function () {
257    $("#add-to-cart-variations").fadeOut(function () {
258      $(this).remove();
259    });
260  };
261  var addToCart = function (id, sku, qtd, button) {
262    if (sku !== undefined && sku !== null && sku !== "") {
263      vtexjs.checkout
264        .getOrderForm()
265        .then(function (orderForm) {
266          var add = !0;
267          var item = null;
268          for (var x = 0; x < orderForm.items.length; x++) {
269            if (parseInt(orderForm.items[x].id) === parseInt(sku)) {
270              item = orderForm.items[x];
271              item.index = x;
272              item.quantity = parseInt(qtd);
273              add = !1;
274              break;
275            }
276          }
277          if (add) {
278            item = {
279              id: parseInt(sku),
280              quantity: parseInt(qtd),
281              seller: 1,
282            };
283            return vtexjs.checkout.addToCart([item]);
284          }
285          return vtexjs.checkout.updateItems([item]);
286        })
287        .done(function (orderForm) {
288          if ($("#quick-view").length) {
289            $("#quick-view").fadeOut(function () {
290              $(this).remove();
291            });
292          }
293          updateMyCart(openMyCart());
294          button.html(HTML_BTN_ATUALIZAR);
295        });
296    } else {
297      vtexjs.catalog.getProductWithVariations(id).done(function (product) {
298        if (product.available == !1) {
299          alert("Producto no disponible");
300        } else {
301          if (product.skus.length > 1) {
302            geraVariacoes(product, qtd);
303          } else {
304            addToCart(id, product.skus[0].sku, qtd, button);
305          }
306        }
307      });
308    }
309  };
310  var ajustMyCartItemHeight = function () {
311    var height =
312      $(".my-cart-header", $myCartBox).outerHeight() +
313      $(".my-cart-footer", $myCartBox).outerHeight();
314    $(".my-cart-items .scroll-bar").css(
315      "max-height",
316      $(window).height() - height
317    );
318  };
319  var openMyCart = function () {
320    $(".mask", $myCartBox).hide();
321    $(".my-cart-info", $myCartBox).css("right", "-100%");
322    $myCartBox.show(function () {
323      $(".mask", $myCartBox).fadeIn();
324      $(".my-cart-info", $myCartBox).animate(
325        {
326          right: 0,
327        },
328        200
329      );
330    });
331  };
332  var closeMyCart = function () {
333    $(".my-cart-info", $myCartBox).animate(
334      {
335        right: "-100%",
336      },
337      200
338    );
339    $(".mask", $myCartBox).fadeOut(function () {
340      $myCartBox.hide();
341    });
342  };
343  var createBuyBoxProductPage = function () {
344    var $e = $(".buy-button a.buy-button");
345    if ($e.length) {
346      $e.before(
347        '<div class="add-to-cart add-to-cart-product-page clearfix">' +
348          ' <div class="qty-box clearfix">' +
349          '   <div class="actions">' +
350          '     <button type="button" class="btn-qty" data-action="del">-</button>' +  
351          '       <input type="text" maxlength="3" class="qty" value="1" />' +
352          '     <button type="button" class="btn-qty" data-action="add">+</button>' +  
353          "   </div>" +
354          " </div>" +
355          ' <div class="overflow-hidden" id="buy-button-box"></div>' +
356          "</div>"
357      );
358      $("#buy-button-box").append($e);
359      $("div.buy-button").css("opacity", "1");
360      // $('.buy-button-ref').append('<img src="/arquivos/carrito_blanco.png">')
361    }
362  };
363  var checkSkuVariation = function () {
364    var $this = $("#product-page .buy-button a.buy-button");
365    var $skuSelector = $(".sku-selector-container");
366    if ($this.length) {
367      if ($this.attr("href").indexOf("javascript:alert") > -1) {
368        $skuSelector.addClass("sku-selector-alert");
369        $this.attr(
370          "href",
371          'javascript:alert("Por favor, seleccione una talla.")'
372        );
373        return !1;
374      } else {
375        $skuSelector.removeClass("sku-selector-alert");
376        return !0;
377      }
378    }
379    return !1;
380  };
381  $body.append(
382    '<div id="my-cart-box" style="display: none;">' +
383      '   <div class="mask"></div>' +
384      '   <div class="my-cart-info">' +
385      '   <div class="my-cart-header">' +
386      "     <strong>Carrito</strong>" +
387      '     <button class="btn btn-close"><i class="fa fa-times" aria-hidden="true"></i></button>' +
388      "   </div>" +
389      '   <div class="my-cart-items"><div class="scroll-bar"></div></div>' +
390      '   <div class="my-cart-footer">' +
391      '     <ul class="info-checkout">' +
392      "       <li>* Envío calculado en la finalización del pedido.</li>" +
393      "       <li>* Si usted tiene un cupon escriba en la finalizacion de la solicitud.</li>" +
394      /* '               <li id="check-acepto">' +
395      '                  <div class="checkbox">' +
396      "                     <label>" +
397      '                        <input type="checkbox">' +
398      '                        <span class="cr"><i class="cr-icon fa fa-check"></i></span>' +
399      '                         <p>He leído y acepto los <a href="/institucional/tiendasel-terminos" target="_blank">términos y condiciones </a> y <a href="/institucional/tiendasel-politicas-privacidad" target="_blank"> las Políticas de Privacidad.</a></p>' +
400      "                     </label>" +
401      "                  </div>" +
402      "               </li>" +*/
403      "     </ul>" +
404      '     <div class="sub-total"><span>Subtotal</span><strong>S/ 0.00</strong></div>' +
405      '       <div class="buttons">' +
406      '       <a href="/checkout/#/cart" class="btn btn-lg btn-block btn-success" id="check-btn">Ir al carrito</a>' +
407      "     </div>" +
408      "   </div>" +
409      " </div>" +
410      "</div>"
411  );
412  var $myCartBox = $("#my-cart-box");
413  $(document).on(
414    "click",
415    "#add-to-cart-variations .btn-close, #add-to-cart-variations .mask",
416    function (event) {
417      closeVariations();
418      return !1;
419    }
420  );
421  $(document).on(
422    "click",
423    "#add-to-cart-variations .label-variation",
424    function () {
425      var $this = $(this);
426      var qtd = $this.attr("data-qtd");
427      var id = $this.attr("data-id");
428      var productId = $this.attr("product-id");
429      var $button = null;
430      addToCart(id, id, qtd, $('.btn-buy[data-id="' + productId + '"]'));
431      closeVariations();
432    }
433  );
434  $(document).on("click", "#my-cart-box .btn-remove", function () {
435    removeItemCart($(this).attr("data-index"));
436    if ($('.btn-buy[data-id="' + $(this).attr("product-id") + '"]').length) {
437      $('.btn-buy[data-id="' + $(this).attr("product-id") + '"]').html(
438        HTML_BTN_NORMAL
439      );
440    }
441    return !1;
442  });
443  $(document).on("click", ".add-to-cart .btn-qty", function () {
444    var $this = $(this);
445    var action = $this.attr("data-action");
446    var $input = $this.parents(".add-to-cart").find(".qty");
447    if ($input.length) {
448      if (action === "add") {
449        $input.val(parseInt($input.val()) + 1);
450      } else if (action === "del" && $input.val() > 1) {
451        $input.val(parseInt($input.val()) - 1);
452      }
453    }
454    return !1;
455  });
456  if ($(".btn-my-cart").length) {
457    $(".btn-my-cart").click(function (event) {
458      openMyCart();
459      return !1;
460    });
461  }
462  $(
463    "#my-cart-box .btn-close, #my-cart-box .mask, #my-cart-box .btn-default"
464  ).click(function (event) {
465    closeMyCart();
466    return !1;
467  });
468  ajustMyCartItemHeight();
469  $(window).scroll(function (event) {
470    ajustMyCartItemHeight();
471  });
472  updateMyCart();
473  if ($body.attr("id") === "product-page") {
474    createBuyBoxProductPage();
475    $(document).on("click", ".buy-button a.buy-button", function () {
476      var $this = $(this);
477      if (checkSkuVariation()) {
478        var qtd =
479          $(".buy-button .qty-box .qty").val() <= 0
480            ? 1
481            : $(".buy-button .qty-box .qty").val();
482        var href = $this.attr("href");
483        var url = href
484          .replace("&qty=1", "&qty=" + qtd)
485          .replace("&redirect=true", "&redirect=false");
486        console.log(url);
487        $.ajax({
488          url: url,
489          context: document.body,
490          method: "GET",
491          beforeSend: function () {
492            $this.html(HTML_BTN_CARREGANDO);
493          },
494        })
495          .done(function () {
496            $this.html(HTML_BTN_ATUALIZAR);
497            updateMyCart();
498            openMyCart();
499          })
500          .fail(function () {
501            $this.html(HTML_BTN_NORMAL);
502            alert("No es posible adicionar un producto a tu carrito.");
503          });
504        return !1;
505      }
506    });
507    $(document).on("change", ".sku-selector", function () {
508      checkSkuVariation();
509    });
510  }
511/* var countChecked = function () {
512    var n = $("#check-acepto input:checked").length;
513    if (n === 1) {
514      $("#check-btn").css({
515        "pointer-events": "initial",
516        opacity: "1",
517      });
518    } else {
519      $("#check-btn").css({
520        "pointer-events": "none",
521        opacity: "0.5",
522        filter: " alpha(opacity=50)",
523      });
524    }
525  };
526  $("#check-acepto input[type=checkbox]").on("click", countChecked);*/
527});

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.