1$(function() { 2 var BASE_CLASS = '.shopItem'; 3 var STOCK_API_URL = CMS_API_URL + '/shop-item/stock-exist/'; 4 var SHIPPING_API_URL = CMS_API_URL + '/shop-item/is-shipping-free/'; 5 var STOCK_CLASS = '.shopItemPostage'; 6 var init_flag = false; 7 var INPUT_QTY_ELEM = '<div class="shopItemSu">æ°éï¼</div><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 .html(INPUT_QTY_ELEM) 44 .find('input[name="qty"]').focus()[0]; 45 if (input_elem.selectionStart != undefined) { 46 input_elem.selectionStart = input_elem.selectionEnd = input_elem.value.length; 47 } else { 48 input_elem.createTextRange().select(); 49 } 50 } 51 }); 52 function initShopItem() { 53 if(init_flag) return; 54 init_flag = true; 55 var id = $(BASE_CLASS).find('[name="shop_id"]:eq(0)').val(); 56 if(!id) return; 57 58 $.post( SHIPPING_API_URL, {id:id}, function(data) { 59 if(data === true) $(BASE_CLASS).find(STOCK_CLASS+':eq(0)').removeClass('hide'); 60 else if(data === false) $(BASE_CLASS).find(STOCK_CLASS+':eq(1)').removeClass('hide'); 61 }, 'json').error(function() { 62 console.log('api error'); 63 }); 64 $(BASE_CLASS).each(function(idx, elem) { 65 var id = $(elem).find('input[name="item_id"]').val(); 66 id = $(elem).find('.shopItemKind .s-select').attr('data-value') || id; 67 setAttrData($(elem), id); 68 }); 69 } 70 initShopItem(); 71 window.onpageshow = function() { initShopItem() }; 72});
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.