/********************************************* /** PCの商品ページ編集用 /*********************************************/ /*----------------------------- slice_str_limit -----------------------------*/ (function($){ var defaults = { overLengthStr:'...', sliceStrLimit:false }; $.fn.sliceStrLimit = function(options){ var configs = {}, el = this, lenEl = el.length, limitLength, str, funcInit = function(){ configs = $.extend({}, defaults, options); str = el.text().trim(); limitLength = configs.sliceStrLimit if(typeof el.data('slice_str_limit') === 'number') limitLength = el.data('slice_str_limit'); el.funcExecute(); }; if(lenEl === 0)return this; if(lenEl > 1){ el.each(function(){$(this).sliceStrLimit(options)}); return this; } el.funcExecute = function(){ el.html(str.slice(0, limitLength) + (limitLength < str.length?configs.overLengthStr:'')); }; funcInit(); }; })(jQuery); /*----------------------------- /slice_str_limit -----------------------------*/ (function($){ $.unixTimeToDate = function(unixTime, format){ var date = new Date(unixTime * 1000), year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours() < 10?'0' + date.getHours():date.getHours(), minute = date.getMinutes() < 10?'0' + date.getMinutes():date.getMinutes(), second = date.getSeconds() < 10?'0' + date.getSeconds():date.getSeconds(); return format.replace('Y', year).replace('m', month).replace('d', day).replace('H', hour).replace('i', minute).replace('s', second); }; $.numberFormat = function(number){ return number.toString().replace(/([0-9]+?)(?=(?:[0-9]{3})+$)/g , '$1,'); }; $(window).on( 'load', () => { const configs = { shopId:18, urlApi:'https://alamode1.xsrv.jp/shop/item_search_api/index.php', plugin:{ slick:{ autoplay:true, slidesToShow:6, slidesToScroll:6, infinite:true, arrows:true, dots:true } } }, arrayHref = location.href.split('/fs/alamode/'), itemCode = arrayHref[arrayHref.length - 1].split('/').join(''), funcAjax = ( url, dataType, callback ) => { $.ajax({ url:url, dataType:dataType, cache:false, error:( jqXHR, textStatus, errorThrown ) => { console.log(textStatus); }, success:callback }); } const funcLoadFinish = () => { const funcRemoveKeywords = ( keywords, removeKeywords ) => { let newKeywords = []; for(var i = 0, l = keywords.length;i < l;i++){ if( $.inArray( keywords[i], removeKeywords ) === -1 && keywords[i] !== '' ) newKeywords.push(keywords[i]); } return newKeywords; }, funcPutTaglist = (keywords) => { const eleFooterItemTagList = $('#footer_item_tag_list'); eleFooterItemTagList.empty(); for(var i = 0, l = keywords.length;i < l;++i) eleFooterItemTagList.append(`
  • ` + keywords[i] + `
  • `); }; funcAjax( '/configs/product_tags/remove_keywords.json', 'json', ( response, textStatus, jqXHR ) => { const removeKeywords = response; funcAjax( configs.urlApi + '?request=get_list&shop_id=' + configs.shopId + '&display_keywords=' + encodeURIComponent(itemCode), 'jsonp', ( response, textStatus, jqXHR ) => { const keywords = response.item[0].html0.split('】【').join(',').split('【').join('').split('】').join('').split(','); funcPutTaglist( funcRemoveKeywords( keywords, removeKeywords ) ); } ); } ); funcAjax( '/js/config/order_history/item_order.json', 'json', ( response, textStatus, jqXHR ) => { const eleFooterOrderListCarousel = $('#footer_order_list_carousel'); eleFooterOrderListCarousel.empty(); for(var i = 0, l = response.length;i < l;++i){ if(i % 2 === 0) eleFooterOrderListCarousel.append(`
    `); let eleFooterOrderListCarouselDiv = eleFooterOrderListCarousel.find('> div:last'); eleFooterOrderListCarouselDiv.append(`
    ` + response[i].name + `
    `); } eleFooterOrderListCarousel.slick(configs.plugin.slick); } ); funcAjax( '/item/footer/ranking/configs.json', 'json', ( response, textStatus, jqXHR ) => { const eleFooterRankingProductList = $('#footer_ranking_product_list'); eleFooterRankingProductList.empty(); for(var i = 0, l = response.length;i < l;++i) eleFooterRankingProductList.append(`
  • ` + response[i].item_name + `
  • `); eleFooterRankingProductList.find('.slice_str_limit').sliceStrLimit(); } ); }, funcPutElements = () => { const eleFooterContentsParent = $('#footer_contents_parent'); eleFooterContentsParent .empty() .html(` `); }, funcGetScriptLink = () => { const loadScriptList = [ '/plugin/jquery/slick/jquery.slick.js' ], eleHead = $('head'); let countLoad = 0; eleHead.append(` `); for(var i = 0, l = loadScriptList.length;i < l;++i) $.getScript( loadScriptList[i] + '?_=' + Math.random(), () => { ++countLoad; if(l === countLoad){ funcPutElements(); funcAppendToItemList(); funcEditProduct(); funcLoadFinish(); } } ); }, funcAppendToItemList = () => { const eleRcmdjpDisplay2 = $('#_rcmdjp_display_2'), eleRcmdjpDisplay1 = $('#_rcmdjp_display_1'), eleFsRecommend2ContainerItemList2 = eleRcmdjpDisplay2.find('ul'), eleFsRecommend2ContainerItemList1 = eleRcmdjpDisplay1.find('ul'); eleFsRecommend2ContainerItemList2.appendTo('#footer_recommend2_container_item_list_parent0'); eleFsRecommend2ContainerItemList1.appendTo('#footer_recommend2_container_item_list_parent1'); eleRcmdjpDisplay2.remove(); eleRcmdjpDisplay1.remove(); }, funcEditProduct = () => { const eleFooterItemList = $('.footer_item_list'), eleFooterItemListLi = eleFooterItemList.find('li'), eleFooterItemListItemName = eleFooterItemList.find('.FS2_Recommend2_itemName'), eleFooterItemListItemPrice = eleFooterItemList.find('.itemPrice'); eleFooterItemListLi .each(function(){ const eleBr = $(this).find('br'); eleBr.remove(); }); eleFooterItemListItemName .each(function(){ const textThis = $(this).text(); $(this).html(textThis.replace( /レディース 大人 上品|レディース 大人 モード/g, '' ).trim()); }) .sliceStrLimit({ sliceStrLimit:15 }); eleFooterItemListItemPrice .each(function(){ const textThis = $(this).text(); $(this).html(textThis.replace( /円/g, '' ).trim()); }); }; funcGetScriptLink(); } ); })(jQuery);