document.addEventListener('DOMContentLoaded', function() { // Sample data - in a real app, this would come from your backend API const samplePosts = [ { id: 1, username: 'traveler123', userImage: 'http://static.photos/travel/200x200/1', image: 'http://static.photos/travel/1024x576/1', caption: 'Exploring the beautiful mountains! 🏔️ #adventure #travel', likes: 1243, comments: 42, timeAgo: '2h ago', isLiked: false }, { id: 2, username: 'foodlover', userImage: 'http://static.photos/food/200x200/1', image: 'http://static.photos/food/1024x576/1', caption: 'Delicious homemade pasta for dinner tonight! 🍝 #foodie #homecooking', likes: 892, comments: 31, timeAgo: '5h ago', isLiked: true } ]; const postsContainer = document.getElementById('posts-container'); // Render sample posts samplePosts.forEach(post => { const postElement = document.createElement('custom-post-card'); postElement.setAttribute('post-id', post.id); postElement.setAttribute('username', post.username); postElement.setAttribute('user-image', post.userImage); postElement.setAttribute('image', post.image); postElement.setAttribute('caption', post.caption); postElement.setAttribute('likes', post.likes); postElement.setAttribute('comments', post.comments); postElement.setAttribute('time-ago', post.timeAgo); postElement.setAttribute('is-liked', post.isLiked); postsContainer.appendChild(postElement); }); // Toggle auth modal const authModal = document.querySelector('custom-auth-modal'); const authButtons = document.querySelectorAll('[data-auth-toggle]'); authButtons.forEach(button => { button.addEventListener('click', () => { const action = button.getAttribute('data-auth-toggle'); authModal.setAttribute('visible', 'true'); authModal.setAttribute('mode', action); }); }); // Mock authentication state let isAuthenticated = false; function updateAuthUI() { const authElements = document.querySelectorAll('[data-auth-state]'); authElements.forEach(el => { const showWhen = el.getAttribute('data-auth-state'); el.style.display = (showWhen === 'logged-in') === isAuthenticated ? '' : 'none'; }); } // For demo purposes - in a real app, this would be handled by your auth system updateAuthUI(); });