File size: 1,542 Bytes
fb34bbe 7e3f3ea fb34bbe 7e3f3ea | 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 |
// Main JavaScript functionality
document.addEventListener('DOMContentLoaded', () => {
// Initialize any global functionality here
console.log('ByteBazaar loaded!');
// Initialize price range slider
const initRangeSliders = () => {
document.querySelectorAll('input[type="range"]').forEach(slider => {
slider.addEventListener('input', function() {
const valueDisplay = this.nextElementSibling?.querySelector('span:nth-child(2)');
if (valueDisplay) {
valueDisplay.textContent = `${this.value}`;
}
});
});
};
// Initialize filter sections
const initFilterSections = () => {
document.querySelectorAll('.filter-section').forEach(section => {
const header = section.querySelector('.filter-header');
if (header) {
header.addEventListener('click', () => {
const content = section.querySelector('.filter-content');
content.classList.toggle('hidden');
});
}
});
};
initRangeSliders();
initFilterSections();
// Example: Add to cart functionality
document.addEventListener('click', (e) => {
if (e.target.classList.contains('add-to-cart')) {
const product = e.target.closest('.product-card').dataset.product;
alert(`Added ${product} to your cart!`);
}
});
// Mobile menu toggle would be handled by the navbar component
}); |