-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscript.js
73 lines (60 loc) · 2.5 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
let currentSlide = 0;
function showSlide(index) {
const slides = document.querySelectorAll('.destination-card');
if (index >= slides.length) {
currentSlide = 0;
} else if (index < 0) {
currentSlide = slides.length - 1;
} else {
currentSlide = index;
}
const offset = -currentSlide * 100;
document.querySelector('.carousel-container').style.transform = `translateX(${offset}%)`;
slides.forEach((slide, i) => {
slide.classList.remove('active');
if (i === currentSlide) {
slide.classList.add('active');
}
});
}
function moveSlide(direction) {
showSlide(currentSlide + direction);
}
showSlide(currentSlide);
let testimonialsIndex = 0;
function moveTestimonials(direction) {
const items = document.querySelectorAll('.testimonial-item');
testimonialsIndex = (testimonialsIndex + direction + items.length) % items.length;
const offset = -testimonialsIndex * 100;
document.querySelector('.testimonials-container').style.transform = `translateX(${offset}%)`;
}
document.getElementById("bus-ticket-form").addEventListener("submit", function (e) {
e.preventDefault();
const departure = document.getElementById("departure").value.trim();
const arrival = document.getElementById("arrival").value.trim();
const travelDate = document.getElementById("travel-date").value.trim();
const tickets = document.getElementById("tickets").value.trim();
const busType = document.getElementById("bus-type").value;
if (!departure || !arrival || !travelDate || !tickets || !busType) {
alert("Please fill in all fields before booking.");
return;
}
alert(`Bus ticket successfully booked!\n\nDetails:\nDeparture: ${departure}\nArrival: ${arrival}\nDate: ${travelDate}\nTickets: ${tickets}\nBus Type: ${busType}`);
});
/* ============================ BACK TO TOP BUTTON ============================ */
const backToTopBtn = document.getElementById("backToTop");
window.addEventListener("scroll", () => {
if (window.scrollY > 300) {
backToTopBtn.classList.add("show");
} else {
backToTopBtn.classList.remove("show");
}
});
backToTopBtn.addEventListener("click", () => {
window.scrollTo({ top: 0, behavior: "smooth" });
});
/* ============================ CHAT BUTTON ============================ */
const chatButton = document.getElementById("chatButton");
chatButton.addEventListener("click", () => {
alert("Chat feature is under construction. Coming soon!");
});