function setCookie(name, value, days) { const date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); document.cookie = name + "=" + value + ";expires=" + date.toUTCString() + ";path=/"; } function getCookie(name) { const cname = name + "="; const decoded = decodeURIComponent(document.cookie); const cookies = decoded.split(';'); for (let i = 0; i < cookies.length; i++) { const c = cookies[i].trim(); if (c.indexOf(cname) === 0) return c.substring(cname.length, c.length); } return ""; } $(document).ready(function () { // ¸ðµç ÄíŰ ÆË¾÷À» Ã¼Å©ÇØ¼­ Ç¥½Ã ¿©ºÎ °áÁ¤ $('.pop_cookie').each(function () { const popupId = this.id; if (getCookie(popupId) !== 'hide') { $(this).show(); } else { $(this).hide(); } }); // ´Ý±â ¹öư Ŭ¸¯ ½Ã $('.pop_cookie .close_btn').on('click', function () { const $popup = $(this).closest('.pop_cookie'); const popupId = $popup.attr('id'); if ($popup.find('.hide_today').is(':checked')) { setCookie(popupId, 'hide', 1); } $popup.hide(); }); let outOfView = false; $('.pop_cookie').each(function () { const left = parseInt($(this).css('left'), 10); const width = $(this).outerWidth(); if ((left + width) > $(window).width()) { outOfView = true; return false; // Çϳª¶óµµ ³ÑÀ¸¸é ¹Ù·Î Áß´Ü } }); if (outOfView) { $('.pop_cookie').css({ top: 0, left: 0 }); } });