-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
57 lines (48 loc) · 1.5 KB
/
scripts.js
File metadata and controls
57 lines (48 loc) · 1.5 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
const heroBg = document.querySelector('.hero-bg');
const dots = document.querySelectorAll('.dot');
const images = ['img/hero1.jpg', 'img/hero2.jpg', 'img/hero3.jpg'];
let idx = 0;
function updateSlide() {
heroBg.style.backgroundImage = `url('${images[idx]}')`;
dots.forEach(dot => dot.classList.remove('active'));
dots[idx].classList.add('active');
}
dots.forEach((dot, i) => {
dot.onclick = () => {
idx = i;
updateSlide();
resetTimer();
};
});
let timer = setInterval(nextSlide, 5000);
function nextSlide() {
idx = (idx + 1) % images.length;
updateSlide();
}
function resetTimer() {
clearInterval(timer);
timer = setInterval(nextSlide, 5000);
}
updateSlide();
// Testimonials
let tIndex = 0;
const slides = document.querySelectorAll('#testimonial-slider .slide');
setInterval(() => {
slides[tIndex].classList.remove('active');
tIndex = (tIndex + 1) % slides.length;
slides[tIndex].classList.add('active');
}, 5000);
// Leaflet map
var map = L.map('mapid').setView([0, 20], 2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OSM contributors'
}).addTo(map);
[
{ lat: 13.0827, lng: 80.2707, label: 'Chennai, India' },
{ lat: 0.3476, lng: 32.5825, label: 'Kampala, Uganda' },
{ lat: 6.5244, lng: 3.3792, label: 'Lagos, Nigeria' },
{ lat: 18.7357, lng: -70.1627, label: 'Dominican Republic' },
{ lat: -1.2921, lng: 36.8219, label: 'Nairobi, Kenya' }
].forEach(({lat, lng, label}) =>
L.marker([lat, lng]).addTo(map).bindPopup(label)
);