1$(function() { 2 var BASE_CLASS = '.shopItem'; 3 var STOCK_API_URL = '/shop-item/stock-exist/'; 4 var SHIPPING_API_URL = '/shop-item/is-shipping-free/'; 5 var STOCK_CLASS = '.shopItemPostage'; 6 var init_flag = false; 7 var INPUT_QTY_ELEM = '<input type="text" name="qty" value="10" maxlength="4">'; 8 9 function setAttrData(parts, id, callback) { 10 $.post(STOCK_API_URL, {id: id}, function(data) { 11 if(data === true) { 12 parts.find('.shopItemStock').removeClass('hide'); 13 parts.find('.shopItemKagoLine').removeClass('hide'); 14 parts.find('.shopItemStockOut').addClass('hide'); 15 } else if(data === false) { 16 parts.find('.shopItemStock').addClass('hide'); 17 parts.find('.shopItemKagoLine').addClass('hide'); 18 parts.find('.shopItemStockOut').removeClass('hide'); 19 } 20 parts.find('input[name="item_id"]').val(id); 21 if($.isFunction(callback)) callback(); 22 }, 'json').error(function(e) { 23 console.log('api error'); 24 }); 25 } 26 $(BASE_CLASS+' .shopItemKind a').on('click', function(e) { 27 e.preventDefault(); 28 var parts = $(e.target).parents(BASE_CLASS); 29 var _this = ($(e.target).attr('data-value')) ? $(e.target):$(e.target).parent('[data-value]'); 30 var id = _this.attr('data-value'); 31 var price = _this.attr('data-price'); 32 setAttrData(parts, id, function() { 33 parts.find('.shopItemKind .s-select').removeClass('s-select'); 34 _this.addClass('s-select'); 35 parts.find('.shopItemPrice2').text(price); 36 }); 37 return false; 38 }); 39 $(BASE_CLASS+' select[name="qty"]').on('change', function(e) { 40 if($(e.target).val() == 10) { 41 $(e.target).val(1); // init 42 var input_elem = $(e.target).parent('.shopItemS') 43 .append(INPUT_QTY_ELEM) 44 .find('input[name="qty"]').focus()[0]; 45 $(e.target).remove(); 46 if (input_elem.selectionStart != undefined) { 47 input_elem.selectionStart = input_elem.selectionEnd = input_elem.value.length; 48 } else { 49 input_elem.createTextRange().select(); 50 } 51 } 52 }); 53 function initShopItem() { 54 if(init_flag) return; 55 init_flag = true; 56 var id = $(BASE_CLASS).find('[name="shop_id"]:eq(0)').val(); 57 if(!id) return; 58 59 $.post( SHIPPING_API_URL, {id:id}, function(data) { 60 if(data === true) $(BASE_CLASS).find(STOCK_CLASS+':eq(0)').removeClass('hide'); 61 else if(data === false) $(BASE_CLASS).find(STOCK_CLASS+':eq(1)').removeClass('hide'); 62 }, 'json').error(function() { 63 console.log('api error'); 64 }); 65 $(BASE_CLASS).each(function(idx, elem) { 66 var id = $(elem).find('input[name="item_id"]').val(); 67 id = $(elem).find('.shopItemKind .s-select').attr('data-value') || id; 68 setAttrData($(elem), id); 69 }); 70 } 71 initShopItem(); 72 window.onpageshow = function() { initShopItem() }; 73});
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.