lemon-drop / script.js
Soul4orm777's picture
Redesign my website
1872519 verified
Raw History Blame Contribute Delete
1.48 kB
// Shared JavaScript across all pages
document.addEventListener('DOMContentLoaded', function() {
console.log('Lemon Drop App loaded');
// Add to cart functionality
const addToCartButtons = document.querySelectorAll('.add-to-cart-btn');
addToCartButtons.forEach(button => {
button.addEventListener('click', function() {
const productId = this.dataset.productId;
const productName = this.dataset.productName;
// In a real app, this would add to cart
console.log(`Added ${productName} (${productId}) to cart`);
// Show confirmation
const originalText = this.innerHTML;
this.innerHTML = '<i data-feather="check"></i> Added!';
this.classList.remove('bg-emerald-500');
this.classList.add('bg-green-500');
setTimeout(() => {
this.innerHTML = originalText;
this.classList.remove('bg-green-500');
this.classList.add('bg-emerald-500');
feather.replace();
}, 2000);
});
});
// Weight selector
const weightButtons = document.querySelectorAll('[data-weight]');
weightButtons.forEach(button => {
button.addEventListener('click', function() {
weightButtons.forEach(btn => btn.classList.remove('bg-emerald-500'));
this.classList.add('bg-emerald-500');
});
});
});