-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelhi.js
More file actions
136 lines (114 loc) · 4.78 KB
/
delhi.js
File metadata and controls
136 lines (114 loc) · 4.78 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
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
document.addEventListener("DOMContentLoaded", function () {
const lightbox = document.getElementById("lightbox");
const lightboxImg = document.getElementById("lightbox-img");
const closeBtn = document.querySelector(".close");
const prevBtn = document.querySelector(".prev");
const nextBtn = document.querySelector(".next");
const dotsContainer = document.querySelector(".dots-container");
const galleryImages = document.querySelectorAll(".gallery-container img");
let currentIndex = 0;
// Function to open the lightbox
function openLightbox(index) {
currentIndex = index;
lightbox.style.display = "flex";
lightboxImg.src = galleryImages[currentIndex].getAttribute("src");
updateDots();
}
// Add event listener to all gallery images
galleryImages.forEach((img, index) => {
img.addEventListener("click", () => {
openLightbox(index);
});
});
// Function to close the lightbox
closeBtn.addEventListener("click", () => {
lightbox.style.display = "none";
});
// Function to navigate next
nextBtn.addEventListener("click", () => {
currentIndex = (currentIndex + 1) % galleryImages.length;
openLightbox(currentIndex);
});
// Function to navigate previous
prevBtn.addEventListener("click", () => {
currentIndex = (currentIndex - 1 + galleryImages.length) % galleryImages.length;
openLightbox(currentIndex);
});
// Close lightbox when clicking outside the image
lightbox.addEventListener("click", (event) => {
if (event.target === lightbox) {
lightbox.style.display = "none";
}
});
// Create dots for each image
function createDots() {
dotsContainer.innerHTML = "";
galleryImages.forEach((_, index) => {
let dot = document.createElement("span");
dot.classList.add("dot");
if (index === currentIndex) {
dot.classList.add("active");
}
dot.addEventListener("click", () => {
openLightbox(index);
});
dotsContainer.appendChild(dot);
});
}
// Function to update dot indicators
function updateDots() {
let dots = document.querySelectorAll(".dot");
dots.forEach((dot, index) => {
dot.classList.toggle("active", index === currentIndex);
});
}
// Initialize dots on page load
createDots();
});
document.addEventListener("DOMContentLoaded", function () {
let slides = ["res1.jpg", "res2.jpg", "res3.jpg"]; // Image List
let currentIndex = 0; // Start with first image
let heroSection = document.querySelector(".hero");
// Initial Background
heroSection.style.background = `url('${slides[currentIndex]}') center/cover no-repeat`;
// Function to change background automatically
function changeBackground(next = true) {
if (next) {
currentIndex = (currentIndex + 1) % slides.length; // Move Forward
} else {
currentIndex = (currentIndex - 1 + slides.length) % slides.length; // Move Backward
}
heroSection.style.background = `url('${slides[currentIndex]}') center/cover no-repeat`;
}
// Automatic Background Change Every 5 Secs
let interval = setInterval(() => changeBackground(true), 5000);
// Event Listeners for Buttons
document.querySelector(".prev-btn").addEventListener("click", function () {
clearInterval(interval); // Stop auto transition when clicked
changeBackground(false);
interval = setInterval(() => changeBackground(true), 5000); // Restart interval
});
document.querySelector(".next-btn").addEventListener("click", function () {
clearInterval(interval); // Stop auto transition when clicked
changeBackground(true);
interval = setInterval(() => changeBackground(true), 5000); // Restart interval
});
});
document.addEventListener("DOMContentLoaded", function () {
const menuLink = document.getElementById("menu-link");
const lightbox = document.getElementById("pdf-lightbox");
const closeBtn = document.querySelector(".close-btn");
menuLink.addEventListener("click", function (event) {
event.preventDefault(); // Prevent default link behavior
lightbox.style.display = "flex";
});
closeBtn.addEventListener("click", function () {
lightbox.style.display = "none";
});
// Close lightbox when clicking outside of it
lightbox.addEventListener("click", function (event) {
if (event.target === lightbox) {
lightbox.style.display = "none";
}
});
});