Spaces:
Running
Running
File size: 1,756 Bytes
482f77b | 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 44 45 46 47 | 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 [];
}
} |