Created
September 21, 2023 00:46
-
-
Save Scofield-Idehen/1a7498fa5e4e247ff3f03a30a39e137f to your computer and use it in GitHub Desktop.
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
// Get references to page elements | |
const passwordModal = document.querySelector('.modal'); | |
const passwordInput = document.querySelector('.modal input'); | |
const unlockBtn = document.querySelector('.modal button'); | |
const notesSection = document.querySelector('.notes'); | |
// Open password modal | |
function openPasswordModal() { | |
passwordModal.style.display = 'flex'; | |
} | |
// Close password modal | |
function closePasswordModal() { | |
passwordModal.style.display = 'none'; | |
} | |
// Unlock notes | |
function unlockNotes(password) { | |
// Validate password | |
if (password === 'secret') { | |
notesSection.style.filter = 'blur(0px)'; | |
} else { | |
alert('Incorrect password'); | |
} | |
} | |
// Check password when modal is opened | |
openPasswordModal(); | |
// Submit password | |
unlockBtn.addEventListener('click', () => { | |
unlockNotes(passwordInput.value); | |
closePasswordModal(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment