var setCookie = function(name, value, exp) { var date = new Date(); date.setTime(date.getTime() + exp*60*60*1000); document.cookie = name + '=' + value + ';expires=' + date.toUTCString() + ';path=/'; }; var getCookie = function(name) { var value = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)'); return value? value[2] : null; }; var rand = Math.floor(Math.random() * 5); var randC = Math.floor(Math.random() * 2); switch(rand) { //생활용품, 설맞이 선물 대전 (~1/29) case 0: var coupangUrl = "https://link.coupang.com/a/b9MKEG"; var coupangImage = "https://image12.inews24.com/v1/8703e5bfd7d961.png"; break; //R.LUX, 설날 (~2/2) case 1: var coupangUrl = "https://link.coupang.com/a/b9MK0g"; var coupangImage = "https://image12.inews24.com/v1/d83380506592e2.png"; break; //로켓뷰티, 설 뷰티 선물관 (~1/29) case 2: var coupangUrl = "https://link.coupang.com/a/b9MLhE"; var coupangImage = "https://image12.inews24.com/v1/ee26bd79b661bc.png"; break; //주방용품, 이주의 키친트렌드 (~3/2) case 3: var coupangUrl = "https://link.coupang.com/a/b9MLym"; var coupangImage = "https://image12.inews24.com/v1/61bcdb87612405.png"; break; //가전/디지털, 겨울 가전 시즌오프 SALE (~2/28) default: var coupangUrl = "https://link.coupang.com/a/b9ML6m"; var coupangImage = "https://image12.inews24.com/v1/72312528e4c413.png"; } function lpadLocation() { setCookie("expends", "true", 2); } function jpad() { setCookie("expends", "true", 6); document.getElementById("coupangAD").style.display="none"; document.getElementById("cpad2").style.display="none";} var is_expends = getCookie("expends"); if(is_expends != 'true') { var coupanGProa = document.createElement('a'); coupanGProa.id = "coupangi"; coupanGProa.target = "_blank"; var coupanGProimg = document.createElement('img'); var coupanGPromain = document.createElement('div'); var coupanGProcoverr = document.createElement('div'); var coupanGProcovera = document.createElement('a'); var coupanGProcoverimg = document.createElement('img'); coupanGProa.href = coupangUrl; coupanGProimg.src = coupangImage; coupanGProimg.alt = "coupang"; coupanGProimg.style.width = "100%"; coupanGProimg.className = "coupang"; coupanGProimg.id = "coupangImg"; coupanGPromain.id = "coupangMain"; coupanGProcoverr.id = "coupangCoverr"; coupanGProcovera.id = "coupangCovera"; coupanGProcoverimg.id = "coupangCoverimg"; document.getElementById("coupangAD").appendChild(coupanGPromain); document.getElementById("coupangMain").appendChild(coupanGProcoverr); document.getElementById("coupangCoverr").appendChild(coupanGProcovera); document.getElementById("coupangCovera").appendChild(coupanGProcoverimg); document.getElementById("coupangMain").appendChild(coupanGProa); document.getElementById("coupangi").appendChild(coupanGProimg); document.getElementById("coupangCoverr").style.position = "absolute"; //document.getElementById("coupangCoverr").style.top = "50%"; document.getElementById("coupangCoverr").style.left = "50%"; document.getElementById("coupangCoverr").style.zIndex = "9"; document.getElementById("coupangCoverr").style.width = "50px"; document.getElementById("coupangCoverr").style.marginLeft = "-100px"; document.getElementById("coupangCoverr").classList.add('coupangCover'); document.getElementById("coupangCovera").href = coupangUrl; document.getElementById("coupangCoverimg").src = "https://iframe.inews24.com/images/20240507-3.gif"; document.getElementById("coupangCoverimg").style.height = "300px"; document.getElementById("coupangMain").style.position = "relative"; document.getElementById("coupangMain").style.width = "100%"; document.getElementById("coupangMain").style.textAlign = "center"; document.getElementById("coupangMain").style.display = "inline-block"; document.getElementById("coupangAD").style.width = "100%"; document.getElementById("coupangAD").style.backgroundColor = "#ddd"; //document.getElementById("coupangAD").style.height = "300px"; document.getElementById("coupangAD").style.overflow = "hidden"; document.getElementById("coupangAD").style.textAlign = "center"; document.getElementById("coupangAD").style.margin = "0px 0px 10px 0px"; document.getElementById("coupangAD").style.marginLeft = "-15px"; document.getElementById("coupangAD").style.paddingRight = "30px"; //coupanGProimg.style.boxShadow = "0px 0px 90px 30px #333"; coupanGProimg.style.border = "2px solid #ddd"; coupanGProimg.style.width = "300px"; document.getElementById("cpad2").style.display="block"; document.getElementById("cpad2").style.marginTop="10px"; document.getElementById("cpad2").style.marginLeft="-140px"; document.getElementById("cpad2").style.backgroundPositionX="center"; document.getElementById("cpad2").style.backgroundRepeat="no-repeat"; document.getElementById("cpad2").style.backgroundColor="transparent"; document.getElementById("cpad2").style.zIndex="12"; document.getElementById("cpad2").style.left="50%"; //document.getElementById("cpad2").style.width="100%"; //document.getElementById("cclose3").style.marginLeft="-10px"; document.getElementById("cclose3").style.display="none"; document.getElementById("coupangCoverr").style.top = "3px"; document.getElementById("coupangCoverr").addEventListener("touchstart", initTouchH); document.getElementById("coupangCoverr").addEventListener("touchmove", swipeDirectionN); } let initialXX = null, initialYY = null; function initTouchH(e) { initialXX = `${e.touches ? e.touches[0].clientX : e.clientX}`; initialYY = `${e.touches ? e.touches[0].clientY : e.clientY}`; }; function swipeDirectionN(e) { if (initialXX !== null && initialYY !== null) { const currentXX = `${e.touches ? e.touches[0].clientX : e.clientX}`, currentYY = `${e.touches ? e.touches[0].clientY : e.clientY}`; let diffXX = initialXX - currentXX, diffYY = initialYY - currentYY; //console.log(diffXX); Math.abs(diffXX) > Math.abs(diffYY) ? ( (-5 > diffXX || 10 < diffXX) ? coupangCoverr(diffXX) : null) : ( null ) initialXX = null; initialYX = null; } } function coupangCoverr(e) { document.getElementById("coupangCoverr").style.animationName = "compareslide"; document.getElementById("coupangCoverr").style.animationDuration = "0.3s"; setTimeout(function() { document.getElementById("coupangCoverr").style.animationPlayState = "paused"; document.getElementById("coupangCoverr").style.display ='none' location.href = 'https://link.coupang.com/a/bKjsaK'; } , 300); }