dfw-creator-connect / script.js
tonynwright's picture
create a classified site for creators in dallas fort worth
55e57ba verified
// 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)}`;
}
}