PageSourceSearch

https://stonestory.co.kr/theme/basic/js/theme.shop.list.js?ver=191202

js stonestory.co.kr collected 2026-10-08 11:04:26 UTC 9,921 bytes, 319 lines download raw bytes

1var mainCart = mainCart || {}; 
2
3mainCart.chr = function(code){
4    return String.fromCharCode(code);
5}
6
7jQuery(function ($) {
8    
9    var select_option_el = "select.it_option",
10        overclass = "overlay",
11        cartclass = "sct_cartop",
12        cart_btn_class = "sct_btn";
13
14    mainCart.add_wishitem = function(el) {
15
16        var $el   = $(el),
17            it_id = $el.data("it_id");
18
19        if(!it_id) {
20            alert("상품코드가 올바르지 않습니다.");
21            return false;
22        }
23
24        $.post(
25            g5_theme_shop_url + "/ajax.action.php",
26            { it_id: it_id, action : "wish_update" },
27            function(error) {
28                if(error != "OK") {
29                    alert(error.replace(/\\n/g, "\n"));
30                    return false;
31                }
32                
33                mainCart.update_wish_side();
34                alert("상품을 위시리스트에 담았습니다.");
35                return;
36            }
37        );
38    }
39
40    mainCart.add_cart = function(frm) {
41
42        var $frm = $(frm);
43        var $sel = $frm.find(select_option_el);
44        var it_name = $frm.find("input[name^=it_name]").val();
45        var it_price = parseInt($frm.find("input[name^=it_price]").val());
46        var id = "";
47        var value, info, sel_opt, item, price, stock, run_error = false;
48        var option = sep = "";
49        var count = $sel.size();
50
51        if(count > 0) {
52            $sel.each(function(index) {
53                value = $(this).val();
54                item  = $(this).prev("label").text();
55
56                if(!value) {
57                    run_error = true;
58                    return false;
59                }
60
61                // 옵션선택정보
62                sel_opt = value.split(",")[0];
63
64                if(id == "") {
65                    id = sel_opt;
66                } else {
67                    id += mainCart.chr(30)+sel_opt;
68                    sep = " / ";
69                }
70
71                option += sep + item + ":" + sel_opt;
72            });
73
74            if(run_error) {
75                alert(it_name+"의 "+item+"을(를) 선택해 주십시오.");
76                return false;
77            }
78
79            price = value[1];
80            stock = value[2];
81        } else {
82            price = 0;
83            stock = $frm.find("input[name^=it_stock]").val();
84            option = it_name;
85        }
86
87        // 금액 음수 체크
88        if(it_price + parseInt(price) < 0) {
89            alert("구매금액이 음수인 상품은 구매할 수 없습니다.");
90            mainCart.add_cart_after();
91            return false;
92        }
93
94        // 옵션 선택정보 적용
95        $frm.find("input[name^=io_id]").val(id);
96        $frm.find("input[name^=io_value]").val(option);
97        $frm.find("input[name^=io_price]").val(price);
98        
99        $.ajax({
100            url: $(frm).attr("action"),
101            type: "POST",
102            data: $(frm).serialize(),
103            dataType: "json",
104            async: true,
105            cache: false,
106            success: function(data, textStatus) {
107
108                mainCart.add_cart_after(frm);
109
110                if(data.error != "") {
111                    alert(data.error);
112                    return false;
113                }
114                
115                mainCart.update_cart_side();
116
117                alert("상품을 장바구니에 담았습니다.");
118            },
119            error : function(request, status, error){
120                mainCart.add_cart_after(frm);
121                alert('false ajax :'+request.responseText);
122            }
123        });
124
125        return false;
126    }
127
128    // 5.4 버전의 기본테마의 사이드바의 장바구니를 새로고침합니다.
129    mainCart.update_cart_side = function(){
130        var ajax_url = g5_theme_shop_url || g5_shop_url;
131
132        $.ajax({
133            url: ajax_url + "/ajax.action.php",
134            type: "GET",
135            data: {"action":"refresh_cart"},
136            dataType: "html",
137            async: true,
138            cache: false,
139            success: function(data, textStatus) {
140                var inner_html = $(data).filter(".sbsk").html(),
141                    cart_count = $(data).find(".cart-count").text();
142                
143                $(".qk_con_wr .sbsk").html(inner_html);
144                $(".hd_login .shop_cart .count").text(cart_count);
145            },
146            error : function(request, status, error){
147                alert("false ajax :"+request.responseText);
148            }
149        });
150
151        return true;
152    }
153
154    mainCart.update_wish_side = function(){
155        var ajax_url = g5_theme_shop_url || g5_shop_url;
156        
157        if (typeof g5_is_member == "undefined" || ! g5_is_member) {
158            return false;
159        }
160
161        $.ajax({
162            url: ajax_url + "/ajax.action.php",
163            type: "GET",
164            data: {"action":"refresh_wish"},
165            dataType: "html",
166            async: true,
167            cache: false,
168            success: function(data, textStatus) {
169                var inner_html = $(data).filter(".side-wish").html();
170                
171                $(".qk_con_wr .side-wish").html(inner_html);
172            },
173            error : function(request, status, error){
174                alert("false ajax :"+request.responseText);
175            }
176        });
177
178        return true;
179    }
180
181    mainCart.add_cart_after = function(frm){
182        var $over_rayers = $("."+overclass),
183            $cart_rayers = $("."+cartclass);
184        
185        $over_rayers.each(function(i) {
186            $(this).removeClass(overclass);
187        });
188
189        $cart_rayers.each(function(i) {
190            if( !(frm && $(this).find("select").length) ){
191                $(this).html("").removeClass(cartclass);
192            }
193        });
194    }
195
196    $(document).on("click", ".btn_cart", function(e) {
197        e.preventDefault();
198
199        var $this = $(this),
200            it_id = $this.data("it_id"),
201            $sct_li = $this.closest("li.sct_li"),
202            $opt = $sct_li.find(".cart-layer"),
203            $btn = $sct_li.find("."+cart_btn_class);
204        
205        $(".cart-layer").not($opt).removeClass(cartclass).html('');
206        $("li.sct_li").not($sct_li).removeClass(overclass);
207
208        $.ajax({
209            url: g5_theme_shop_url+"/ajax.action.php",
210            type: "POST",
211            data: {
212                "it_id" : it_id,
213                "action" : "get_item_option"
214            },
215            dataType: "json",
216            async: true,
217            cache: false,
218            success: function(data, textStatus) {
219                if(data.error != "") {
220                    alert(data.error);
221                    return false;
222                }
223                
224                $sct_li.addClass(overclass);
225                $opt.addClass(cartclass).html(data.html);
226
227                if(!data.option) {
228                    mainCart.add_cart($opt.find("form").get(0));
229                    return;
230                }
231
232                //$btn.css("display","none");
233                //$opt.css("display","block");
234            },
235            error : function(request, status, error){
236                alert('false ajax :'+request.responseText);
237            }
238        });
239    });
240
241    $(document).on("change", "select.it_option", function() {
242        var $frm = $(this).closest("form");
243        var $sel = $frm.find("select.it_option");
244        var sel_count = $sel.size();
245        var idx = $sel.index($(this));
246        var val = $(this).val();
247        var it_id = $frm.find("input[name='it_id[]']").val();
248
249        // 선택값이 없을 경우 하위 옵션은 disabled
250        if(val == "") {
251            $frm.find("select.it_option:gt("+idx+")").val("").attr("disabled", true);
252            return;
253        }
254
255        // 하위선택옵션로드
256        if(sel_count > 1 && (idx + 1) < sel_count) {
257            var opt_id = "";
258
259            // 상위 옵션의 값을 읽어 옵션id 만듬
260            if(idx > 0) {
261                $frm.find("select.it_option:lt("+idx+")").each(function() {
262                    if(!opt_id)
263                        opt_id = $(this).val();
264                    else
265                        opt_id += mainCart.chr(30)+$(this).val();
266                });
267
268                opt_id += mainCart.chr(30)+val;
269            } else if(idx == 0) {
270                opt_id = val;
271            }
272
273            $.post(
274                g5_shop_url + "/itemoption.php",
275                { it_id: it_id, opt_id: opt_id, idx: idx, sel_count: sel_count },
276                function(data) {
277                    $sel.eq(idx+1).empty().html(data).attr("disabled", false);
278
279                    // select의 옵션이 변경됐을 경우 하위 옵션 disabled
280                    if(idx+1 < sel_count) {
281                        var idx2 = idx + 1;
282                        $frm.find("select.it_option:gt("+idx2+")").val("").attr("disabled", true);
283                    }
284                }
285            );
286        } else if((idx + 1) == sel_count) { // 선택옵션처리
287            if(val == "")
288                return;
289
290            var info = val.split(",");
291            // 재고체크
292            if(parseInt(info[2]) < 1) {
293                alert("선택하신 선택옵션상품은 재고가 부족하여 구매할 수 없습니다.");
294                return false;
295            }
296        }
297    });
298
299    $(document).on("click", ".cartopt_cart_btn", function(e) {
300        e.preventDefault();
301
302        mainCart.add_cart(this.form);
303    });
304
305    $(document).on("click", ".cartopt_close_btn", function(e) {
306        e.preventDefault();
307        
308        mainCart.add_cart_after();
309
310        //$(this).closest(".sct_cartop").css("display","none");
311        //$(this).closest("li.sct_li").find(".sct_btn").css("display", "");
312    });
313
314    $(document).on("click", ".btn_wish", function(e) {
315        e.preventDefault();
316
317        mainCart.add_wishitem(this);
318    });
319});

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.