forked from anuragverma108/SwapReads
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making newsletter and vote popup appear only once per session
- Loading branch information
1 parent
32cae55
commit cf5f363
Showing
2 changed files
with
98 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
// Show the pop-up automatically when the page loads | ||
window.onload = function() { | ||
if (!sessionStorage.getItem('popupDisplayed')) { | ||
document.getElementById('popup-nl').style.display = 'flex'; | ||
sessionStorage.setItem('popupDisplayed', 'true'); | ||
window.onload = function () { | ||
if (!sessionStorage.getItem("popupDisplayed")) { | ||
document.getElementById("popup-nl").style.display = "flex"; | ||
sessionStorage.setItem("popupDisplayed", "true"); // Set flag to indicate popup has been shown | ||
} | ||
}; | ||
|
||
// Close the pop-up when the user clicks the close button | ||
document.querySelector('.close-nl').addEventListener('click', function() { | ||
document.getElementById('popup-nl').style.display = 'none'; | ||
document.querySelector(".close-nl").addEventListener("click", function () { | ||
document.getElementById("popup-nl").style.display = "none"; | ||
}); | ||
|
||
// // Close the pop-up when clicking outside the pop-up content | ||
// window.addEventListener('click', function(event) { | ||
// const popupContent = document.querySelector('.popup-content'); // Select the popup content | ||
// if (event.target === document.getElementById('popup')) { | ||
// document.getElementById('popup').style.display = 'none'; | ||
// } | ||
// }); | ||
// Close the pop-up when clicking outside the pop-up content | ||
window.addEventListener("click", function (event) { | ||
const popupContent = document.querySelector(".popup-content"); // Select the popup content | ||
if ( | ||
event.target === document.getElementById("popup-nl") && | ||
!popupContent.contains(event.target) | ||
) { | ||
document.getElementById("popup-nl").style.display = "none"; | ||
} | ||
}); | ||
|
||
// Handle form submission | ||
document.getElementById('emailForm-nl').addEventListener('submit', function(event) { | ||
event.preventDefault(); | ||
document | ||
.getElementById("emailForm-nl") | ||
.addEventListener("submit", function (event) { | ||
event.preventDefault(); | ||
|
||
const email = document.getElementById('email-nl').value; | ||
if (email) { | ||
alert(`Your email ID ${email} has been registered successfully for the newsletter.`); | ||
document.getElementById('popup').style.display = 'none'; | ||
} | ||
}); | ||
const email = document.getElementById("email-nl").value; | ||
if (email) { | ||
alert( | ||
`Your email ID ${email} has been registered successfully for the newsletter.` | ||
); | ||
document.getElementById("popup-nl").style.display = "none"; // Close popup after successful submission | ||
} | ||
}); | ||
|
||
// Handle "No thanks" link | ||
document.querySelector('.no-thanks-nl').addEventListener('click', function(event) { | ||
event.preventDefault(); | ||
document.getElementById('popup-nl').style.display = 'none'; | ||
}); | ||
document | ||
.querySelector(".no-thanks-nl") | ||
.addEventListener("click", function (event) { | ||
event.preventDefault(); | ||
document.getElementById("popup-nl").style.display = "none"; | ||
}); |