-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
357 lines (236 loc) · 8.24 KB
/
script.js
File metadata and controls
357 lines (236 loc) · 8.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
//TESTIMONIAL
const users = document.querySelectorAll(".testimonial .user");
const dots = document.querySelectorAll(".testimonial .dots span");
const prevBtn = document.getElementById("prevBtn");
const nextBtn = document.getElementById("nextBtn");
let currentIndex = 0;
let autoSlideInterval;
function showUser(index) {
users.forEach((user, i) => {
if (i === index) {
user.classList.add("active");
user.style.animation = "none";
void user.offsetWidth;
user.style.animation = "fadeIn 0.6s ease forwards";
} else {
user.classList.remove("active");
}
});
dots.forEach((dot, i) => {
dot.classList.toggle("active", i === index);
});
}
function nextUser() {
currentIndex = (currentIndex + 1) % users.length;
showUser(currentIndex);
resetAutoSlide();
}
function prevUser() {
currentIndex = (currentIndex - 1 + users.length) % users.length;
showUser(currentIndex);
resetAutoSlide();
}
function startAutoSlide() {
autoSlideInterval = setInterval(() => {
nextUser();
}, 5000);
}
function resetAutoSlide() {
clearInterval(autoSlideInterval);
startAutoSlide();
}
nextBtn.addEventListener("click", nextUser);
prevBtn.addEventListener("click", prevUser);
showUser(currentIndex);
startAutoSlide();
// MAP
const bounds = [
[-90, -180],
[90, 180]
];
const map = L.map("real-map", {
center: [20, 0],
zoom: 1.8,
scrollWheelZoom: false,
doubleClickZoom: false,
dragging: true,
zoomControl: true,
maxBounds: bounds,
maxBoundsViscosity: 1.0,
worldCopyJump: false,
maxZoom: 32,
minZoom: 2.8
});
L.tileLayer(
"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
{
attribution:
"Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye",
maxZoom: 18,
noWrap: true
}
).addTo(map);
const locations = [
{ name: "Machu Picchu, Peru", coords: [-13.1631, -72.545] },
{ name: "Sydney Opera House, Australia", coords: [-33.8568, 151.2153] },
{ name: "Mount Kilimanjaro, Tanzania", coords: [-3.3731, 36.686] },
{ name: "Queenstown, New Zealand", coords: [-45.0312, 168.6626] },
{ name: "Matterhorn, Switzerland", coords: [46.0207, 7.7491] },
{ name: "Wat Phra Kaew, Thailand", coords: [13.4125, 103.8667] },
{ name: "CN Tower, Canada", coords: [43.6426, -79.3871] },
{ name: "Golden Circle, Iceland", coords: [64.9631, -19.0208] },
{ name: "Everest Base Camp, Nepal", coords: [27.9881, 86.925] },
{ name: "Table Mountain, South Africa", coords: [-33.9249, 18.4241] },
];
locations.forEach(loc => {
L.marker(loc.coords).addTo(map).bindPopup(loc.name);
});
// function findAdventure() {
// alert("Finding adventure near you...");
// }
function findAdventure() {
const selected = document.getElementById("country").value;
const modal = document.getElementById("adventureModal");
const modalText = modal.querySelector("p");
if (!selected) {
modalText.innerHTML = "⚠️ Please select a Country.";
modal.style.display = "block";
setTimeout(() => {
modal.style.display = "none";
}, 2500);
return;
}
modalText.innerHTML = "🌍 Finding adventure near you...";
modal.style.display = "block";
setTimeout(() => {
modal.style.display = "none";
const coordsMap = {
peru: [-13.1631, -72.545], // Machu Picchu
australia: [-33.8568, 151.2153], // Sydney Opera House
tanzania: [-3.3731, 36.686], // Mount Kilimanjaro
newzealand: [-45.0312, 168.6626], // Queenstown
switzerland: [46.0207, 7.7491], // Matterhorn
thailand: [13.4125, 103.8667], // Wat Phra Kaew (Bangkok)
canada: [43.6426, -79.3871], // CN Tower (Toronto)
iceland: [64.9631, -19.0208], // Golden Circle
nepal: [27.9881, 86.925], // Mount Everest Base Camp
southafrica: [-33.9249, 18.4241], // Table Mountain (Cape Town)
};
const destination = coordsMap[selected];
if (destination) {
map.flyTo(destination, 16);
}
}, 3000);
}
function closeModal() {
document.getElementById("adventureModal").style.display = "none";
}
// HEADER DROPDOWN
document.querySelectorAll('.arrow-icon').forEach(icon => {
icon.addEventListener('click', function (e) {
e.stopPropagation();
const parent = this.closest('.has-dropdown');
const dropdown = parent.querySelector('.dropdown');
document.querySelectorAll('.dropdown').forEach(menu => {
if (menu !== dropdown) menu.classList.remove('show');
});
dropdown.classList.toggle('show');
this.classList.toggle('rotate');
});
});
document.addEventListener('click', function () {
document.querySelectorAll('.dropdown').forEach(menu => {
menu.classList.remove('show');
});
document.querySelectorAll('.arrow-icon').forEach(icon => {
icon.classList.remove('rotate');
});
});
// HERO SELECT RANGE
const rangeInput = document.getElementById('price-range');
const rangeValue = document.getElementById('range-value');
rangeInput.addEventListener('input', () => {
rangeValue.textContent = `$${rangeInput.value}`;
});
const rangeInput2 = document.getElementById("price-range-2");
const rangeValue2 = document.getElementById("range-value-2");
rangeInput2.addEventListener("input", () => {
rangeValue2.textContent = `$${rangeInput2.value}`;
});
// Step Further Slider
const sliderContainer = document.querySelector('.step-further');
const articleTrack = sliderContainer.querySelector('.explore-articles');
const articleItems = sliderContainer.querySelectorAll('.article');
const articleNext = sliderContainer.querySelector('#article-next');
const articlePrev = sliderContainer.querySelector('#article-prev');
const articleDots = sliderContainer.querySelectorAll('.article-dot');
function getVisibleCount() {
if (window.innerWidth <= 440) return 1;
if (window.innerWidth <= 767) return 2;
if (window.innerWidth <= 991) return 3;
return 3.5;
}
let index = 0;
const totalArticles = articleItems.length;
function updateArticleView() {
const visibleCount = getVisibleCount();
const itemWidth = articleItems[0].offsetWidth;
const maxIndex = Math.ceil(totalArticles - visibleCount);
let shift = index * itemWidth;
if (index === maxIndex && visibleCount === 3.5) {
shift = (totalArticles - visibleCount) * itemWidth;
}
articleTrack.style.transform = `translateX(-${shift}px)`;
articleDots.forEach((dot, i) => {
dot.classList.toggle('active', i === index);
});
articlePrev.disabled = index === 0;
articleNext.disabled = index >= maxIndex;
}
articleNext.addEventListener('click', () => {
const visibleCount = getVisibleCount();
const maxIndex = Math.ceil(totalArticles - visibleCount);
if (index < maxIndex) {
index++;
updateArticleView();
}
});
articlePrev.addEventListener('click', () => {
if (index > 0) {
index--;
updateArticleView();
}
});
articleDots.forEach((dot, i) => {
dot.addEventListener('click', () => {
const visibleCount = getVisibleCount();
const maxIndex = Math.ceil(totalArticles - visibleCount);
if (i <= maxIndex) {
index = i;
updateArticleView();
}
});
});
window.addEventListener('resize', () => {
updateArticleView();
});
updateArticleView();
// Sidebar Toggle
const hamburger = document.querySelector(".hamburger");
const sidebar = document.querySelector(".sidebar");
const closeSidebar = document.querySelector(".close-sidebar");
const sidebarLinks = document.querySelectorAll(".sidebar a");
hamburger.addEventListener("click", () => {
sidebar.classList.add("active");
document.body.classList.add("sidebar-active");
});
closeSidebar.addEventListener("click", () => {
sidebar.classList.remove("active");
document.body.classList.remove("sidebar-active");
});
sidebarLinks.forEach((link) => {
link.addEventListener("click", () => {
sidebar.classList.remove("active");
document.body.classList.remove("sidebar-active");
});
});