-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
46 lines (37 loc) · 1.55 KB
/
scripts.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
$(document).ready(function() {
// Image carousel functionality
let currentSlide = 0;
const slides = $('.image-carousel img');
const slideCount = slides.length;
function showSlide(index) {
slides.hide();
slides.eq(index).fadeIn();
}
function nextSlide() {
currentSlide = (currentSlide + 1) % slideCount;
showSlide(currentSlide);
}
function prevSlide() {
currentSlide = (currentSlide - 1 + slideCount) % slideCount;
showSlide(currentSlide);
}
// Initialize carousel
showSlide(0);
setInterval(nextSlide, 5000); // Auto-advance every 5 seconds
// Availability form submission
$('#availability-form').submit(function(e) {
e.preventDefault();
// Gather form data
const name = $('input[name="name"]').val();
const dateFrom = $('input[name="dateFrom"]').val();
const dateTo = $('input[name="dateTo"]').val();
const guests = $('input[name="guests"]').val();
const comments = $('textarea[name="comments"]').val();
// Construct WhatsApp message
const message = `Hola, me interesa La Casita.\nNombre: ${name}\nDesde: ${dateFrom}\nHasta: ${dateTo}\nHuéspedes: ${guests}\nComentarios: ${comments}`;
// Encode the message for URL
const encodedMessage = encodeURIComponent(message);
// Open WhatsApp with the pre-filled message
window.open(`https://wa.me/5491131741969?text=${encodedMessage}`, '_blank');
});
});