diff --git a/episodes/files/additional.js b/episodes/files/additional.js index dfb4d0ac5..0166ff330 100644 --- a/episodes/files/additional.js +++ b/episodes/files/additional.js @@ -1,9 +1,11 @@ console.log("JS loaded") - window.onload = function() { console.log("Running function") const dropdownButton = document.getElementById('dropdownMenu1'); + const ddparent = document.getElementById('instructor-dropdown'); dropdownButton.disabled = true; + const correctPassword = "D&DPython"; // Set your hardcoded password here + let isPasswordCorrect = false; console.log("FOOOOO") console.log(dropdownButton) @@ -14,4 +16,17 @@ window.onload = function() { button.style.opacity = '0.5'; }); } + ddparent.addEventListener('click', function(event) { + if (!isPasswordCorrect) { // Only prompt for password if not correct yet + const password = prompt("Please enter the password:"); + + if (password === correctPassword) { + isPasswordCorrect = true; + dropdownButton.disabled = false; + dropdownButton.click(); // Manually trigger the click after unlocking + } else { + alert("Incorrect password."); + } + } + }); };