Spaces:
Running
Running
File size: 1,382 Bytes
55e57ba |
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 |
// Main script file with common functionality
document.addEventListener('DOMContentLoaded', function() {
// Initialize any common functionality here
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Initialize any tooltips or popovers
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
});
// API functions for creator data
async function fetchFeaturedCreators() {
try {
const response = await fetch('/api/creators/featured');
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching featured creators:', error);
return [];
}
}
// Function to handle search
function handleSearch(event) {
event.preventDefault();
const searchTerm = document.getElementById('searchInput').value.trim();
if (searchTerm) {
window.location.href = `/search?q=${encodeURIComponent(searchTerm)}`;
}
} |