-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
93 lines (77 loc) · 3.41 KB
/
scripts.js
File metadata and controls
93 lines (77 loc) · 3.41 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
document.addEventListener('DOMContentLoaded', function() {
// Word Change Functionality in Hero Section
const changingWords = ['Style', 'Elegance', 'Minimalism', 'Comfort'];
let currentWordIndex = 0;
const changingWordElement = document.getElementById('changing-word');
if (changingWordElement) {
function changeWord() {
changingWordElement.textContent = changingWords[currentWordIndex];
currentWordIndex = (currentWordIndex + 1) % changingWords.length;
}
setInterval(changeWord, 3000); // Change word every 3 seconds
}
// Carousel Functionality
const prevBtn = document.querySelector('.carousel-prev');
const nextBtn = document.querySelector('.carousel-next');
const uspContainer = document.querySelector('.usp-container');
const uspItems = document.querySelectorAll('.usp-item');
let index = 0;
function showSlide(n) {
if (n >= uspItems.length) index = 0;
if (n < 0) index = uspItems.length - 1;
uspContainer.style.transform = `translateX(${-index * 100}%)`;
}
if (nextBtn && prevBtn && uspContainer) {
nextBtn.addEventListener('click', () => {
index++;
showSlide(index);
});
prevBtn.addEventListener('click', () => {
index--;
showSlide(index);
});
setInterval(() => {
index++;
showSlide(index);
}, 5000); // Change slide every 5 seconds
}
// Form input spacing fix for Contact Us page
const contactInputs = document.querySelectorAll('.contact-form input, .contact-form textarea');
contactInputs.forEach(input => {
input.style.padding = '10px';
input.style.marginBottom = '15px';
input.style.border = '1px solid #ddd';
input.style.borderRadius = '4px';
input.style.boxSizing = 'border-box';
});
});
document.addEventListener('DOMContentLoaded', () => {
const form = document.querySelector('.contact-form');
const responseMessage = document.getElementById('response-message');
if (form) {
form.addEventListener('submit', async (event) => {
event.preventDefault(); // Prevent the default form submission
const formData = new FormData(form);
try {
const response = await fetch('/send-email', { // Replace with your server endpoint
method: 'POST',
body: formData
});
if (response.ok) {
// Show success message
responseMessage.textContent = 'Message sent successfully!';
responseMessage.style.color = 'green'; // Optionally style the message
form.reset(); // Reset form fields
} else {
// Handle server errors
responseMessage.textContent = 'Failed to send the message. Please try again.';
responseMessage.style.color = 'red'; // Optionally style the message
}
} catch (error) {
console.error('Error:', error);
responseMessage.textContent = 'Failed to send the message. Please try again.';
responseMessage.style.color = 'red'; // Optionally style the message
}
});
}
});