-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript1.js
More file actions
43 lines (34 loc) · 1.28 KB
/
script1.js
File metadata and controls
43 lines (34 loc) · 1.28 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
let currentSlide = 0;
const totalSlides = document.querySelectorAll("#carousel > div").length;
function showSlide() {
const carousel = document.getElementById('carousel');
carousel.style.transform = `translateX(-${currentSlide * 100}%)`;
}
function next() {
currentSlide = (currentSlide + 1) % totalSlides;
showSlide();
}
function prev() {
currentSlide = (currentSlide - 1 + totalSlides) % totalSlides;
showSlide();
}
function logout() {
localStorage.removeItem('loggedIn');
window.location.href = 'login.html';
}
document.addEventListener('DOMContentLoaded', function () {
if (!localStorage.getItem('loggedIn')) {
window.location.href = 'login.html';
}
const navbar = document.getElementById('navbar');
const logoutBtn = document.createElement('button');
logoutBtn.textContent = 'Logout';
logoutBtn.className = 'hover:text-green-600';
logoutBtn.onclick = logout;
navbar.appendChild(logoutBtn);
const mobileLogout = document.getElementById('mobileLogout');
if (mobileLogout) {
mobileLogout.classList.remove('hidden');
mobileLogout.onclick = logout;
}
});