PageSourceSearch

https://www.cliomariage-shopping.com/js/product_stock.js

js cliomariage-shopping.com collected 2026-09-30 20:11:58 UTC 5,594 bytes, 166 lines download raw bytes

1Colorme = Colorme || {};
2
3// product_stock.js¤¬Ê£¿ô²óÆÉ¤Þ¤ì¤¿»þ¤Ë2²óÌܰʹߤÏ̵¸ú²½
4if(typeof Colorme.productStockJsAlreadyRead === 'undefined') {
5  Colorme.productStockJsAlreadyRead = true;
6
7  $(function () {
8    if ($(".stock_error") == void (0) || ($(".disable_cartin") == void (0))) return;
9
10    var $forms = $('[name=product_form]'),
11      c_class = $(".stock_error"),
12      dis_cart = $(".disable_cartin");
13
14    if ($forms.find("input[name=option]").length <= 0
15        && $forms.find("select[name^=option]").length <= 0)
16    {
17      $forms.on("submit", function(){ add_to_cart() });
18      return;
19    }
20
21    if (dis_cart.children().length >= 1) {
22      var dis_but = dis_cart.children();
23    } else {
24      var dis_but = dis_cart;
25    }
26
27    var a = function (ev) {
28
29      form = $(this).parents('[name=product_form]');
30      form.find('select[name^=option]').each(function (i, v) {
31        if (this.value == 0) {
32          if ($(this).parent().siblings().text() == "" || $(this).parent().siblings().length > 1) {
33            var str_err = "¥ª¥×¥·¥ç¥ó";
34          } else {
35            var str_err = $(this).parent().siblings().text();
36          }
37          c_class.text(str_err + "¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤").css("display", "block");
38          ev.preventDefault();
39          return false;
40        }
41      });
42
43      return true;
44    };
45
46    dis_but.on('click', a);
47
48    $forms.find('select[name^=option],input[name=option],input[type=text][name=product_num],input[type=number][name=product_num]').on('change', function (e) {
49      form = $(this).parents('[name=product_form]');
50      checkProductStock(form, c_class, e);
51    });
52
53    $('[name=product_form]').on('submit', function(e) {
54      checkProductStock($(this), c_class, e);
55
56      if (typeof ga !== "undefined") {
57        ga(function() {
58          var trackers = ga.getAll();
59          var linkerParams = [];
60          trackers.forEach(function(tracker) {
61            linkerParams.push(tracker.get('linkerParam'));
62          });
63          var action = form.attr('action');
64          if (action.indexOf('?') == -1) {
65            form.attr('action', action + '?' + linkerParams.join('&'));
66          } else {
67            form.attr('action', action + '&' + linkerParams.join('&'));
68          }
69        });
70      }
71      add_to_cart();
72    });
73
74    function add_to_cart()
75    {
76      if (typeof gtag !== "undefined") {
77        var $productNum = $('[name=product_form]').find("input[name=product_num]");
78        var productNum = convertNumFullToHalf($productNum.val());
79        if (!$.isNumeric(productNum) || productNum <= 0) return;
80
81        gtag("event", "add_to_cart", {
82          currency: "JPY",
83          value: Colorme.product.sales_price_including_tax,
84          items: [
85            {
86              item_id: Colorme.product.id,
87              item_name: Colorme.product.name,
88              quantity: productNum
89            }
90          ]
91        });
92      }
93    }
94  });
95
96  var convertNumFullToHalf = function (arg) {
97    return arg.replace(/[£°£±£²£³£´£µ£¶£·£¸£¹]/g
98        , function (arg) {
99          var num = "£°£±£²£³£´£µ£¶£·£¸£¹".indexOf(arg);
100          return (num !== -1) ? num : arg;
101        }
102    );
103  };
104
105  var checkProductStock = function (form, c_class, e) {
106    var $productNum = form.find("input[name=product_num]");
107    var productNum = convertNumFullToHalf($productNum.val());
108    $productNum.val(productNum); // ÆþÎϤµ¤ì¤¿¿ô»ú¤òÁ´³Ñ¤«¤éȾ³Ñ¤ØÊÑ´¹
109    if (!$.isNumeric(productNum) || productNum <= 0) return; // ¼«Á³¿ô°Ê³°¤¬ÆþÎϤµ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢ÄÌ¿®¤·¤Ê¤¤
110    var select_array = {};
111    var param = location.search.split("?"),
112        pid = param[1].match("pid=[0-9]*");
113    if (form.find("select[name^=option]").length <= 0) {
114      var checked_val = $("input[name=option]:checked").val();
115      if (checked_val == void 0) return;
116      var tmp = checked_val.split(",");
117      var tmp_cnt = tmp.length / 2;
118      for (var i = 0, x = 0; i < tmp_cnt; i++, x += 2) {
119        if (tmp[x] != "" && tmp[x + 1] != "") {
120          select_array['option[' + i + ']'] = tmp[x] + "," + tmp[x + 1];
121        }
122      }
123    } else {
124      form.find('select[name^=option]').each(function (i, v) {
125        if (this.value == 0) return;
126        select_array['option[' + i + ']'] = this.value;
127      });
128    }
129
130    if ($.isEmptyObject(select_array)) return;
131
132    $.ajax({
133      type: "POST",
134      data: select_array,
135      dataType: "json",
136      url: "?" + pid + "&mode=option_get&preOrderNum=" + productNum,
137      async: false,
138      success: function (option_val, req) {
139        submit_flg = true;
140        c_class.css("display", "none");
141        if (option_val.stock_flg == 0) {
142          if (option_val.stock_num == -1) {
143            c_class.text("ÁªÂò¤¤¤¿¤À¤¤¤¿¾¦Éʤκ߸˿ô¤¬ÉÔ­¤·¤Æ¤¤¤Þ¤¹").css("display", "block");
144          } else if (option_val.stock_num == 0) {
145            c_class.text("ÁªÂò¤¤¤¿¤À¤¤¤¿¾¦Éʤκ߸ˤϤ¢¤ê¤Þ¤»¤ó").css("display", "block");
146          } else if (option_val.stock_num < parseInt(productNum)) {
147            c_class.text("ÁªÂò¤¤¤¿¤À¤¤¤¿¾¦Éʤκ߸ˤϻĤê" + option_val.stock_num + decodeURI(option_val.unit) + "¤Ç¤¹").css("display", "block");
148          }
149          if (c_class.css('display') == 'block') {
150            e.preventDefault();
151            return false;
152          }
153        }
154
155        var form_status = form.find("input[type=submit]"),
156            submit_name = form_status.attr("name");
157
158        if (submit_name == "submit") {
159          form_status.attr("name", "");
160          var clone_submit = form_status.clone();
161          $(this).replaceWith(clone_submit);
162        }
163      }
164    });
165  };
166}

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.