-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
66 lines (59 loc) · 2.31 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
// Existing modal functionality code
document.getElementById('login-link').addEventListener('click', function() {
document.getElementById('login-selection').classList.add('active');
});
// Close modal when clicking outside the form
window.addEventListener('click', function(event) {
const activeModal = document.querySelector('.modal.active');
if (activeModal && !event.target.closest('.login-container') && !event.target.closest('#login-link')) {
activeModal.classList.remove('active');
}
});
function selectLevel(level) {
document.getElementById('login-selection').classList.remove('active');
if (level === 'driver') {
document.getElementById('driver-login').classList.add('active');
} else if (level === 'authority') {
document.getElementById('authority-login').classList.add('active');
}
}
function closeModal() {
document.querySelectorAll('.modal').forEach(modal => {
modal.classList.remove('active');
});
}
// Function to open Sign-Up form
function openSignUp() {
closeModal(); // Close other modals
document.getElementById('signup').classList.add('active');
}
// Function to clear forms on submit and simulate login/signup
function handleFormSubmission(formId) {
const form = document.getElementById(formId);
form.addEventListener('submit', (event) => {
event.preventDefault(); // Prevent default form submission
form.reset(); // Reset the form fields
window.location.href = 'driver.html'; // Redirect to driver.html
});
}
// Attach form submission handlers
document.addEventListener('DOMContentLoaded', () => {
handleFormSubmission('driver-login-form');
handleFormSubmission('authority-login-form');
handleFormSubmission('signup-form');
});
document.addEventListener("DOMContentLoaded", function () {
let lastScrollTop = 0;
const navbar = document.querySelector('.navbar');
window.addEventListener("scroll", function () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if (scrollTop > lastScrollTop) {
// Scrolling down
navbar.style.top = "-100px"; // Adjust this value based on the navbar height
} else {
// Scrolling up
navbar.style.top = "0";
}
lastScrollTop = scrollTop;
});
});