-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys.js
More file actions
144 lines (118 loc) · 5.24 KB
/
sys.js
File metadata and controls
144 lines (118 loc) · 5.24 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
137
138
139
140
141
142
143
144
document.addEventListener("DOMContentLoaded", function () {
const lightbox = document.getElementById("lightbox");
const lightboxImg = document.getElementById("lightbox-img");
const closeBtn = document.querySelector(".close");
const nextBtn = document.querySelector(".next");
const prevBtn = document.querySelector(".prev");
const dotsContainer = document.querySelector(".dots-container");
let images = []; // Store all image sources
let currentIndex = 0;
// Get all gallery images
document.querySelectorAll(".gallery-item").forEach((item, index) => {
images.push(item.getAttribute("data-src"));
// Create a dot for each image
const dot = document.createElement("span");
dot.classList.add("dot");
dot.dataset.index = index;
dotsContainer.appendChild(dot);
// Allow clicking dots to navigate
dot.addEventListener("click", function () {
currentIndex = parseInt(this.dataset.index);
updateLightbox();
});
// Open the lightbox when an image is clicked
item.addEventListener("click", function () {
currentIndex = index;
lightbox.style.display = "flex";
updateLightbox();
});
});
// Function to update lightbox image and dots
function updateLightbox() {
lightboxImg.src = images[currentIndex];
// Update active dot
document.querySelectorAll(".dot").forEach((dot, index) => {
dot.classList.toggle("active", index === currentIndex);
});
}
// Close the lightbox
closeBtn.addEventListener("click", function () {
lightbox.style.display = "none";
});
// Close when clicking outside the image
lightbox.addEventListener("click", function (event) {
if (event.target === lightbox) {
lightbox.style.display = "none";
}
});
// Show Next Image
nextBtn.addEventListener("click", function () {
currentIndex = (currentIndex + 1) % images.length; // Loop to first image if at the end
updateLightbox();
});
// Show Previous Image
prevBtn.addEventListener("click", function () {
currentIndex = (currentIndex - 1 + images.length) % images.length; // Loop to last image if at the beginning
updateLightbox();
});
});
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("form");
form.addEventListener("submit", function (event) {
const name = document.getElementById("name").value.trim();
const email = document.getElementById("email").value.trim();
const message = document.getElementById("message").value.trim();
if (name === "" || email === "" || message === "") {
alert("Please fill out all fields.");
event.preventDefault(); // Prevent form submission
}
});
});
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 () {
let heroSection = document.querySelector(".hero");
function updateHeroBackground() {
if (window.innerWidth < 768) {
heroSection.style.backgroundSize = "contain"; // Adjust for smaller screens
} else {
heroSection.style.backgroundSize = "cover";
}
}
window.addEventListener("resize", updateHeroBackground);
updateHeroBackground(); // Run on page load
});
document.addEventListener("DOMContentLoaded", function () {
const menuToggle = document.querySelector(".menu-toggle");
const navLinks = document.querySelector(".nav-links");
menuToggle.addEventListener("click", function () {
navLinks.classList.toggle("active");
});
});