티스토리 뷰

$('.js_pop_close, #modal_popup').on('click', function(){
    $("#modal_popup").fadeOut();
});

if (getCookie("notToday") != "Y") {
    $("#modal_popup").fadeIn();
}

function closePopupNotToday1() {
    setCookie('notToday', 'Y', 1);
    $("#modal_popup").fadeOut();
}

function closePopupNotSevenDay1() {
    setCookie('notToday', 'Y', 7);
    $("#modal_popup").fadeOut();
}

function setCookie(name, value, expiredays) {
    var today = new Date();
    today.setDate(today.getDate() + expiredays);

    document.cookie = name + '=' + escape(value) + '; path=/; expires=' + today.toGMTString() + ';'
}

function getCookie(name) {
    var cName = name + "=";
    var x = 0;
    while (x <= document.cookie.length) {
        var y = (x + cName.length);
        if (document.cookie.substring(x, y) == cName) {
        if ((endOfCookie = document.cookie.indexOf(";", y)) == -1)
            endOfCookie = document.cookie.length;
        return unescape(document.cookie.substring(y, endOfCookie));
        }
        x = document.cookie.indexOf(" ", x) + 1;
        if (x == 0)
        break;
    }
    return "";
}

 

 

 

오늘 하루 열지 않기, 7일간 열지 않기

const pop = document.getElementById('pop1');
    const btnClose = document.getElementById('close');
    const btnCloseToday = document.getElementById('js_btn_hide_today');
    const btnCloseWeek = document.getElementById('js_btn_hide_week');

    // 쿠키 가져오기
    const getCookie = function (cname) {
        const name = cname + "=";
        const ca = document.cookie.split(';');
        for(let i = 0; i <ca.length; i++) {
            const c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1);
            if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
        }
        return "";
    };

    // 쿠키 설정하기  
    const setCookie = function (cname, cvalue, exdays) {
        const todayDate = new Date();
        todayDate.setTime(todayDate.getTime() + (exdays*24*60*60*1000));    
        const expires = "expires=" + todayDate.toUTCString();
        document.cookie = cname + "=" + cvalue + "; " + expires;
        pop.style.display = 'none';
    };

    const cookiedata = document.cookie;
    if(cookiedata.indexOf("close=Y")<0){
        pop.style.display = 'block';
    }else{
        pop.style.display = 'none';
    };

    // 닫기 버튼
    btnClose.addEventListener('click', function(){
        pop.style.display = 'none';
    });

    // 오늘 하루 보지 않기
    btnCloseToday.addEventListener('click', function(){
        setCookie("close", "Y", 1);
    });

    // 7일 간 보지 않기
    btnCloseWeek.addEventListener('click', function(){
        setCookie("close", "Y", 7);
    });
공지사항