Skip to content

Instantly share code, notes, and snippets.

@Scofield-Idehen
Created September 21, 2023 00:46
Show Gist options
  • Save Scofield-Idehen/1a7498fa5e4e247ff3f03a30a39e137f to your computer and use it in GitHub Desktop.
Save Scofield-Idehen/1a7498fa5e4e247ff3f03a30a39e137f to your computer and use it in GitHub Desktop.
// 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