<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container-P11 {
max-width: 100%;
text-align: center;
margin: 0;
margin-left: 10px;
margin-top: 0px;
margin-bottom: -50px;
}
.container-P11 h1 {
font-size: 30px;
color: #000;
margin-bottom: 10px;
display: inline-block;
padding-bottom: 10px;
font-family: 'Monotype Corsiva', sans-serif;
}
.product-P11 {
flex: 0 0 23%;
background-color: #fff;
border: 2px solid #ccc;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
border-radius: 8px;
overflow: hidden;
text-align: center;
display: flex;
cursor: pointer;
flex-direction: column;
align-items: center;
justify-content: space-between;
transition: transform 0.3s ease;
}
.product-P11 h3 {
font-size: 16px;
margin-top: -10px;
color: #000;
font-weight: bold;
}
.product-P11 p {
font-size: 16px;
padding: 5px;
margin-top: -15px;
margin-bottom: 5px;
color: #666;
}
#product-container-P11 {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
}
.image-slider-P11 {
width: 100%;
background-color: #9f9f9f;
display: flex;
justify-content: center;
align-items: center;
aspect-ratio: 1 / 1;
overflow: hidden;
}
.image-slider-P11 img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
display: none;
}
.image-slider-P11 img:first-child {
display: block;
}
.dot-container-P11 {
text-align: center;
padding: 10px 0;
margin-top: -7px;
}
.dot-P11 {
height: 10px;
width: 10px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
cursor: pointer;
}
.dot-P11.active {
background-color: #717171;
}
@media (max-width: 768px) {
.container-P11 {
margin-left: 0;
margin-bottom: -90px;
margin-top: -50px;
}
.container-P11 h1 {
font-size: 24px;
}
.product-P11 {
flex: 0 0 43%;
}
.product-P11 h3 {
font-size: 14px;
}
.product-P11 p {
font-size: 14px;
}
.dot-P11 {
height: 7px;
width: 7px;
}
}
</style>
<div class="container-P11">
<h1>Wedding Garlands</h1>
<div id="product-container-P11"></div>
</div>
<script>
const csvUrl = 'https://docs.google.com/spreadsheets/d/1nrlFzcYVdBIl3YjcOC9jL4OLE57o8jez_ko_JAhJm1M/pub?output=csv';
function parseCSV(csv) {
const rows = csv.split('\n');
const header = rows[0].split(',');
return rows.slice(1).map(row => {
const values = row.split(',');
const product = {};
header.forEach((key, index) => {
product[key.trim()] = values[index]?.trim() || '';
});
return product;
});
}
function displayProducts(products) {
const productContainer = document.getElementById('product-container-P11');
productContainer.innerHTML = '';
products.forEach(product => {
const productElement = document.createElement('div');
productElement.classList.add('product-P11');
productElement.addEventListener('click', function () {
const urlParams = new URLSearchParams();
urlParams.append('name', product.Name);
urlParams.append('price', product.Price);
urlParams.append('image1', product.Image1 || '');
urlParams.append('image2', product.Image2 || '');
urlParams.append('image3', product.Image3 || '');
urlParams.append('image4', product.Image4 || '');
urlParams.append('description', product.Description || '');
urlParams.append('description2', product.Description2 || '');
urlParams.append('description3', product.Description3 || '');
urlParams.append('customization', product.Customization || 'Yes');
urlParams.append('productCode', product['Product Code'] || 'N/A');
window.location.href = 'https://wed.giftntreat.com?' + urlParams.toString();
});
const imageSlider = document.createElement('div');
imageSlider.classList.add('image-slider-P11');
const images = [product.Image1, product.Image2, product.Image3, product.Image4];
images.forEach((imageSrc, index) => {
if (imageSrc) {
const imgElement = document.createElement('img');
imgElement.src = imageSrc;
imgElement.alt = `${product.Name} Image ${index + 1}`;
imgElement.style.display = (index === 0) ? 'block' : 'none';
imageSlider.appendChild(imgElement);
}
});
const dotContainer = document.createElement('div');
dotContainer.classList.add('dot-container-P11');
images.forEach((_, index) => {
const dot = document.createElement('span');
dot.classList.add('dot-P11');
if (index === 0) dot.classList.add('active');
dotContainer.appendChild(dot);
});
productElement.appendChild(imageSlider);
productElement.appendChild(dotContainer);
const titleElement = document.createElement('h3');
titleElement.textContent = product.Name;
const priceElement = document.createElement('p');
priceElement.innerHTML = product.Price ? `₹ ${product.Price}` : '';
productElement.appendChild(titleElement);
productElement.appendChild(priceElement);
productContainer.appendChild(productElement);
});
document.querySelectorAll('.product-P11').forEach(product => {
const images = product.querySelectorAll('.image-slider-P11 img');
const dots = product.querySelectorAll('.dot-P11');
let currentIndex = 0;
let interval;
const showSlide = (index) => {
images.forEach((img, i) => img.style.display = i === index ? 'block' : 'none');
dots.forEach((dot, i) => dot.classList.toggle('active', i === index));
};
const startSlideShow = () => {
interval = setInterval(() => {
currentIndex = (currentIndex + 1) % images.length;
showSlide(currentIndex);
}, 2000);
};
const stopSlideShow = () => clearInterval(interval);
product.addEventListener('mouseenter', startSlideShow);
product.addEventListener('mouseleave', () => {
stopSlideShow();
showSlide(0);
});
dots.forEach((dot, index) => {
dot.addEventListener('click', () => {
currentIndex = index;
showSlide(currentIndex);
stopSlideShow();
});
});
});
}
fetch(csvUrl)
.then(response => response.text())
.then(csv => displayProducts(parseCSV(csv)))
.catch(error => console.error('Error fetching CSV:', error));
</script>