Reach Local Readers

Promote your business on thepost.sydney. View our latest advertising rates today.

See Media Kit
document.addEventListener("DOMContentLoaded", function() { const popup = document.getElementById('ad-promo-popup'); const closeBtn = document.getElementById('ad-popup-close'); const neverShowCheckbox = document.getElementById('ad-popup-never-show'); // Keys for LocalStorage const lastSeenKey = 'thepost_ad_popup_seen_date'; const neverShowKey = 'thepost_ad_popup_never_show'; // Config: 30 days in milliseconds const daysToWait = 30; const timeLimit = daysToWait * 24 * 60 * 60 * 1000; // 1. Check if we should show the popup function shouldShowPopup() { // If user previously checked "Don't show again", stop immediately. if (localStorage.getItem(neverShowKey) === 'true') { return false; } const lastSeen = localStorage.getItem(lastSeenKey); // If never seen before, show it if (!lastSeen) return true; // Calculate time difference const now = new Date().getTime(); const difference = now - parseInt(lastSeen); // Only show if more than 30 days have passed return difference > timeLimit; } // 2. Function to handle closing function closePopup() { popup.classList.remove('is-visible'); if (neverShowCheckbox.checked) { // If box is checked, set the permanent flag localStorage.setItem(neverShowKey, 'true'); } else { // If box is NOT checked, just update the date (snooze for 30 days) localStorage.setItem(lastSeenKey, new Date().getTime().toString()); } } // 3. Trigger Animation if (shouldShowPopup()) { setTimeout(() => { popup.classList.add('is-visible'); }, 3000); // 3-second delay } // 4. Event Listeners closeBtn.addEventListener('click', closePopup); });