-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpassword.html
More file actions
97 lines (83 loc) · 3.27 KB
/
password.html
File metadata and controls
97 lines (83 loc) · 3.27 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rival Proxy - Enter your Password</title>
<!-- Your existing CSS and JavaScript imports -->
</head>
<body onload="checkPassword()">
<h1>Settings</h1>
<!-- Your existing HTML content -->
<script>
// Function to check password on page load
function checkPassword() {
const passwordEnabled = localStorage.getItem("passwordEnabled") === "true";
const passwordVerified = localStorage.getItem("passwordVerified") === "true";
if (passwordEnabled && !passwordVerified) {
window.location.href = "password.html";
}
}
// Function to toggle password setup based on checkbox
function togglePasswordSetup() {
const passwordSetupDiv = document.getElementById("passwordSetup");
const passwordEnableCheckbox = document.getElementById("passwordEnableCheckbox");
if (passwordEnableCheckbox.checked) {
passwordSetupDiv.style.display = "block";
localStorage.setItem("passwordEnabled", true);
} else {
passwordSetupDiv.style.display = "none";
localStorage.setItem("passwordEnabled", false);
}
}
// Function to handle Enter key press in password field
document.getElementById("passwordField").addEventListener("keypress", function(event) {
if (event.key === "Enter") {
setPassword();
}
});
// Function to set the password
function setPassword() {
const passwordField = document.getElementById("passwordField");
const password = passwordField.value;
if (password) {
localStorage.setItem("password", password);
localStorage.setItem("passwordVerified", true);
alert("Password set successfully!");
}
}
// Function to handle inactive tab timeout
const TIMEOUT_DURATION = 5 * 60 * 1000; // 5 minutes in milliseconds
let timeoutId;
function startInactiveTimeout() {
timeoutId = setTimeout(redirectToPasswordPage, TIMEOUT_DURATION);
}
function resetInactiveTimeout() {
clearTimeout(timeoutId);
startInactiveTimeout();
}
function redirectToPasswordPage() {
const passwordEnabled = localStorage.getItem("passwordEnabled") === "true";
const passwordVerified = localStorage.getItem("passwordVerified") === "true";
if (passwordEnabled && !passwordVerified) {
window.location.href = "password.html";
}
}
// Start inactive tab timeout on page load
startInactiveTimeout();
// Reset timeout whenever there's user interaction
document.addEventListener("mousemove", resetInactiveTimeout);
document.addEventListener("keydown", resetInactiveTimeout);
window.addEventListener("focus", resetInactiveTimeout);
// Function to handle password verification on tab close and reopen
window.addEventListener("beforeunload", function (e) {
const passwordEnabled = localStorage.getItem("passwordEnabled") === "true";
const passwordVerified = localStorage.getItem("passwordVerified") === "true";
if (passwordEnabled && !passwordVerified) {
const confirmationMessage = "You have unsaved changes. Are you sure you want to leave?";
e.returnValue = confirmationMessage;
return confirmationMessage;
}
});
</script>
</body>
</html>