class PopupManager { constructor() { this.cookieName = 'popup_closed'; this.cookieExpiry = 365; this.cookiePolicyName = 'cookie_policy_accepted'; this.init(); this.initCookiePolicy(); } init() { if (this.isPopupClosed()) return; setTimeout(() => this.loadPopupContent(), 10000); } // Инициализация cookie policy попапа initCookiePolicy() { if (this.isCookiePolicyAccepted()) return; setTimeout(() => this.showCookiePolicy(), 100); } isPopupClosed() { return document.cookie.split(';').some(cookie => cookie.trim().startsWith(this.cookieName + '=') ); } isCookiePolicyAccepted() { return document.cookie.split(';').some(cookie => cookie.trim().startsWith(this.cookiePolicyName + '=') ); } setPopupClosed() { const date = new Date(); date.setTime(date.getTime() + (this.cookieExpiry * 24 * 60 * 60 * 1000)); document.cookie = `${this.cookieName}=true;expires=${date.toUTCString()};path=/`; } setCookiePolicyAccepted() { const date = new Date(); date.setTime(date.getTime() + (this.cookieExpiry * 24 * 60 * 60 * 1000)); document.cookie = `${this.cookiePolicyName}=true;expires=${date.toUTCString()};path=/`; } loadPopupContent() { const timestamp = new Date().getTime(); $.getJSON(`/popup/random?t=${timestamp}`) .done(data => { if (data.success) this.showPopup(data.content); }) .fail(error => { console.error('Error loading popup:', error); }); } showPopup(content) { const popupContainer = $( `