Spaces:
Sleeping
Sleeping
File size: 2,624 Bytes
1cb3976 26b6333 1cb3976 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Modal</title>
<link rel="stylesheet" href="static/popups.css">
</head>
<body>
<!-- Popup Modal HTML Structure -->
<div id="mpopupBoxpassword" class="mpopuppassword">
<!-- Modal content -->
<div class="modal-contentpassword">
<div class="modal-bodypassword" id="modal-bodyTextpassword">
<p id='enterPText'>Enter Password to access ADR Console.</p>
<input type="password" id="passwordField" placeholder="Enter Password" style="display: block; margin: 10px 0;">
<button id="submitBtn">Submit</button>
</div>
</div>
</div>
<div id="errorMessage" class="error-message" style="display: none;">Error Validating. Please Refresh and Try Again.</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
// Show the modal on page load
document.getElementById('mpopupBoxpassword').style.display = "flex";
// Event listener for the submit button
document.getElementById('submitBtn').onclick = function() {
validatePassword();
};
function validatePassword() {
var enteredPassword = document.getElementById("passwordField").value;
// Send the entered password to the Flask backend for validation
$.ajax({
url: '/check_password', // Flask route for password validation
type: 'POST',
data: {
password: enteredPassword // Send entered password as form data
},
success: function(response) {
if (response.authenticated) {
console.log('Correct Password');
document.getElementById('mpopupBoxpassword').style.display = "none"; // Hide modal on success
window.location.href = "/mainGUI"; // Redirect to the main GUI page
} else {
document.getElementById("passwordField").style.boxShadow = '0 0 8px 2px rgb(255, 0, 0)';
}
},
error: function(jqXHR, textStatus, errorThrown) {
// Show error message if validation fails
document.getElementById('errorMessage').style.display = "block"; // Show error message
}
});
}
</script>
</body>
</html>
|