GOALNEWS | Football, Matches & Global Tournaments
// Abrir pop-up
function openPopup(popupId) {
document.getElementById(popupId).style.display = 'flex';
}
// Fechar pop-up
function closePopup(popupId) {
document.getElementById(popupId).style.display = 'none';
}
// Rating stars
function ratePopup(rating) {
const stars = document.querySelectorAll('.gn-star');
stars.forEach((star, index) => {
if (index < rating) star.classList.add('active');
else star.classList.remove('active');
});
}
// Submit survey
function submitSurvey() {
const textarea = document.querySelector('.gn-survey-textarea');
if (textarea.value.trim() === '') {
alert('Please enter your feedback');
return;
}
alert('Thank you!');
closePopup('gn-popup-survey');
}
// Newsletter
function handleNewsletterSubmit(event) {
event.preventDefault();
alert('Subscribed!');
closePopup('gn-popup-newsletter');
}
// Initializing Popups
function initPopups() {
const settings = {
newsletter: { enabled: true, delay: 3 },
alert: { enabled: true, delay: 10 },
offer: { enabled: true, delay: 15 },
app: { enabled: true, delay: 20 },
social: { enabled: true, delay: 25 },
survey: { enabled: true, delay: 30 }
};
function show(name, id) {
if (!settings[name].enabled) return;
setTimeout(() => openPopup(id), settings[name].delay * 1000);
}
show('newsletter', 'gn-popup-newsletter');
show('alert', 'gn-popup-alert');
show('offer', 'gn-popup-offer');
show('app', 'gn-popup-app');
show('social', 'gn-popup-social');
show('survey', 'gn-popup-survey');
}
document.addEventListener('DOMContentLoaded', initPopups);