|
| 1 | +// Navigation HTML |
| 2 | +const navigationHTML = ` |
| 3 | +<nav class="navbar"> |
| 4 | + <div class="nav-container"> |
| 5 | + <div class="nav-logo"> |
| 6 | + <h2>FinWorld</h2> |
| 7 | + </div> |
| 8 | + <ul class="nav-menu"> |
| 9 | + <li><a href="index.html">Home</a></li> |
| 10 | + <li><a href="index.html#overview">Overview</a></li> |
| 11 | + <li><a href="index.html#architecture">Architecture</a></li> |
| 12 | + <li><a href="index.html#datasets">Datasets</a></li> |
| 13 | + <li><a href="index.html#results">Results</a></li> |
| 14 | + <li><a href="index.html#download">Download</a></li> |
| 15 | + <li><a href="documentation.html">Documentation</a></li> |
| 16 | + </ul> |
| 17 | + <div class="hamburger"> |
| 18 | + <span></span> |
| 19 | + <span></span> |
| 20 | + <span></span> |
| 21 | + </div> |
| 22 | + </div> |
| 23 | +</nav> |
| 24 | +`; |
| 25 | + |
| 26 | +// Documentation Sidebar HTML |
| 27 | +const documentationSidebarHTML = ` |
| 28 | +<aside class="docs-sidebar" id="docs-sidebar"> |
| 29 | + <div class="sidebar-toggle" id="sidebar-toggle"> |
| 30 | + <i class="fas fa-bars"></i> |
| 31 | + </div> |
| 32 | + <div class="sidebar-content"> |
| 33 | + <div class="sidebar-section"> |
| 34 | + <h3>Get Started</h3> |
| 35 | + <ul> |
| 36 | + <li><a href="documentation.html#introduction">Introduction</a></li> |
| 37 | + <li><a href="documentation.html#installation">Installation</a></li> |
| 38 | + <li><a href="documentation.html#quick-start">Quick Start</a></li> |
| 39 | + </ul> |
| 40 | + </div> |
| 41 | + |
| 42 | + <div class="sidebar-section"> |
| 43 | + <h3>Core Documentation</h3> |
| 44 | + <ul> |
| 45 | + <li><a href="architecture.html">Architecture Guide</a></li> |
| 46 | + <li><a href="tasks.html">Financial Tasks</a></li> |
| 47 | + <li><a href="configuration.html">Configuration Guide</a></li> |
| 48 | + <li><a href="api-reference.html">API Reference</a></li> |
| 49 | + <li><a href="tutorials.html">Tutorials</a></li> |
| 50 | + <li><a href="examples.html">Examples</a></li> |
| 51 | + </ul> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div class="sidebar-section"> |
| 55 | + <h3>Advanced Topics</h3> |
| 56 | + <ul> |
| 57 | + <li><a href="#custom-models">Custom Models</a></li> |
| 58 | + </ul> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | +</aside> |
| 62 | +`; |
| 63 | + |
| 64 | +// Footer HTML |
| 65 | +const footerHTML = ` |
| 66 | +<footer class="footer"> |
| 67 | + <div class="footer-content" style="text-align: center; max-width: 800px; margin: 0 auto;"> |
| 68 | + <div class="footer-section"> |
| 69 | + <h3>Citation</h3> |
| 70 | + <p style="text-align: left; font-family: monospace; font-size: 14px; line-height: 1.6;">@article{zhang2025finworld,<br> |
| 71 | + title={FinWorld: An All-in-One Open-Source Platform for End-to-End Financial AI Research and Deployment},<br> |
| 72 | + author={Zhang, Wentao and Zhao, Yilei and Zong, Chuqiao and Wang, Xinrun and An, Bo},<br> |
| 73 | + journal={arXiv preprint arXiv:2508.02292},<br> |
| 74 | + year={2025}<br> |
| 75 | + }</p> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + <div class="footer-bottom" style="text-align: center;"> |
| 79 | + <p>© 2025 FinWorld Team. Built with ❤️ for the financial AI community.</p> |
| 80 | + </div> |
| 81 | +</footer> |
| 82 | +`; |
| 83 | + |
| 84 | +// Function to get GitHub base URL |
| 85 | +function getGitHubBaseURL() { |
| 86 | + // Check if we're on GitHub Pages |
| 87 | + if (window.location.hostname.includes('github.io')) { |
| 88 | + // Extract repository name from the path |
| 89 | + const pathParts = window.location.pathname.split('/'); |
| 90 | + if (pathParts.length >= 3) { |
| 91 | + const username = pathParts[1]; |
| 92 | + const repoName = pathParts[2]; |
| 93 | + return `https://github.com/${username}/${repoName}`; |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + // Default to FinWorld repository |
| 98 | + return 'https://github.com/DVampire/FinWorld'; |
| 99 | +} |
| 100 | + |
| 101 | +// Function to convert relative paths to absolute GitHub URLs |
| 102 | +function convertToGitHubURLs() { |
| 103 | + const githubBase = getGitHubBaseURL(); |
| 104 | + |
| 105 | + // Find all links with relative paths starting with ../ |
| 106 | + const links = document.querySelectorAll('a[href^="../"]'); |
| 107 | + links.forEach(link => { |
| 108 | + const relativePath = link.getAttribute('href'); |
| 109 | + // Remove the ../ prefix and convert to absolute GitHub URL |
| 110 | + const cleanPath = relativePath.replace('../', ''); |
| 111 | + |
| 112 | + // Determine if it's a file or directory based on extension |
| 113 | + const isFile = cleanPath.includes('.py') || cleanPath.includes('.yaml') || cleanPath.includes('.json') || cleanPath.includes('.md'); |
| 114 | + const urlType = isFile ? 'blob' : 'tree'; |
| 115 | + |
| 116 | + const absoluteURL = `${githubBase}/${urlType}/main/${cleanPath}`; |
| 117 | + link.setAttribute('href', absoluteURL); |
| 118 | + }); |
| 119 | +} |
| 120 | + |
| 121 | +// Inject components |
| 122 | +document.addEventListener('DOMContentLoaded', function() { |
| 123 | + // Inject navigation |
| 124 | + const navContainer = document.getElementById('navigation-container'); |
| 125 | + if (navContainer) { |
| 126 | + navContainer.innerHTML = navigationHTML; |
| 127 | + } |
| 128 | + |
| 129 | + // Inject documentation sidebar |
| 130 | + const sidebarContainer = document.getElementById('sidebar-container'); |
| 131 | + if (sidebarContainer) { |
| 132 | + sidebarContainer.innerHTML = documentationSidebarHTML; |
| 133 | + |
| 134 | + // Set active page based on current URL |
| 135 | + const currentPage = window.location.pathname.split('/').pop(); |
| 136 | + const activeLink = sidebarContainer.querySelector(`a[href="${currentPage}"]`); |
| 137 | + if (activeLink) { |
| 138 | + activeLink.classList.add('active'); |
| 139 | + } |
| 140 | + |
| 141 | + // Initialize sidebar toggle after injection |
| 142 | + setTimeout(() => { |
| 143 | + initializeSidebarToggle(); |
| 144 | + }, 50); |
| 145 | + } |
| 146 | + |
| 147 | + // Inject footer |
| 148 | + const footerContainer = document.getElementById('footer-container'); |
| 149 | + if (footerContainer) { |
| 150 | + footerContainer.innerHTML = footerHTML; |
| 151 | + } |
| 152 | + |
| 153 | + // Convert relative GitHub links to absolute URLs |
| 154 | + setTimeout(convertToGitHubURLs, 100); |
| 155 | + |
| 156 | + // Initialize mobile menu after components are injected |
| 157 | + setTimeout(initializeMobileMenu, 100); |
| 158 | +}); |
| 159 | + |
| 160 | +function initializeMobileMenu() { |
| 161 | + const hamburger = document.querySelector('.hamburger'); |
| 162 | + const navMenu = document.querySelector('.nav-menu'); |
| 163 | + |
| 164 | + if (hamburger && navMenu) { |
| 165 | + hamburger.addEventListener('click', () => { |
| 166 | + navMenu.classList.toggle('active'); |
| 167 | + }); |
| 168 | + |
| 169 | + // Close mobile menu when clicking outside |
| 170 | + document.addEventListener('click', (e) => { |
| 171 | + if (!hamburger.contains(e.target) && !navMenu.contains(e.target)) { |
| 172 | + navMenu.classList.remove('active'); |
| 173 | + } |
| 174 | + }); |
| 175 | + } |
| 176 | +} |
| 177 | + |
| 178 | +function initializeSidebarToggle() { |
| 179 | + const sidebarToggle = document.getElementById('sidebar-toggle'); |
| 180 | + const sidebar = document.getElementById('docs-sidebar'); |
| 181 | + const docsContent = document.querySelector('.docs-content'); |
| 182 | + |
| 183 | + if (sidebarToggle && sidebar) { |
| 184 | + sidebarToggle.addEventListener('click', (e) => { |
| 185 | + e.preventDefault(); |
| 186 | + e.stopPropagation(); |
| 187 | + sidebar.classList.toggle('collapsed'); |
| 188 | + if (docsContent) { |
| 189 | + docsContent.classList.toggle('sidebar-collapsed'); |
| 190 | + } |
| 191 | + }); |
| 192 | + } |
| 193 | +} |
0 commit comments