document.addEventListener('DOMContentLoaded', function() { const siteData = JSON.parse(document.getElementById('site-data').textContent); const contentArea = document.getElementById('content-area'); const navLinks = document.querySelectorAll('.nav-link'); const backToTopBtn = document.getElementById('backToTop'); // Handle Content Switching navLinks.forEach(link => { link.addEventListener('click', function(e) { e.preventDefault(); // Update Active Link navLinks.forEach(l => l.classList.remove('active')); this.classList.add('active'); const sectionKey = this.getAttribute('data-section'); const data = siteData.find(item => item.section_key === sectionKey); if (data) { renderContent(data); // On mobile, scroll to content after selection if (window.innerWidth < 768) { contentArea.scrollIntoView({ behavior: 'smooth' }); } } }); }); function renderContent(data) { // We use innerHTML directly because content is pre-formatted in setup_db.php contentArea.innerHTML = `

${data.title}

${data.content}
财神组内部资料 更新时间: ${data.updated_at || '2026-01-30'}
`; } // Back to Top Button window.addEventListener('scroll', function() { if (window.pageYOffset > 300) { backToTopBtn.classList.remove('d-none'); } else { backToTopBtn.classList.add('d-none'); } }); backToTopBtn.addEventListener('click', function() { window.scrollTo({ top: 0, behavior: 'smooth' }); }); // Auto-select Day 1 on load const firstLink = document.querySelector('.nav-link[data-section="day1"]'); if (firstLink) { firstLink.click(); } });