forked from apu52/Travel_Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
131 lines (105 loc) · 4 KB
/
index.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
function sendMail() {
var params = {
name: document.getElementById("exampleInputName").value,
email: document.getElementById("exampleInputEmail2").value,
message: document.getElementById("exampleInputMessage").value,
};
const serviceID = "service_hi7jvka";
const templateID = "template_2mu6atu";
emailjs.send(serviceID, templateID, params)
.then(res=>{
document.getElementById("exampleInputName").value = "";
document.getElementById("exampleInputEmail2").value = "";
document.getElementById("exampleInputMessage").value = "";
console.log(res);
alert("Your message sent successfully!!")
})
.catch(err=>console.log(err));
}
// Modal JS
const modalContainer = document.querySelector(".modal-container");
const closeBtn = document.querySelector("#close-btn");
const subscribeBtn = document.querySelector("#news-subscribe");
const form = document.querySelector("#modal-form");
function openModal() {
modalContainer.style.display = "flex";
}
function closeModal() {
modalContainer.style.display = "none";
}
// Function to handle form submission (you can customize this)
function subscribe(e) {
e.preventDefault();
const emailInput = document.querySelector("#modal-email").value;
// You can add your logic to handle the form submission here
// alert("Email subscribed: "+emailInput);
closeModal();
}
form.addEventListener("submit", subscribe)
// closeBtn.addEventListener("click", closeModal);
// Open the modal as soon as the page loads
window.onload = openModal();
// carousel JS
const slideDots = document.querySelectorAll(".imageDots span");
const slides = document.querySelectorAll(".mySlides");
let activeSlide = 0;
const destinationTitles = [
"Eiffel Tower",
"Giant Wheel",
"Goa Beach",
"Male Beach",
];
const destinationSubtitles = ["Paris", "London", "Goa", "Maldives"];
slideDots.forEach((dot, index) => {
dot.addEventListener("click", () => {
pullSlide(null, index);
});
});
function pullSlide(relativeNum, absoluteNum) {
if (typeof relativeNum === "number") {
activeSlide = (activeSlide + relativeNum) % 4;
if (activeSlide < 0) activeSlide = slides.length + activeSlide;
} else if (typeof absoluteNum === "number") {
activeSlide = absoluteNum;
}
const title = destinationTitles[activeSlide];
const subtitle = destinationSubtitles[activeSlide];
slides.forEach((slide) => {
// Check if destination__details already exists, if not, create it
let detailsContainer = slide.querySelector(".destination__details");
if (!detailsContainer) {
detailsContainer = document.createElement("div");
detailsContainer.className = "destination__details";
slide.appendChild(detailsContainer);
}
// Check if destination__title already exists, if not, create it
let titleElement = detailsContainer.querySelector(".destination__title");
if (!titleElement) {
titleElement = document.createElement("p");
titleElement.className = "destination__title";
detailsContainer.appendChild(titleElement);
}
titleElement.textContent = title;
// Check if destination__subtitle already exists, if not, create it
let subtitleElement = detailsContainer.querySelector(".destination__subtitle");
if (!subtitleElement) {
subtitleElement = document.createElement("p");
subtitleElement.className = "destination__subtitle";
detailsContainer.appendChild(subtitleElement);
}
subtitleElement.textContent = subtitle;
});
slides[0].style.marginLeft = `${-activeSlide * 100}%`;
slideDots.forEach((dot) => {
dot.classList.remove("active");
});
slideDots[activeSlide].classList.add("active");
}
// Initial details rendering
pullSlide(0);
document.getElementById('emailInput').addEventListener('focus', function() {
document.getElementById('send').classList.add('focused');
});
document.getElementById('emailInput').addEventListener('blur', function() {
document.getElementById('send').classList.remove('focused');
});