document.addEventListener('DOMContentLoaded', function() { // Initialize tooltips const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl); }); // Search functionality const searchForm = document.querySelector('.search-form'); if (searchForm) { searchForm.addEventListener('submit', function(e) { e.preventDefault(); const searchTerm = this.querySelector('input').value.trim(); if (searchTerm) { // In a real app, this would redirect to search results console.log(`Searching for: ${searchTerm}`); window.location.href = `/search?q=${encodeURIComponent(searchTerm)}`; } }); } // Book hover effects const bookItems = document.querySelectorAll('.book-item'); bookItems.forEach(item => { item.addEventListener('mouseenter', () => { item.classList.add('shadow-lg'); item.querySelector('img').classList.add('scale-105'); }); item.addEventListener('mouseleave', () => { item.classList.remove('shadow-lg'); item.querySelector('img').classList.remove('scale-105'); }); }); }); // API Integration would go here async function fetchRecentBooks() { try { // In a real implementation, this would fetch from BnF API const response = await fetch('https://api.bnf.fr/api/v1/recent'); const data = await response.json(); return data; } catch (error) { console.error('Error fetching recent books:', error); return []; } }