1var option_add = false; 2var supply_add = false; 3var isAndroid = (navigator.userAgent.toLowerCase().indexOf("android") > -1); 4 5$(function() { 6 // ì íìµì 7 /* ê°ì커ì ctrl keyup ì´ë² í¸ ëì */ 8 /* 9 $(document).on("keyup", "select.it_option", function(e) { 10 var sel_count = $("select.it_option").size(); 11 var idx = $("select.it_option").index($(this)); 12 var code = e.keyCode; 13 var val = $(this).val(); 14 15 option_add = false; 16 if(code == 17 && sel_count == idx + 1) { 17 if(val == "") 18 return; 19 20 sel_option_process(true); 21 } 22 }); 23 */ 24 25 /* í¤ë³´ë ì ê·¼ í ìµì ì í Enter keydown ì´ë²¤í¸ ëì */ 26 $(document).on("keydown", "select.it_option", function(e) { 27 var sel_count = $("select.it_option").size(); 28 var idx = $("select.it_option").index($(this)); 29 var code = e.keyCode; 30 var val = $(this).val(); 31 32 option_add = false; 33 if(code == 13 && sel_count == idx + 1) { 34 if(val == "") 35 return; 36 37 sel_option_process(true); 38 } 39 }); 40 41 if(isAndroid) { 42 $(document).on("touchend", "select.it_option", function() { 43 option_add = true; 44 }); 45 } else { 46 $(document).on("mouseup", "select.it_option", function() { 47 option_add = true; 48 }); 49 } 50 51 $(document).on("change", "select.it_option", function() { 52 var sel_count = $("select.it_option").size(); 53 var idx = $("select.it_option").index($(this)); 54 var val = $(this).val(); 55 var it_id = $("input[name='it_id[]']").val(); 56 57 // ì íê°ì´ ìì ê²½ì° íì ìµì ì disabled 58 if(val == "") { 59 $("select.it_option:gt("+idx+")").val("").attr("disabled", true); 60 return; 61 } 62 63 // íìì íìµì ë¡ë 64 if(sel_count > 1 && (idx + 1) < sel_count) { 65 var opt_id = ""; 66 67 // ìì ìµì ì ê°ì ì½ì´ ìµì id ë§ë¬ 68 if(idx > 0) { 69 $("select.it_option:lt("+idx+")").each(function() { 70 if(!opt_id) 71 opt_id = $(this).val(); 72 else 73 opt_id += chr(30)+$(this).val(); 74 }); 75 76 opt_id += chr(30)+val; 77 } else if(idx == 0) { 78 opt_id = val; 79 } 80 81 $.post( 82 "./itemoption.php", 83 { it_id: it_id, opt_id: opt_id, idx: idx, sel_count: sel_count }, 84 function(data) { 85 $("select.it_option").eq(idx+1).empty().html(data).attr("disabled", false); 86 87 // selectì ìµì ì´ ë³ê²½ëì ê²½ì° íì ìµì disabled 88 if(idx+1 < sel_count) { 89 var idx2 = idx + 1; 90 $("select.it_option:gt("+idx2+")").val("").attr("disabled", true); 91 } 92 } 93 ); 94 } else if((idx + 1) == sel_count) { // ì íìµì ì²ë¦¬ 95 if(option_add && val == "") 96 return; 97 98 var info = val.split(","); 99 // ì¬ê³ ì²´í¬ 100 if(parseInt(info[2]) < 1) { 101 alert("ì ííì ì íìµì ìíì ì¬ê³ ê° ë¶ì¡±íì¬ êµ¬ë§¤í ì ììµëë¤."); 102 return false; 103 } 104 105 if(option_add) 106 sel_option_process(true); 107 } 108 }); 109 110 // ì¶ê°ìµì 111 /* ê°ì커ì ctrl keyup ì´ë² í¸ ëì */ 112 /* 113 $(document).on("keyup", "select.it_supply", function(e) { 114 var $el = $(this); 115 var code = e.keyCode; 116 var val = $(this).val(); 117 118 supply_add = false; 119 if(code == 17) { 120 if(val == "") 121 return; 122 123 sel_supply_process($el, true); 124 } 125 }); 126 */ 127 128 /* í¤ë³´ë ì ê·¼ í ìµì ì í Enter keydown ì´ë²¤í¸ ëì */ 129 $(document).on("keydown", "select.it_supply", function(e) { 130 var $el = $(this); 131 var code = e.keyCode; 132 var val = $(this).val(); 133 134 supply_add = false;
135 if(code == 13) { 136 if(val == "") 137 return; 138 139 sel_supply_process($el, true); 140 } 141 }); 142 143 if(isAndroid) { 144 $(document).on("touchend", "select.it_supply", function() { 145 supply_add = true; 146 }); 147 } else { 148 $(document).on("mouseup", "select.it_supply", function() { 149 supply_add = true; 150 }); 151 } 152 153 $(document).on("change", "select.it_supply", function() { 154 var $el = $(this); 155 var val = $(this).val(); 156 157 if(val == "") 158 return; 159 160 if(supply_add) 161 sel_supply_process($el, true); 162 }); 163 164 // ìëë³ê²½ ë° ìì 165 $(document).on("click", "#sit_sel_option li button", function() { 166 var mode = $(this).text(); 167 var this_qty, max_qty = 9999, min_qty = 1; 168 var $el_qty = $(this).closest("li").find("input[name^=ct_qty]"); 169 var stock = parseInt($(this).closest("li").find("input.io_stock").val()); 170 171 switch(mode) { 172 case "ì¦ê°": 173 this_qty = parseInt($el_qty.val().replace(/[^0-9]/, "")) + 1; 174 if(this_qty > stock) { 175 alert("ì¬ê³ ìë ë³´ë¤ ë§ì ìëì 구매í ì ììµëë¤."); 176 this_qty = stock; 177 } 178 179 if(this_qty > max_qty) { 180 this_qty = max_qty; 181 alert("ìµë 구매ìëì "+number_format(String(max_qty))+" ì ëë¤."); 182 } 183 184 $el_qty.val(this_qty); 185 price_calculate(); 186 break; 187 188 case "ê°ì": 189 this_qty = parseInt($el_qty.val().replace(/[^0-9]/, "")) - 1; 190 if(this_qty < min_qty) { 191 this_qty = min_qty; 192 alert("ìµì 구매ìëì "+number_format(String(min_qty))+" ì ëë¤."); 193 } 194 $el_qty.val(this_qty); 195 price_calculate(); 196 break; 197 198 case "ìì ": 199 if(confirm("ì ííì ìµì í목ì ìì íìê² ìµëê¹?")) { 200 var $el = $(this).closest("li"); 201 var del_exec = true; 202 203 if($("#sit_sel_option .sit_spl_list").size() > 0) { 204 // ì íìµì ì´ íëì´ìì¸ì§ 205 if($el.hasClass("sit_opt_list")) { 206 if($(".sit_opt_list").size() <= 1) 207 del_exec = false; 208 } 209 } 210 211 if(del_exec) { 212 $el.closest("li").remove(); 213 price_calculate(); 214 } else { 215 alert("ì íìµì ì íëì´ìì´ì´ì¼ í©ëë¤."); 216 return false; 217 } 218 } 219 break; 220 221 default: 222 alert("ì¬ë°ë¥¸ ë°©ë²ì¼ë¡ ì´ì©í´ 주ììì¤."); 223 break; 224 } 225 }); 226 227 // ìëì§ì ì ë ¥ 228 $(document).on("keyup", "input[name^=ct_qty]", function() { 229 var val= $(this).val(); 230 231 if(val != "") { 232 if(val.replace(/[0-9]/g, "").length > 0) { 233 alert("ìëì ì«ìë§ ì ë ¥í´ ì£¼ììì¤."); 234 $(this).val(1); 235 } else { 236 var d_val = parseInt(val); 237 if(d_val < 1 || d_val > 9999) { 238 alert("ìëì 1ìì 9999 ì¬ì´ì ê°ì¼ë¡ ì ë ¥í´ ì£¼ììì¤."); 239 $(this).val(1); 240 } else { 241 var stock = parseInt($(this).closest("li").find("input.io_stock").val()); 242 if(d_val > stock) { 243 alert("ì¬ê³ ìë ë³´ë¤ ë§ì ìëì 구매í ì ììµëë¤."); 244 $(this).val(stock); 245 } 246 } 247 } 248 249 price_calculate(); 250 } 251 }); 252}); 253 254// ì íìµì ì¶ê°ì²ë¦¬ 255function sel_option_process(add_exec) 256{ 257 var it_price = parseInt($("input#it_price").val()); 258 var id = ""; 259 var value, info, sel_opt, item, price, stock, run_error = false;
260 var option = sep = ""; 261 info = $("select.it_option:last").val().split(","); 262 263 $("select.it_option").each(function(index) { 264 value = $(this).val(); 265 item = $(this).closest("tr").find("th label").text(); 266 267 if(!value) { 268 run_error = true; 269 return false; 270 } 271 272 // ìµì ì íì ë³´ 273 sel_opt = value.split(",")[0]; 274 275 if(id == "") { 276 id = sel_opt; 277 } else { 278 id += chr(30)+sel_opt; 279 sep = " / "; 280 } 281 282 option += sep + item + ":" + sel_opt; 283 }); 284 285 if(run_error) { 286 alert(item+"ì(를) ì íí´ ì£¼ììì¤."); 287 return false; 288 } 289 290 price = info[1]; 291 stock = info[2]; 292 293 // ê¸ì¡ ìì ì²´í¬ 294 if(it_price + parseInt(price) < 0) { 295 alert("구매ê¸ì¡ì´ ììì¸ ìíì 구매í ì ììµëë¤."); 296 return false; 297 } 298 299 if(add_exec) { 300 if(same_option_check(option)) 301 return; 302 303 add_sel_option(0, id, option, price, stock); 304 } 305} 306 307// ì¶ê°ìµì ì¶ê°ì²ë¦¬ 308function sel_supply_process($el, add_exec) 309{ 310 var val = $el.val(); 311 var item = $el.closest("tr").find("th label").text(); 312 313 if(!val) { 314 alert(item+"ì(를) ì íí´ ì£¼ììì¤."); 315 return; 316 } 317 318 var info = val.split(","); 319 320 // ì¬ê³ ì²´í¬ 321 if(parseInt(info[2]) < 1) { 322 alert(info[0]+"ì(ë) ì¬ê³ ê° ë¶ì¡±íì¬ êµ¬ë§¤í ì ììµëë¤."); 323 return false; 324 } 325 326 var id = item+chr(30)+info[0]; 327 var option = item+":"+info[0]; 328 var price = info[1]; 329 var stock = info[2]; 330 331 // ê¸ì¡ ìì ì²´í¬ 332 if(parseInt(price) < 0) { 333 alert("구매ê¸ì¡ì´ ììì¸ ìíì 구매í ì ììµëë¤."); 334 return false; 335 } 336 337 if(add_exec) { 338 if(same_option_check(option)) 339 return; 340 341 add_sel_option(1, id, option, price, stock); 342 } 343} 344 345// ì íë ìµì ì¶ë ¥ 346function add_sel_option(type, id, option, price, stock) 347{ 348 var item_code = $("input[name='it_id[]']").val(); 349 var opt = ""; 350 var li_class = "sit_opt_list"; 351 if(type) 352 li_class = "sit_spl_list"; 353 354 var opt_prc; 355 if(parseInt(price) >= 0) 356 opt_prc = "(+"+number_format(String(price))+"ì)"; 357 else 358 opt_prc = "("+number_format(String(price))+"ì)"; 359 360 opt += "<li class=\""+li_class+"\">"; 361 opt += "<input type=\"hidden\" name=\"io_type["+item_code+"][]\" value=\""+type+"\">"; 362 opt += "<input type=\"hidden\" name=\"io_id["+item_code+"][]\" value=\""+id+"\">"; 363 opt += "<input type=\"hidden\" name=\"io_value["+item_code+"][]\" value=\""+option+"\">"; 364 opt += "<input type=\"hidden\" class=\"io_price\" value=\""+price+"\">"; 365 opt += "<input type=\"hidden\" class=\"io_stock\" value=\""+stock+"\">"; 366 opt += "<span class=\"sit_opt_subj\">"+option+"</span>"; 367 opt += "<span class=\"sit_opt_prc\">"+opt_prc+"</span>"; 368 opt += "<div><input type=\"text\" name=\"ct_qty["+item_code+"][]\" value=\"1\" class=\"frm_input\" size=\"5\">"; 369 opt += "<button type=\"button\" class=\"sit_qty_plus btn_frmline\">ì¦ê°</button>"; 370 opt += "<button type=\"button\" class=\"sit_qty_minus btn_frmline\">ê°ì</button>"; 371 opt += "<button type=\"button\" class=\"sit_opt_del btn_frmline\">ìì </button></div>"; 372 opt += "</li>"; 373 374 if($("#sit_sel_option > ul").size() < 1) { 375 $("#sit_sel_option").html("<ul id=\"sit_opt_added\"></ul>"); 376 $("#sit_sel_option > ul").html(opt); 377 } else{ 378 if(type) { 379 if($("#sit_sel_option .sit_spl_list").size() > 0) { 380 $("#sit_sel_option .sit_spl_list:last").after(opt); 381 } else { 382 if($("#sit_sel_option .sit_opt_list").size() > 0) { 383 $("#sit_sel_option .sit_opt_list:last").after(opt); 384 } else { 385 $("#sit_sel_option > ul").html(opt); 386 } 387 } 388 } else { 389 if($("#sit_sel_option .sit_opt_list").size() > 0) { 390 $("#sit_sel_option .sit_opt_list:last").after(opt); 391 } else { 392 if($("#sit_sel_option .sit_spl_list").size() > 0) { 393 $("#sit_sel_option .sit_spl_list:first").before(opt); 394 } else { 395 $("#sit_sel_option > ul").html(opt); 396 } 397 } 398 } 399 } 400 401 price_calculate(); 402} 403 404// ëì¼ì íìµì ìëì§ 405function same_option_check(val) 406{ 407 var result = false;
408 $("input[name^=io_value]").each(function() { 409 if(val == $(this).val()) { 410 result = true; 411 return false; 412 } 413 }); 414 415 if(result) 416 alert(val+" ì(ë) ì´ë¯¸ ì¶ê°íì ìµì ìíì ëë¤."); 417 418 return result; 419} 420 421// ê°ê²©ê³ì° 422function price_calculate() 423{ 424 var it_price = parseInt($("input#it_price").val()); 425 426 if(isNaN(it_price)) 427 return; 428 429 var $el_prc = $("input.io_price"); 430 var $el_qty = $("input[name^=ct_qty]"); 431 var $el_type = $("input[name^=io_type]"); 432 var price, type, qty, total = 0; 433 434 $el_prc.each(function(index) { 435 price = parseInt($(this).val()); 436 qty = parseInt($el_qty.eq(index).val()); 437 type = $el_type.eq(index).val(); 438 439 if(type == "0") { // ì íìµì 440 total += (it_price + price) * qty; 441 } else { // ì¶ê°ìµì 442 total += price * qty; 443 } 444 }); 445 446 $("#sit_tot_price").empty().html("<span>ì´ ê¸ì¡ :</span> "+number_format(String(total))+"ì"); 447} 448 449// php chr() ëì 450function chr(code) 451{ 452 return String.fromCharCode(code); 453}
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.