-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
73 lines (64 loc) · 2.59 KB
/
script.js
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
// JavaScript to dynamically update the footer text with the current year
document.addEventListener("DOMContentLoaded", (event) => {
const footerText = document.createElement("footer p");
footerText.textContent =
"© " + new Date().getFullYear() + " Saleh Omer Ali Alkarabubi";
document.body.appendChild(footerText);
});
// Change link colors when clicked
document.querySelectorAll(".nav-links a").forEach((link) => {
link.addEventListener("click", function () {
this.style.color = "#ff4500"; // Change to your preferred color
});
});
// Change footer text dynamically
const footerText = document.querySelector("footer p");
footerText.textContent =
"© " + new Date().getFullYear() + " Saleh Omer Ali Alkarabubi";
document.addEventListener("DOMContentLoaded", function () {
const loginLink = document.getElementById("loginLink");
const loginFormContainer = document.getElementById("loginFormContainer");
const loginForm = document.getElementById("loginForm");
const messageDisplay = document.getElementById("messageDisplay");
let loginAttempts = 0;
loginLink.addEventListener("click", function (event) {
event.preventDefault();
loginFormContainer.style.display = "block";
// Reset username and password fields
document.getElementById("username").value = "";
document.getElementById("password").value = "";
});
loginForm.addEventListener("submit", function (event) {
event.preventDefault();
const username = document.getElementById("username").value;
const password = document.getElementById("password").value;
// Replace with your authentication logic
if (username === "admin" && password === "123") {
// Successful login
messageDisplay.textContent =
"Login successful! Redirecting to Photos page...";
messageDisplay.style.display = "block";
setTimeout(function () {
window.location.href = "photos.html";
}, 3000); // Redirect after 3 seconds
} else {
// Failed login attempt
loginAttempts++;
if (loginAttempts >= 3) {
messageDisplay.textContent =
"Login attempts exceeded. Redirecting to Contact page...";
messageDisplay.style.display = "block";
setTimeout(function () {
window.location.href = "contactAdmin.html?loginFailed=true";
}, 3000); // Redirect after 3 seconds
} else {
messageDisplay.textContent = `Incorrect username or password. Attempts left: ${
3 - loginAttempts
}`;
messageDisplay.style.display = "block";
}
}
// Clear form fields
loginForm.reset();
});
});