const appServerURL = "//apps.hyapps.com/"; var MorenvyBanner_AreaData = {"4093":{"id":"4093","name":"\uc0c1\uc138\ud398\uc774\uc9c0 \ud0ed \uad6c\uac04 \ud0c0\uc774\ud2c0\uba85","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1708587308424":{"id":"1708587308424","name":"Details","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"","openType":"_self"}],"AddOn":["open"],"index":0},"1708587310794":{"id":"1708587310794","name":"Material","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":1},"1708587311511":{"id":"1708587311511","name":"Size","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":2},"1708587312259":{"id":"1708587312259","name":"Shipping","isActive":false,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":3}},"index":7},"58fd":{"id":"58fd","name":"\ub85c\uace0","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1708582703644":{"id":"1708582703644","name":"\ub85c\uace0 - \ud53c\uc528","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 15:00:00","displayEndTime":"2024-02-22 15:00:00","html":"","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240325\/1d1eae552b53bbb13147cf071d4c947f.png","type":2}],"link":[{"url":"28px","openType":"_self"}],"AddOn":["REFRESH"],"index":0},"1708582705344":{"id":"1708582705344","name":"\ub85c\uace0 - \ubaa8\ubc14\uc77c","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 15:00:00","displayEndTime":"2024-02-22 15:00:00","html":"","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240325\/461a275e8d9e67df8f6cf13ba9328de7.png","type":2}],"link":[{"url":"26px","openType":"_self"}],"AddOn":["REFRESH"],"index":1}},"index":0},"78b4":{"id":"78b4","name":"\uba54\uc778\ubc30\ub108 PC","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1711685991954":{"id":"1711685991954","name":"","isActive":true,"displayType":0,"displayBeginTime":"2024-03-29 13:00:00","displayEndTime":"2024-03-29 13:00:00","html":"","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/bbd553b11cdf1bac419bbd0866d3b7bf.jpg","type":2}],"link":[{"url":"\/","openType":"_self"}],"AddOn":[""],"index":0},"1715606221888":{"id":"1715606221888","name":"","isActive":true,"displayType":0,"displayBeginTime":"2024-05-13 22:00:00","displayEndTime":"2024-05-13 22:00:00","html":"","img":[{"url":"https:\/\/ecimg.cafe24img.com\/pg305b70698375034\/virid79\/web\/upload\/NNEditor\/20240513\/22ae278f4c737322573dbb641aa6db31.jpg","type":2}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":1}},"index":2},"c8bb":{"id":"c8bb","name":"\uba54\uc778\uc0c1\ud488 (\ud0c0\uc774\ud2c0\uba85) (\ub9c1\ud06c)","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1708584608085":{"id":"1708584608085","name":"New Arrivals","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 15:00:00","displayEndTime":"2024-02-22 15:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":0},"1711604345323":{"id":"1711604345323","name":"More \u2192","isActive":true,"displayType":0,"displayBeginTime":"2024-03-28 14:00:00","displayEndTime":"2024-03-28 14:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"\/product\/list.html?cate_no=43","openType":"_self"}],"AddOn":[""],"index":1}},"index":3},"bc19":{"id":"bc19","name":"\uc5b4\ubc14\uc6c3","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1708584888789":{"id":"1708584888789","name":"VIRID
RUSTIC
POETRY","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 15:00:00","displayEndTime":"2024-02-22 15:00:00","html":"\ucc38\uc2e0\ud55c \uc18c\uc7ac\uc640 \ubaa8\ub358\ud55c \uc2e4\ub8e8\uc5e3, \uc790\uc5f0\uc2a4\ub7ec\uc6c0\uc774 \ud750\ub974\ub294 moia\ub294 \uc77c\uc0c1\uc5d0 \uc2a4\uba70\ub4dc\ub294 \uc637, <\/span>\n\uc624\ub798 \uac04\uc9c1\ud558\uace0 \uc2f6\uc740 \uac83\uc5d0 \uac00\uce58\ub97c \ub461\ub2c8\ub2e4. \ucc38\uc2e0\ud55c \uc18c\uc7ac\uc640 \ubaa8\ub358\ud55c \uc2e4\ub8e8\uc5e3, \uc790\uc5f0\uc2a4\ub7ec\uc6c0\uc774 \ud750\ub974\ub294 <\/span>\nmoia\ub294 \uc77c\uc0c1\uc5d0 \uc2a4\uba70\ub4dc\ub294 \uc637, \uc624\ub798 \uac04\uc9c1\ud558\uace0 \uc2f6\uc740 \uac83\uc5d0 \uac00\uce58\ub97c \ub461\ub2c8\ub2e4. <\/span>","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240424\/37a1a4d66c5ba0be5aab654d7be16b53.jpg","type":2}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":0}},"index":4},"e11a":{"id":"e11a","name":"\uc0c1\ub2e8 \uacf5\uc9c0 \ub760\ubc30\ub108","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1708586842564":{"id":"1708586842564","name":"Special Sale 30%","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"\/","openType":"_self"}],"AddOn":["background:#111;","color:#fff;"],"index":0}},"index":5},"c62f":{"id":"c62f","name":"SNS \uc815\ubcf4","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-22","bannerList":{"1708587223175":{"id":"1708587223175","name":"<\/i>","isActive":true,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"http:\/\/instagram.com\/","openType":"_self"}],"AddOn":[""],"index":0},"1708587240344":{"id":"1708587240344","name":"<\/i>","isActive":false,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"http:\/\/facebook.com\/","openType":"_self"}],"AddOn":[""],"index":1},"1708587241392":{"id":"1708587241392","name":"<\/i>","isActive":false,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"http:\/\/twitter.com\/","openType":"_self"}],"AddOn":[""],"index":2},"1708587242193":{"id":"1708587242193","name":"<\/i>","isActive":false,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"http:\/\/blog.naver.com\/","openType":"_self"}],"AddOn":[""],"index":3},"1708587262882":{"id":"1708587262882","name":"<\/i>","isActive":false,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"http:\/\/pinterest.com\/","openType":"_self"}],"AddOn":[""],"index":4},"1708587263597":{"id":"1708587263597","name":"<\/i>","isActive":false,"displayType":0,"displayBeginTime":"2024-02-22 16:00:00","displayEndTime":"2024-02-22 16:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"http:\/\/kakao.com\/","openType":"_self"}],"AddOn":[""],"index":5}},"index":6},"82ea":{"id":"82ea","name":"\uba54\uc778\ubc30\ub108 MO","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-23","bannerList":{"1711686035801":{"id":"1711686035801","name":"","isActive":true,"displayType":0,"displayBeginTime":"2024-03-29 13:00:00","displayEndTime":"2024-03-29 13:00:00","html":"","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/1a46f0ce335b88091181bb1190a45d41.jpg","type":2}],"link":[{"url":"\/","openType":"_self"}],"AddOn":[""],"index":0},"1715606298236":{"id":"1715606298236","name":"","isActive":true,"displayType":0,"displayBeginTime":"2024-05-13 22:00:00","displayEndTime":"2024-05-13 22:00:00","html":"","img":[{"url":"https:\/\/ecimg.cafe24img.com\/pg305b70698375034\/virid79\/web\/upload\/NNEditor\/20240513\/29406c75a47ebb45c2f687bd51970d8d.jpg","type":2}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":1}},"index":1},"88a9":{"id":"88a9","name":"\uc0c1\ud488\uac80\uc0c9 \uce74\ud14c\uace0\ub9ac \ubc88\ud638","desc":"","displayType":"0","isActive":true,"createDate":"2024-02-23","bannerList":{"1708666966471":{"id":"1708666966471","name":"42","isActive":true,"displayType":0,"displayBeginTime":"2024-02-23 14:00:00","displayEndTime":"2024-02-23 14:00:00","html":"","img":[{"url":"","type":0}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":0}},"index":8},"921a":{"id":"921a","name":"\uceec\ub809\uc158 \uc0c1\ub2e8 \ubc30\ub108","desc":"","displayType":"0","isActive":true,"createDate":"2024-03-26","bannerList":{"1711431813689":{"id":"1711431813689","name":"24k Kumbu","isActive":true,"displayType":0,"displayBeginTime":"2024-03-26 14:00:00","displayEndTime":"2024-03-26 14:00:00","html":"\u2018\uae08\ubd80\u2019\ub294 \uc21c\uc740 \uc704\uc5d0 \uc587\uc740 \uc21c\uae08\uc744 \uc785\ud788\ub294 \ubc29\uc2dd\uc785\ub2c8\ub2e4.
\n\uc6b0\ub9ac\ub098\ub77c\uc758 \uc804\ud1b5 \uae30\ubc95\uc73c\ub85c \uc2dc\uac04\uc774 \ud750\ub97c\uc218\ub85d \uc544\ub984\ub2e4\uc6c0\uc774 \ub354\ud574\uc9d1\ub2c8\ub2e4.","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/80a6bc99113705bf201664f8f57d17f3.jpg","type":2},{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/97cf2da976521c8c264a7b2b1432d88c.jpg","type":2}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":0},"1711432047625":{"id":"1711432047625","name":"Pearl & white","isActive":true,"displayType":0,"displayBeginTime":"2024-03-26 14:00:00","displayEndTime":"2024-03-26 14:00:00","html":"\ucc9c\uc5f0 \ub2f4\uc218\uc9c4\uc8fc\uc640
\n\uc0c9\uacfc \ube5b\uc774 \uc544\ub984\ub2e4\uc6b4 \ubb38\uc2a4\ud1a4\uc744 \uc120\ubcc4\ud574 \uc791\uc5c5\ud569\ub2c8\ub2e4.","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/0ae947fa26b79f2e4fd687b2f7f048e3.jpg","type":2},{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/3f36b201f8ff118fc37feb96ec272d0a.jpg","type":2}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":1},"1711432048658":{"id":"1711432048658","name":"Roman glass","isActive":true,"displayType":0,"displayBeginTime":"2024-03-26 14:00:00","displayEndTime":"2024-03-26 14:00:00","html":"\u2018\ub85c\ub9cc\uae00\ub77c\uc2a4'\ub294 \ub85c\ub9c8\uc2dc\ub300\uc5d0 \uadc0\ud558\uac8c \uc720\ud1b5\ub418\ub358 \uae00\ub77c\uc2a4\ub85c
\n \uc2dc\uac04\uc758 \ud754\uc801\uacfc \uc774\uc57c\uae30\uac00 \uae43\ub4e4\uc5b4 \uc788\uc2b5\ub2c8\ub2e4.","img":[{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/f03ee5cf965f26bba06338abda655b6c.jpg","type":2},{"url":"https:\/\/ecudemo320544.cafe24.com\/web\/upload\/NNEditor\/20240329\/882f080a18c6fe29f8e072337da0de4d.jpg","type":2}],"link":[{"url":"","openType":"_self"}],"AddOn":[""],"index":2}},"index":9}}; var LastSaveData = { "lastSaveSkin": "Refresh 반응형 KR", "lastSaveDate": "2024-05-13 22:27:04" }; // 아이콘 var IconsPC = {"soldout":"https:\/\/img.echosting.cafe24.com\/design\/skin\/admin\/ko_KR\/ico_product_soldout.gif"}; var IconsMobile = {"soldout":"https:\/\/img.echosting.cafe24.com\/design\/skin\/admin\/ko_KR\/ico_product_soldout.gif"}; // 활성된 배너 엘리먼트, 배너 데이터 var activeBannerElem = []; //--------------------------------------------------------------------------------------------------------------------------------- // 배너 관리자 Init_MorenvyBannerManager(); //(function( CAFE24API ) function Init_MorenvyBannerManager() { console.log( "%c----- Banner Manager -----", "color:rgb(20, 85, 249); font-size: 25px;" ); console.log( "최종 수정 스킨 : " + LastSaveData[ "lastSaveSkin" ] ); console.log( "최종 수정 일자 : " + LastSaveData[ "lastSaveDate" ] ); console.log( "https://morenvy.com" ); console.log( "%c--------------------------", "color:rgb(20, 85, 249); font-size: 25px;" ); // 배너영역 클래스 검색 var bannerAreaList = document.getElementsByClassName( "morenvy-banner-area" ); if( null == bannerAreaList ) return; for( var i = 0; i < bannerAreaList.length; ) { // HTML에서 배너영역 ID 가져온다 var bannerArea = bannerAreaList[ i ]; var areaID = bannerArea.getAttribute( "area_id" ); // 배너영역 ID로 데이터 검색 var areaData = MorenvyBanner_AreaData[ areaID ]; if( null == areaData ) { bannerArea.style.display = "none"; ++i; continue; } // 순서대로 출력 var bannerArray = []; if( "0" == areaData.displayType ) { for( var key in areaData.bannerList ) { bannerArray.push( areaData.bannerList[ key ] ); } bannerArray.sort( function( a, b ) { return a.index > b.index ? 1 : -1; } ); } // 랜덤 출력 else if( "1" == areaData.displayType ) { for( var key in areaData.bannerList ) { areaData.bannerList[ key ].random = Math.random(); bannerArray.push( areaData.bannerList[ key ] ); } bannerArray.sort( function( a, b ) { return a.random > b.random ? 1 : -1; } ); } var bannerList = bannerAreaList[ i ].getElementsByClassName( "morenvy-banner" ); if( 0 == bannerList.length ) { bannerArea.style.display = "none"; ++i; continue; } // 설정 수 보다 엘리먼트가 부족할 경우 마지막 엘리먼트 복사 if( bannerList.length < bannerArray.length ) { var copyTarget = bannerList[ bannerList.length - 1 ]; var loopCount = bannerArray.length - bannerList.length; for( var j = 0; j < loopCount; ++j ) { var copyElem = copyTarget.cloneNode( true ); //bannerAreaList[ i ].append( copyElem ); copyTarget.parentElement.append( copyElem ); } } var showIndex = 0; for( var j = 0; j < bannerList.length; ) { var bannerData = j >= bannerArray.length ? null : bannerArray[ j ]; // 배너 데이터 없음 if( null == bannerData ) { bannerList[ j ].remove(); bannerArray.splice( j, 1 ); continue; } // 활성 중? if( false == bannerData.isActive ) { bannerList[ j ].remove(); bannerArray.splice( j, 1 ); continue; } // 기간 노출 if( 1 == bannerData.displayType ) { var beginDate = new Date( bannerData.displayBeginTime.replace( /-/g, "/" ) ); var endDate = new Date( bannerData.displayEndTime.replace( /-/g, "/" ) ); var curTime = new Date(); if( beginDate > curTime || endDate < curTime ) { bannerList[ j ].remove(); bannerArray.splice( j, 1 ); continue; } } var html = bannerList[ j ].innerHTML; html = html.replace( /%7B/gi, "{" ); html = html.replace( /%7D/gi, "}" ); html = html.replace( /{#areaName}/gi, areaData.name ); html = html.replace( /{#areaDesc}/gi, areaData.desc ); html = html.replace( /{#areaDisplayType}/gi, areaData.displayType ); html = html.replace( /{#num}/gi, ++showIndex ); html = html.replace( /{#title}/gi, bannerData.name ); html = html.replace( /{#displayType}/gi, bannerData.displayType ); html = html.replace( /{#displayBeginTime}/gi, bannerData.displayBeginTime ); html = html.replace( /{#displayEndTime}/gi, bannerData.displayEndTime ); html = html.replace( /{#text_1}/gi, 0 < bannerData.AddOn.length ? bannerData.AddOn[ 0 ] : "" ); html = html.replace( /{#text_2}/gi, 1 < bannerData.AddOn.length ? bannerData.AddOn[ 1 ] : bannerData.AddOn[ bannerData.AddOn.length - 1 ] ); html = html.replace( /{#text_3}/gi, 2 < bannerData.AddOn.length ? bannerData.AddOn[ 2 ] : bannerData.AddOn[ bannerData.AddOn.length - 1 ] ); html = html.replace( /{#link_1}/gi, 0 < bannerData.link.length ? bannerData.link[ 0 ].url : "" ); html = html.replace( /{#link_2}/gi, 1 < bannerData.link.length ? bannerData.link[ 1 ].url : bannerData.link[ bannerData.link.length - 1 ].url ); html = html.replace( /{#link_3}/gi, 2 < bannerData.link.length ? bannerData.link[ 2 ].url : bannerData.link[ bannerData.link.length - 1 ].url ); html = html.replace( /{#target_1}/gi, 0 < bannerData.link.length ? bannerData.link[ 0 ].openType : "" ); html = html.replace( /{#target_2}/gi, 1 < bannerData.link.length ? bannerData.link[ 1 ].openType : bannerData.link[ bannerData.link.length - 1 ].openType ); html = html.replace( /{#target_3}/gi, 2 < bannerData.link.length ? bannerData.link[ 2 ].openType : bannerData.link[ bannerData.link.length - 1 ].openType ); html = html.replace( /{#html}/gi, bannerData.html ); html = html.replace( /{#imgTag_1}/gi, 0 < bannerData.img.length ? "" : "" ); html = html.replace( /{#imgTag_2}/gi, 1 < bannerData.img.length ? "" : "" ); html = html.replace( /{#imgTag_3}/gi, 2 < bannerData.img.length ? "" : "" ); html = html.replace( /{#imgSrc_1}/gi, 0 < bannerData.img.length ? bannerData.img[ 0 ].url : "" ); html = html.replace( /{#imgSrc_2}/gi, 1 < bannerData.img.length ? bannerData.img[ 1 ].url : bannerData.img[ bannerData.img.length - 1 ].url ); html = html.replace( /{#imgSrc_3}/gi, 2 < bannerData.img.length ? bannerData.img[ 2 ].url : bannerData.img[ bannerData.img.length - 1 ].url ); bannerList[ j ].innerHTML = html; activeBannerElem.push( { elem : bannerList[ j ], bannerData : bannerData } ); ++j; } if( 0 == bannerList.length ) bannerArea.style.display = "none"; ++i; bannerArea.classList.add( "init" ); } }/* )( CAFE24API.init( { version: "2022-09-01", client_id: "gSOPn7dNJxAp8cu31kDDtD" } ) );*/ //---------------------------------------------------------------------------------------------------------------------------- // 상품 진열 플러그인 function Init_MorenvyProductDisplay() { // 상품 정보 요청 최대 개수, cafe24에서 최대 100개까지 지원됨. const maxSearchCount = 100; // 상품 정보 요청할 상품 번호 var needToSearchProduct = {}; // 상품 정보 콜백 받은 후 html replace 필요한 엘리먼트들, 해당 엘리먼트 내 상품 번호 var needToReplaceElems = []; // 초기화 필요한 product area var needToInitPrudctArea = []; // replace 필요한 상품 배열 데이터 var needToReplaceArray = {}; // 모바일인지 체크 var isMobile = /Mobi/i.test( window.navigator.userAgent ); // 상품 관련 태그를 상품 번호 태그로 매핑 // ex) {#productName} ----> {#19_Name} function replaceToProductNo( html, tagName, productNo, replace ) { const regExp = new RegExp( `{${"#" + tagName}}`, "gi" ); if( null != productNo ) html = html.replace( regExp, "{#" + productNo + "_" + replace + "}" ); else html = html.replace( regExp, "" ); return html; } // 배열 데이터 태그 replace function replaceToArrayProductNo( html, tagName, productNo, replace ) { var nextIndex = 0; while( true ) { var startIndex = html.indexOf( "{#" + tagName, nextIndex ); if( -1 == startIndex ) break; var endIndex = html.indexOf( "}", startIndex ); if( -1 == endIndex ) break; var arrayIndex = html.slice( startIndex + String( "{#" + tagName ).length + 1, endIndex ); if( null == needToReplaceArray[ productNo ] ) needToReplaceArray[ productNo ] = new Object(); if( null == needToReplaceArray[ productNo ][ replace ] ) needToReplaceArray[ productNo ][ replace ] = new Object(); needToReplaceArray[ productNo ][ replace ][ arrayIndex ] = 0; nextIndex = endIndex + 1; } const regExp = new RegExp( `{${"#" + tagName + "_"}`, "gi" ); if( null != productNo ) html = html.replace( regExp, "{#" + productNo + "_" + replace + "_" ); else html = html.replace( regExp, "" ); return html; } // 상품 번호로 매핑된 태그를 실제 상품 정보로 replace function replaceTag( html, productNo, tag, replace ) { const regExp = new RegExp( `{${"#" + productNo + "_" + tag}}`, "gi" ); html = html.replace( regExp, replace ); return html; } // 상품 번호로 매핑된 태그를 실제 상품 정보로 replace (한개만) function replaceOneTag( html, productNo, tag, replace ) { html = html.replace( "{#" + productNo + "_" + tag + "}", replace ); return html; } // 상품 번호로 매핑된 태그를 실제 상품 정보로 replace function replaceArrayTag( index, html, productNo, tag, replace ) { const regExp = new RegExp( `{${"#" + productNo + "_" + tag + "_" + index}}`, "gi" ); html = html.replace( regExp, replace ); return html; } // 배너관리자에서 활성된 배너 for( var key in activeBannerElem ) { // 활성된 배너 데이터 var bannerData = activeBannerElem[ key ].bannerData; // 상품 진열 데이터 없음 if( null == bannerData.productDisplay || 0 == bannerData.productDisplay.length ) continue; // 상품 진열 영역 var productAreaList = activeBannerElem[ key ].elem.getElementsByClassName( "morenvy-product-area" ); if( null == productAreaList || 0 == productAreaList.length ) continue; for( var i = 0; i < productAreaList.length; ) { var productArea = productAreaList[ i ]; var productList = productArea.getElementsByClassName( "morenvy-product" ); if( null == productList || 0 == productList.length ) { productAreaList[ i ].remove(); continue; } // 설정 수 보다 엘리먼트가 부족할 경우 마지막 엘리먼트 복사 if( productList.length < bannerData.productDisplay.length ) { var copyTarget = productList[ productList.length - 1 ]; var loopCount = bannerData.productDisplay.length - productList.length; for( var j = 0; j < loopCount; ++j ) { var copyElem = copyTarget.cloneNode( true ); productArea.append( copyElem ); } } for( var j = 0; j < productList.length; ) { // 상품 검색 최대 수 도달 if( maxSearchCount <= Object.keys( needToSearchProduct ).length ) break; var productNo = j >= bannerData.productDisplay.length ? null : bannerData.productDisplay[ j ]; // 상품 데이터 없음 if( null == productNo ) { productList[ j ].remove(); bannerData.productDisplay.splice( j, 1 ); continue; } var html = productList[ j ].innerHTML; html = html.replace( /%7B/gi, "{" ); html = html.replace( /%7D/gi, "}" ); // 모바일/PC에 따라 아이콘 다름 if( false == isMobile ) { html = html.replace( /{#soldout_icon}/gi, IconsPC[ "soldout" ] ); html = html.replace( /{#soldout_iconTag}/gi, "" ); } else { html = html.replace( /{#soldout_icon}/gi, IconsMobile[ "soldout" ] ); html = html.replace( /{#soldout_iconTag}/gi, "" ); } // 상품 번호 매핑 html = html.replace( /{#productNo}/gi, productNo ); // 상품 태그를 상품 번호 태그로 매핑 html = replaceToProductNo( html, "link", productNo, "Link" ); html = replaceToProductNo( html, "name", productNo, "Name" ); html = replaceToProductNo( html, "nameEn", productNo, "NameEn" ); html = replaceToProductNo( html, "price", productNo, "Price" ); html = replaceToProductNo( html, "retailPrice", productNo, "RetailPrice" ); html = replaceToProductNo( html, "discountPrice", productNo, "DiscountPrice" ); html = replaceToProductNo( html, "imgBig", productNo, "ImgBig" ); html = replaceToProductNo( html, "imgBigTag", productNo, "ImgBigTag" ); html = replaceToProductNo( html, "imgMedium", productNo, "ImgMedium" ); html = replaceToProductNo( html, "imgMediumTag", productNo, "ImgMediumTag" ); html = replaceToProductNo( html, "imgSmall", productNo, "ImgSmall" ); html = replaceToProductNo( html, "imgSmallTag", productNo, "ImgSmallTag" ); html = replaceToProductNo( html, "imgTiny", productNo, "ImgTiny" ); html = replaceToProductNo( html, "imgTinyTag", productNo, "ImgTinyTag" ); html = replaceToProductNo( html, "summaryDesc", productNo, "SummaryDesc" ); html = replaceToProductNo( html, "simpleDesc", productNo, "SimpleDesc" ); html = replaceToProductNo( html, "customCode", productNo, "CustomCode" ); html = replaceToProductNo( html, "modelName", productNo, "ModelName" ); html = replaceToProductNo( html, "brand", productNo, "Brand" ); html = replaceToProductNo( html, "trend", productNo, "Trend" ); html = replaceToProductNo( html, "manu", productNo, "Manu" ); html = replaceToProductNo( html, "opt_discountPrice", productNo, "Opt_DiscountPrice" ); html = replaceToProductNo( html, "coupon_discountPrice", productNo, "Coupon_DiscountPrice" ); html = replaceToProductNo( html, "promotion_period", productNo, "Promotion_Period" ); // addImg / addImgTag 처럼 태그 이름이 확장되는 경우 확장된 놈부터 replace, 에러남 html = replaceToArrayProductNo( html, "addInfo_name", productNo, "AddInfo_Name" ); html = replaceToArrayProductNo( html, "addInfo_value", productNo, "AddInfo_Value" ); html = replaceToArrayProductNo( html, "addImgTag", productNo, "AddImgTag" ); html = replaceToArrayProductNo( html, "addImg", productNo, "AddImg" ); productList[ j ].innerHTML = html; needToSearchProduct[ productNo ] = 0; needToReplaceElems.push( { areaElem : productArea, productNo : productNo, productElem : productList[ j ] } ); ++j; } needToInitPrudctArea.push( productArea ); ++i; } } // 상품 검색 Search(); function applyProductData( products ) { // replace가 먼저 되면 엘리먼트 삭제가 안된다. // 삭제할 엘리먼트만 먼저 찾아서 삭제 for( var key in needToReplaceElems ) { // 상품 엘리먼트 var productElem = needToReplaceElems[ key ].productElem; // 상품 번호 var productNo = needToReplaceElems[ key ].productNo; // 해당 번호의 상품 데이터 없음. 엘리먼트 삭제 var data = products[ productNo ]; if( null == data ) { productElem.remove(); continue; } // 진열중 아니거나 판매중 아니면 엘리먼트 삭제 if( "F" == data.selling || "F" == data.display ) { productElem.remove(); continue; } } // 검색된 상품 정보를 각각의 엘리먼트에 상품 번호로 매핑된 태그를 찾아 replace for( var key in needToReplaceElems ) { // 상품 영역 엘리먼트 var productAreaElem = needToReplaceElems[ key ].areaElem; // 상품 엘리먼트 var productElem = needToReplaceElems[ key ].productElem; // 상품 번호 var productNo = needToReplaceElems[ key ].productNo; var data = products[ productNo ]; if( null == data || "F" == data.selling || "F" == data.display ) continue; // PC/모바일 할인가가 다름 var discount = true == isMobile ? data.discountprice.mobile_discount_price : data.discountprice.pc_discount_price; var html = productAreaElem.innerHTML; html = html.replace( /%7B/gi, "{" ); html = html.replace( /%7D/gi, "}" ); html = replaceTag( html, data.product_no, "Link", "/product/detail.html?product_no=" + data.product_no ); html = replaceTag( html, data.product_no, "Name", data.product_name ); html = replaceTag( html, data.product_no, "NameEn", data.eng_product_name ); html = replaceTag( html, data.product_no, "Price", parseInt( data.price ).toLocaleString() ); html = replaceTag( html, data.product_no, "RetailPrice", parseInt( data.retail_price ).toLocaleString() ); html = replaceTag( html, data.product_no, "DiscountPrice", parseInt( discount ).toLocaleString() ); html = replaceTag( html, data.product_no, "ImgBig", data.detail_image ); html = replaceTag( html, data.product_no, "ImgBigTag", "" ); html = replaceTag( html, data.product_no, "ImgMedium", data.list_image ); html = replaceTag( html, data.product_no, "ImgMediumTag", "" ); html = replaceTag( html, data.product_no, "ImgSmall", data.small_image ); html = replaceTag( html, data.product_no, "ImgSmallTag", "" ); html = replaceTag( html, data.product_no, "ImgTiny", data.tiny_image ); html = replaceTag( html, data.product_no, "ImgTinyTag", "" ); html = replaceTag( html, data.product_no, "SummaryDesc", data.summary_description ); html = replaceTag( html, data.product_no, "CustomCode", data.custom_product_code ); html = replaceTag( html, data.product_no, "ModelName", data.model_name ); productAreaElem.innerHTML = html; ++i; } // 상품 영역 초기화 완료 for( var key in needToInitPrudctArea ) { needToInitPrudctArea[ key ].classList.add( "init" ); } } function Search() { // 검색 필요한 상품 없음 if( 0 == Object.keys( needToSearchProduct ).length ) return; var count = 0; // 상품 검색 파라미터 var searchParam = "?embed=discountprice&product_no="; for( var key in needToSearchProduct ) { ++count; if( 1 < count ) searchParam += ","; searchParam += key; } // 상품 검색 개수, cafe24에서 최대 100개까지 지원됨. searchParam += "&limit=" + maxSearchCount; // 상품 검색 요청 CAFE24API.get( "/api/v2/products" + searchParam, function( err, res ) { // 상품 번호를 키로 object 변환 var products = {}; for( var i in res.products ) { products[ res.products[ i ].product_no ] = res.products[ i ]; } applyProductData( products ); var reqDetailCount = 0; var totalReqCount = 0; var totalApplyCount = 0; function reqDetail() { var arrProductNo = Object.keys( needToSearchProduct ); if( 0 == arrProductNo ) return; ++reqDetailCount; ++totalReqCount; var productNo = arrProductNo[ 0 ]; CAFE24API.get( "/api/v2/productsdetail/" + productNo, function( err, res ) { if( null != err ) { setTimeout( function() { reqDetailCount -= 1; reqDetail(); }, 100 ); return; } applyProductDetail( res.productsdetail ); ++totalApplyCount; if( totalApplyCount == totalReqCount ) replaceNaN(); delete needToSearchProduct[ productNo ]; if( 40 <= reqDetailCount ) { setTimeout( function() { reqDetailCount -= 1; reqDetail(); }, 100 ); } else { reqDetail(); } } ); } reqDetail(); function applyProductDetail( data ) { // 상품 진열 영역 var productAreaList = document.getElementsByClassName( "morenvy-product-area" ); if( null == productAreaList || 0 == productAreaList.length ) return; for( var i = 0; i < productAreaList.length; ++i ) { var elem = productAreaList[ i ]; var html = elem.innerHTML; html = html.replace( /%7B/gi, "{" ); html = html.replace( /%7D/gi, "}" ); html = replaceTag( html, data.product_no, "SimpleDesc", null == data.simple_description ? "" : data.simple_description ); html = replaceTag( html, data.product_no, "Brand", null == data.brand_name ? "" : data.brand_name ); html = replaceTag( html, data.product_no, "Trend", null == data.trend_name ? "" : data.trend_name ); html = replaceTag( html, data.product_no, "Manu", null == data.manufacturer_name ? "" : data.manufacturer_name ); html = replaceTag( html, data.product_no, "Opt_DiscountPrice", null == data.optimum_discount_price ? "" : arseInt( data.optimum_discount_price ).toLocaleString() ); html = replaceTag( html, data.product_no, "Coupon_DiscountPrice", null == data.coupon_discounted_price ? "" : parseInt( data.coupon_discounted_price ).toLocaleString() ); if( null != data.promotion_period ) { var startDate = new Date( data.promotion_period.start_date ); var endDate = new Date( data.promotion_period.end_date ); var timeText = startDate.getFullYear() + "-" + (startDate.getMonth() + 1).toString().padStart( 2, "0" ) + "-" + startDate.getDate().toString().padStart( 2, "0" ) + " " + startDate.getHours().toString().padStart( 2, "0" ) + ":" + startDate.getMinutes().toString().padStart( 2, "0" ) + " ~ " + endDate.getFullYear() + "-" + (endDate.getMonth() + 1).toString().padStart( 2, "0" ) + "-" + endDate.getDate().toString().padStart( 2, "0" ) + " " + endDate.getHours().toString().padStart( 2, "0" ) + ":" + endDate.getMinutes().toString().padStart( 2, "0" ); html = replaceTag( html, data.product_no, "Promotion_Period", timeText ); } else { html = replaceTag( html, data.product_no, "Promotion_Period", data.coupon_discounted_price ); } if( null != data.additional_information ) { for( var j = 0; j < data.additional_information.length; ++j ) { const info = data.additional_information[ j ]; html = replaceArrayTag( j + 1, html, data.product_no, "AddInfo_Name", info.name ); html = replaceArrayTag( j + 1, html, data.product_no, "AddInfo_Value", info.value ); if( null != needToReplaceArray[ data.product_no ] ) { if( null != needToReplaceArray[ data.product_no ][ "AddInfo_Name" ] ) delete needToReplaceArray[ data.product_no ][ "AddInfo_Name" ][ (j + 1).toString() ]; if( null != needToReplaceArray[ data.product_no ][ "AddInfo_Value" ] ) delete needToReplaceArray[ data.product_no ][ "AddInfo_Value" ][ (j + 1).toString() ]; } } } if( null != data.additional_images ) { for( var j = 0; j < data.additional_images.length; ++j ) { const img = data.additional_images[ j ]; html = replaceArrayTag( j + 1, html, data.product_no, "AddImg", img.big ); html = replaceArrayTag( j + 1, html, data.product_no, "AddImgTag", "" ); if( null != needToReplaceArray[ data.product_no ] ) { if( null != needToReplaceArray[ data.product_no ][ "AddImg" ] ) delete needToReplaceArray[ data.product_no ][ "AddImg" ][ (j + 1).toString() ]; if( null != needToReplaceArray[ data.product_no ][ "AddImgTag" ] ) delete needToReplaceArray[ data.product_no ][ "AddImgTag" ][ (j + 1).toString() ]; } } } elem.innerHTML = html; } } } ); } // 태그 변수 입력은 됐는데 실제 조회 후 데이터가 없는 경우 NaN으로 replace function replaceNaN() { for( var keyProductNo in needToReplaceArray ) { for( var keyTag in needToReplaceArray[ keyProductNo ] ) { for( var keyNum in needToReplaceArray[ keyProductNo ][ keyTag ] ) { for( var i = 0; i < productAreaList.length; ++i ) { var elem = productAreaList[ i ]; var html = elem.innerHTML; html = replaceTag( html, keyProductNo, keyTag + "_" + keyNum, "" ); elem.innerHTML = html; } } } } } } let Morenvy_Wait_CAEF24 = setInterval( () => { if( typeof CAFE24API != "undefined" ) { clearInterval( Morenvy_Wait_CAEF24 ); (function( CAFE24API ) { Init_MorenvyProductDisplay(); } )( CAFE24API.init( { version: "2022-09-01", client_id: "gSOPn7dNJxAp8cu31kDDtD" } ) ); } }, 50 );