Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
document.addEventListener('DOMContentLoaded', function () {
// ----- PRODUCT DATA -----
const productTemplates = {
mouses: {
description: "Ergonomic mouse for comfortable use.",
features: [
"57° ergonomic design for wrist comfort",
"Adjustable DPI (800-16000) for precision",
"Textured grip for extra control",
"Multi-device support via Bluetooth 5.0",
"30-day battery life with fast charging"
],
rating: "★★★★★ (342 reviews)"
},
keyboards: {
description: "Mechanical keyboard with RGB lighting.",
features: [
"16.8 million color RGB backlight",
"Cherry MX switches (Red/Blue/Brown)",
"Detachable USB-C cable",
"Adjustable feet with 3 angles",
],
rating: "★★★★☆ (278 reviews)"
},
desks: {
description: "Durable desk with adjustable height.",
features: [
"Compact design with wall mounting",
"Eco-certified materials",
"Electric or manual height adjustment",
"Integrated power outlets and USB ports",
"Supports up to 150kg",
],
rating: "★★★★☆ (189 reviews)"
},
chairs: {
description: "Ergonomic office chair with premium finish.",
features: [
"Steel frame with reinforced cross braces",
"Durable bamboo seat with matte finish",
"Smart design with wireless charger and USB-C",
"Advanced cable management",
"Quiet operation (<30dB) with safety system",
],
rating: "★★★★★ (412 reviews)"
},
glasses: {
description: "Blue light blocking glasses for digital eye strain.",
features: [
"Lightweight frame with adjustable nose pads",
"Anti-reflective lenses with UV protection",
"Reduce eye strain and improve sleep quality",
"Stylish design for work or gaming",
"Available in prescription or non-prescription",
],
rating: "★★★★★ (128 reviews)"
},
};
// ----- WISHLIST FUNCTIONALITY -----
document.querySelectorAll('.wishlist-icon').forEach(icon => {
icon.addEventListener('click', function () {
this.classList.toggle('active');
const svg = this.querySelector('svg path');
svg.style.fill = this.classList.contains('active') ? '#ff4057' : 'none';
svg.style.stroke = this.classList.contains('active') ? '#ff4057' : '#ccc';
showNotification(this.classList.contains('active') ?
'Added to wishlist!' : 'Removed from wishlist!');
});
});
// ----- PRODUCT BUTTONS (DETAILS & BUY NOW) -----
document.querySelectorAll('.product-button').forEach(button => {
button.addEventListener('click', function () {
const productCard = this.closest('.product-card');
const category = productCard.getAttribute('data-category');
const productTitle = productCard.querySelector('.product-title').textContent;
const productPrice = productCard.querySelector('.product-price').textContent;
const productImage = productCard.querySelector('.product-image img').src;
if (this.classList.contains('buy-now')) {
showNotification(`Added "${productTitle}" to cart!`);
this.textContent = '✓ Added to Cart';
setTimeout(() => {
this.textContent = 'Buy Now';
}, 1500);
} else {
if (productTemplates[category]) {
const productData = {
title: productTitle,
price: productPrice,
image: productImage,
description: productTemplates[category].description,
features: productTemplates[category].features,
rating: productTemplates[category].rating
};
showProductModal(productData);
} else {
console.error(`No template found for category: ${category}`);
}
}
});
});
// ----- NOTIFICATION SYSTEM -----
function showNotification(message) {
const notification = document.createElement('div');
notification.className = 'notification';
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => notification.remove(), 3000);
}
// ----- SHOW PRODUCT MODAL -----
function showProductModal(product) {
const modal = document.createElement('div');
modal.className = 'modal';
modal.innerHTML = `
<div class="modal-content">
<span class="close-modal">×</span>
<div class="modal-image">
<img src="${product.image}" alt="${product.title}">
</div>
<div class="modal-info">
<h2>${product.title}</h2>
<p class="modal-price">${product.price}</p>
<div class="modal-rating">${product.rating}</div>
<p class="modal-description">${product.description}</p>
<div class="modal-features">
<h3>Features:</h3>
<ul>
${product.features.map(feature => `<li>${feature}</li>`).join('')}
</ul>
</div>
<button class="modal-buy">Add to Cart</button>
</div>
</div>
`;
document.body.appendChild(modal);
document.body.style.overflow = 'hidden';
// Close modal event handlers
modal.querySelector('.close-modal').addEventListener('click', () => {
modal.remove();
document.body.style.overflow = '';
});
modal.addEventListener('click', (e) => {
if (e.target === modal) {
modal.remove();
document.body.style.overflow = '';
}
});
// Add to cart button in modal
modal.querySelector('.modal-buy').addEventListener('click', () => {
showNotification(`Added "${product.title}" to cart!`);
modal.remove();
document.body.style.overflow = '';
});
}
});