-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
146 lines (122 loc) · 4.36 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
window.addEventListener('resize', function () {
addRequiredClass();
})
function addRequiredClass() {
if (window.innerWidth < 860) {
document.body.classList.add('mobile')
} else {
document.body.classList.remove('mobile')
}
}
window.onload = addRequiredClass
//let hamburger = document.querySelector('.hamburger')
let mobileNav = document.querySelector('.nav-list')
let bars = document.querySelectorAll('.hamburger span')
let isActive = false
hamburger.addEventListener('click', function () {
mobileNav.classList.toggle('open')
if (!isActive) {
bars[0].style.transform = 'rotate(45deg)'
bars[1].style.opacity = '0'
bars[2].style.transform = 'rotate(-45deg)'
isActive = true
} else {
bars[0].style.transform = 'rotate(0deg)'
bars[1].style.opacity = '1'
bars[2].style.transform = 'rotate(0deg)'
isActive = false
}
})
// Simple visitor management system
// let visitors = [];
// let currentVisitors = 0;
// let todayTotal = 0;
// // DOM elements
// const visitorForm = document.getElementById('visitor-form');
// const visitorList = document.getElementById('visitor-list');
// const currentVisitorsEl = document.getElementById('current-visitors');
// const todayTotalEl = document.getElementById('today-total');
// const lockAllBtn = document.getElementById('lock-all');
// const unlockAllBtn = document.getElementById('unlock-all');
// const generateReportBtn = document.getElementById('generate-report');
// const reportOutput = document.getElementById('report-output');
// // Event listeners
// visitorForm.addEventListener('submit', checkInVisitor);
// lockAllBtn.addEventListener('click', lockAllDoors);
// unlockAllBtn.addEventListener('click', unlockAllDoors);
// generateReportBtn.addEventListener('click', generateReport);
// // Check-in visitor
// function checkInVisitor(e) {
// e.preventDefault();
// const name = document.getElementById('visitor-name').value;
// const email = document.getElementById('visitor-email').value;
// const purpose = document.getElementById('visitor-purpose').value;
// const visitor = {
// name,
// email,
// purpose,
// checkInTime: new Date()
// };
// visitors.push(visitor);
// currentVisitors++;
// todayTotal++;
// updateStats();
// displayVisitors();
// visitorForm.reset();
// }
// // Display visitors
// function displayVisitors() {
// visitorList.innerHTML = '';
// visitors.forEach((visitor, index) => {
// const visitorEl = document.createElement('div');
// visitorEl.classList.add('visitor-item');
// visitorEl.innerHTML = `
// <h3>${visitor.name}</h3>
// <p>Email: ${visitor.email}</p>
// <p>Purpose: ${visitor.purpose}</p>
// <p>Check-in Time: ${visitor.checkInTime.toLocaleString()}</p>
// <button onclick="checkOutVisitor(${index})">Check-Out</button>
// `;
// visitorList.appendChild(visitorEl);
// });
// }
// // Check-out visitor
// function checkOutVisitor(index) {
// visitors.splice(index, 1);
// currentVisitors--;
// updateStats();
// displayVisitors();
// }
// // Update stats
// function updateStats() {
// currentVisitorsEl.textContent = currentVisitors;
// todayTotalEl.textContent = todayTotal;
// }
// // Lock all doors (simulated)
// function lockAllDoors() {
// alert('All doors have been locked.');
// }
// // Unlock all doors (simulated)
// function unlockAllDoors() {
// alert('All doors have been unlocked.');
// }
// // Generate simple report
// function generateReport() {
// const report = `
// <h3>Visitor Report</h3>
// <p>Current Visitors: ${currentVisitors}</p>
// <p>Today's Total: ${todayTotal}</p>
// <h4>Visitor List:</h4>
// <ul>
// ${visitors.map(visitor => `<li>${visitor.name} - ${visitor.purpose}</li>`).join('')}
// </ul>
// `;
// reportOutput.innerHTML = report;
// }
// // Initial display
// updateStats();
const hamburger = document.querySelector('.hamburger');
const navList = document.querySelector('.nav-list');
hamburger.addEventListener('click', () => {
navList.classList.toggle('open');
});