-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
81 lines (67 loc) · 2.47 KB
/
script.js
File metadata and controls
81 lines (67 loc) · 2.47 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
document.addEventListener('DOMContentLoaded', function() {
// Slider functionality
const sliderDots = document.querySelectorAll('.slider-dot');
const sliderCards = document.querySelectorAll('.recommendation-card');
let currentSlide = 0;
// Initialize slider
function initSlider() {
// Hide all slides except the first one
sliderCards.forEach((card, index) => {
if (index !== 0) {
card.style.display = 'none';
}
});
// Add click event to dots
sliderDots.forEach((dot, index) => {
dot.addEventListener('click', () => {
showSlide(index);
});
});
}
// Show specific slide
function showSlide(index) {
// Hide current slide
sliderCards[currentSlide].style.display = 'none';
sliderDots[currentSlide].classList.remove('active');
// Show new slide
sliderCards[index].style.display = 'block';
sliderDots[index].classList.add('active');
// Update current slide
currentSlide = index;
}
// Auto slide functionality
function autoSlide() {
let nextSlide = (currentSlide + 1) % sliderCards.length;
showSlide(nextSlide);
}
// Initialize slider
initSlider();
// Set auto slide interval
setInterval(autoSlide, 5000);
// Form validation
const contactForm = document.querySelector('.contact-form form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
const nameInput = document.getElementById('name');
const emailInput = document.getElementById('email');
const messageInput = document.getElementById('message');
// Simple validation
if (nameInput.value.trim() === '') {
alert('Please enter your name');
return;
}
if (emailInput.value.trim() === '') {
alert('Please enter your email');
return;
}
if (messageInput.value.trim() === '') {
alert('Please enter your message');
return;
}
// If validation passes, you would normally submit the form
alert('Form submitted successfully!');
contactForm.reset();
});
}
});