now add donload button to all the function and move bug analysis and fixed js at the top and doccumetion and comment in the bootom
4ffd82e
verified
| <html lang="en" class="dark"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>CodeGenius AI - Smart Coding Companion</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script> | |
| function downloadBugAnalysis() { | |
| const content = document.getElementById('bugTerminal').textContent; | |
| const blob = new Blob([content], { type: 'text/plain' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = 'bug-analysis.txt'; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| function copyFixedCode() { | |
| const code = document.getElementById('fixedCode').textContent; | |
| navigator.clipboard.writeText(code); | |
| const notification = document.createElement('div'); | |
| notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded-md shadow-lg'; | |
| notification.textContent = 'Fixed code copied to clipboard!'; | |
| document.body.appendChild(notification); | |
| setTimeout(() => { | |
| notification.remove(); | |
| }, 2000); | |
| } | |
| function downloadFixedCode() { | |
| const code = document.getElementById('fixedCode').textContent; | |
| const blob = new Blob([code], { type: 'text/javascript' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = 'fixed-code.js'; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| function downloadDocumentation() { | |
| const content = document.getElementById('documentationPanel').textContent; | |
| const blob = new Blob([content], { type: 'text/plain' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = 'documentation.txt'; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| function downloadComments() { | |
| const content = document.getElementById('commentsPanel').textContent; | |
| const blob = new Blob([content], { type: 'text/plain' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = 'code-comments.txt'; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| primary: '#6366f1', | |
| secondary: '#8b5cf6', | |
| dark: '#0f172a', | |
| light: '#f8fafc' | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap'); | |
| body { | |
| font-family: 'Fira Code', monospace; | |
| } | |
| .code-editor { | |
| background-color: #1e293b; | |
| border-radius: 0.75rem; | |
| box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); | |
| } | |
| .gradient-text { | |
| background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%); | |
| -webkit-background-clip: text; | |
| background-clip: text; | |
| color: transparent; | |
| } | |
| .vanta-container { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: -1; | |
| } | |
| .feature-card:hover { | |
| transform: translateY(-5px); | |
| transition: all 0.3s ease; | |
| } | |
| .glow { | |
| box-shadow: 0 0 15px rgba(139, 92, 246, 0.5); | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-dark text-light min-h-screen"> | |
| <div id="vanta-bg" class="vanta-container"></div> | |
| <!-- Navigation --> | |
| <nav class="bg-dark/80 backdrop-blur-md border-b border-gray-800 fixed w-full z-50"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div class="flex items-center justify-between h-16"> | |
| <div class="flex items-center"> | |
| <div class="flex-shrink-0 flex items-center"> | |
| <i data-feather="code" class="text-primary h-6 w-6"></i> | |
| <span class="ml-2 text-xl font-bold gradient-text">CodeGenius AI</span> | |
| </div> | |
| </div> | |
| <div class="hidden md:block"> | |
| <div class="ml-10 flex items-baseline space-x-4"> | |
| <a href="#" class="text-primary px-3 py-2 rounded-md text-sm font-medium">Home</a> | |
| <a href="#" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Features</a> | |
| <a href="#" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Pricing</a> | |
| <a href="#" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Docs</a> | |
| <a href="#" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">About</a> | |
| </div> | |
| </div> | |
| <div class="hidden md:block"> | |
| <div class="ml-4 flex items-center md:ml-6"> | |
| <button class="bg-primary hover:bg-primary/90 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center"> | |
| <i data-feather="log-in" class="mr-2 h-4 w-4"></i> Sign In | |
| </button> | |
| </div> | |
| </div> | |
| <div class="-mr-2 flex md:hidden"> | |
| <button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-white hover:bg-gray-700 focus:outline-none"> | |
| <i data-feather="menu"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </nav> | |
| <!-- Hero Section --> | |
| <div class="relative pt-32 pb-20 px-4 sm:px-6 lg:pt-40 lg:pb-28 lg:px-8"> | |
| <div class="max-w-7xl mx-auto"> | |
| <div class="text-center"> | |
| <h1 class="text-4xl tracking-tight font-extrabold sm:text-5xl md:text-6xl"> | |
| <span class="block">AI-Powered</span> | |
| <span class="block gradient-text">Coding Companion</span> | |
| </h1> | |
| <p class="mt-3 max-w-md mx-auto text-base text-gray-300 sm:text-lg md:mt-5 md:text-xl md:max-w-3xl"> | |
| Supercharge your development workflow with our AI-powered tools that detect bugs, fix code, explain logic, and generate documentation automatically. | |
| </p> | |
| <div class="mt-10 sm:flex sm:justify-center"> | |
| <div class="rounded-md shadow"> | |
| <a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-primary hover:bg-primary/90 md:py-4 md:text-lg md:px-10"> | |
| Get Started | |
| </a> | |
| </div> | |
| <div class="mt-3 rounded-md shadow sm:mt-0 sm:ml-3"> | |
| <a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-primary bg-white hover:bg-gray-50 md:py-4 md:text-lg md:px-10"> | |
| Live Demo | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Features Section --> | |
| <div class="py-12 bg-dark/50 backdrop-blur-sm"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div class="lg:text-center"> | |
| <h2 class="text-base text-primary font-semibold tracking-wide uppercase">Features</h2> | |
| <p class="mt-2 text-3xl leading-8 font-extrabold tracking-tight text-white sm:text-4xl"> | |
| Everything you need to code smarter | |
| </p> | |
| </div> | |
| <div class="mt-10"> | |
| <div class="grid grid-cols-1 gap-10 sm:grid-cols-2 lg:grid-cols-3"> | |
| <!-- Feature 1 --> | |
| <div class="feature-card bg-gray-800/50 p-6 rounded-lg border border-gray-700 hover:border-primary"> | |
| <div class="flex items-center justify-center h-12 w-12 rounded-md bg-primary/10 text-primary mb-4"> | |
| <i data-feather="bug"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-white mb-2">AI Bug Detector</h3> | |
| <p class="text-gray-300"> | |
| Real-time scanning and detection of bugs, errors, and vulnerabilities in your code with detailed reports. | |
| </p> | |
| </div> | |
| <!-- Feature 2 --> | |
| <div class="feature-card bg-gray-800/50 p-6 rounded-lg border border-gray-700 hover:border-primary"> | |
| <div class="flex items-center justify-center h-12 w-12 rounded-md bg-primary/10 text-primary mb-4"> | |
| <i data-feather="check-circle"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-white mb-2">AI Bug Fixer</h3> | |
| <p class="text-gray-300"> | |
| Automated suggestions and fixes for identified bugs, with options to apply changes instantly. | |
| </p> | |
| </div> | |
| <!-- Feature 3 --> | |
| <div class="feature-card bg-gray-800/50 p-6 rounded-lg border border-gray-700 hover:border-primary"> | |
| <div class="flex items-center justify-center h-12 w-12 rounded-md bg-primary/10 text-primary mb-4"> | |
| <i data-feather="book-open"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-white mb-2">AI Code Explainer</h3> | |
| <p class="text-gray-300"> | |
| In-depth breakdowns of complex code segments, simplifying logic and functionality for better understanding. | |
| </p> | |
| </div> | |
| <!-- Feature 4 --> | |
| <div class="feature-card bg-gray-800/50 p-6 rounded-lg border border-gray-700 hover:border-primary"> | |
| <div class="flex items-center justify-center h-12 w-12 rounded-md bg-primary/10 text-primary mb-4"> | |
| <i data-feather="file-text"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-white mb-2">AI Documentation Maker</h3> | |
| <p class="text-gray-300"> | |
| Auto-generates comprehensive, well-structured documentation for projects in various formats. | |
| </p> | |
| </div> | |
| <!-- Feature 5 --> | |
| <div class="feature-card bg-gray-800/50 p-6 rounded-lg border border-gray-700 hover:border-primary"> | |
| <div class="flex items-center justify-center h-12 w-12 rounded-md bg-primary/10 text-primary mb-4"> | |
| <i data-feather="message-square"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-white mb-2">AI Auto-Commentor</h3> | |
| <p class="text-gray-300"> | |
| Intelligently adds descriptive comments to code, improving readability and maintainability. | |
| </p> | |
| </div> | |
| <!-- Feature 6 --> | |
| <div class="feature-card bg-gray-800/50 p-6 rounded-lg border border-gray-700 hover:border-primary"> | |
| <div class="flex items-center justify-center h-12 w-12 rounded-md bg-primary/10 text-primary mb-4"> | |
| <i data-feather="users"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-white mb-2">Real-time Collaboration</h3> | |
| <p class="text-gray-300"> | |
| Work together with your team in real-time with built-in collaboration tools and version control. | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Interactive Code Section --> | |
| <div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto"> | |
| <div class="grid grid-cols-1 gap-8"> | |
| <!-- Bug Analysis and Fixed Code Section --> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-8"> | |
| <!-- Bug Explanation Terminal --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <div class="flex items-center"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-red-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-green-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">Bug Analysis</div> | |
| </div> | |
| <button onclick="downloadBugAnalysis()" class="text-gray-400 hover:text-white p-1 rounded hover:bg-gray-700/50 transition-all duration-200" title="Download Analysis"> | |
| <i data-feather="download" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| <div id="bugTerminal" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-y-auto"> | |
| <div class="text-green-400">$ Waiting for code analysis...</div> | |
| </div> | |
| </div> | |
| <!-- Fixed Code Editor --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <div class="flex items-center"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-red-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-green-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">fixed.js</div> | |
| </div> | |
| <div class="flex space-x-2"> | |
| <button onclick="copyFixedCode()" class="text-gray-400 hover:text-white p-1 rounded hover:bg-gray-700/50 transition-all duration-200" title="Copy Code"> | |
| <i data-feather="copy" class="w-4 h-4"></i> | |
| </button> | |
| <button onclick="downloadFixedCode()" class="text-gray-400 hover:text-white p-1 rounded hover:bg-gray-700/50 transition-all duration-200" title="Download Code"> | |
| <i data-feather="download" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <pre id="fixedCode" class="text-gray-300 text-sm font-mono h-64 overflow-auto bg-gray-800 p-4 rounded"> | |
| <span class="text-gray-500">// Fixed code will appear here after analysis</span></pre> | |
| <button onclick="applyFix()" class="group relative mt-4 w-full bg-gray-800/50 hover:bg-gray-700/70 border border-gray-700 hover:border-green-500 text-white py-3 px-4 rounded-lg font-medium flex items-center justify-center transition-all duration-200 shadow-md hover:shadow-green-500/20"> | |
| <div class="absolute inset-0 bg-green-500/10 group-hover:bg-green-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> | |
| <i data-feather="check-circle" class="mr-2 text-green-400"></i> | |
| <span class="relative">Apply Fix</span> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Enhanced Code Editor with VS Code-like styling --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <div class="flex items-center"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-red-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-green-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">input.js</div> | |
| </div> | |
| <div class="flex space-x-2"> | |
| <button onclick="copyCode()" class="group relative text-gray-400 hover:text-white p-1.5 rounded hover:bg-gray-700/50 transition-all duration-200" title="Copy Code"> | |
| <i data-feather="copy" class="w-4 h-4"></i> | |
| <span class="absolute top-full left-1/2 transform -translate-x-1/2 mt-1 px-2 py-1 text-xs text-white bg-gray-800 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200">Copy</span> | |
| </button> | |
| <button onclick="downloadCode()" class="group relative text-gray-400 hover:text-white p-1.5 rounded hover:bg-gray-700/50 transition-all duration-200" title="Download Code"> | |
| <i data-feather="download" class="w-4 h-4"></i> | |
| <span class="absolute top-full left-1/2 transform -translate-x-1/2 mt-1 px-2 py-1 text-xs text-white bg-gray-800 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200">Download</span> | |
| </button> | |
| </div> | |
| </div> | |
| <div id="codeEditor" class="w-full h-96 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-auto"> | |
| <div> | |
| <div class="text-primary font-medium">Function Declaration:</div> | |
| <div class="text-gray-400 ml-4"><span class="text-purple-400">function</span> <span class="text-yellow-300">calculateTotal</span>(<span class="text-blue-400">items</span>) {</div> | |
| </div> | |
| <div class="mt-2"> | |
| <div class="text-primary font-medium">Input Validation:</div> | |
| <div class="text-gray-400 ml-4"><span class="text-green-400">if</span> (!Array.isArray(<span class="text-blue-400">items</span>)) {</div> | |
| <div class="text-gray-400 ml-8"><span class="text-green-400">throw</span> <span class="text-purple-400">new</span> <span class="text-blue-400">Error</span>(<span class="text-orange-300">'Items must be an array'</span>);</div> | |
| <div class="text-gray-400 ml-4">}</div> | |
| </div> | |
| <div class="mt-2"> | |
| <div class="text-primary font-medium">Total Calculation:</div> | |
| <div class="text-gray-400 ml-4"><span class="text-purple-400">let</span> total = <span class="text-blue-400">0</span>;</div> | |
| <div class="text-gray-400 ml-4"><span class="text-blue-400">items</span>.forEach(<span class="text-blue-400">item</span> => {</div> | |
| <div class="text-gray-400 ml-8"><span class="text-purple-400">const</span> price = <span class="text-blue-400">Number</span>(<span class="text-blue-400">item</span>.price) || <span class="text-blue-400">0</span>;</div> | |
| <div class="text-gray-400 ml-8">total += price * (<span class="text-blue-400">item</span>.quantity || <span class="text-blue-400">1</span>);</div> | |
| <div class="text-gray-400 ml-4">});</div> | |
| </div> | |
| <div class="mt-2"> | |
| <div class="text-primary font-medium">Return Value:</div> | |
| <div class="text-gray-400 ml-4"><span class="text-green-400">return</span> total;</div> | |
| <div class="text-gray-400 ml-4">}</div> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-5 gap-3 mt-4"> | |
| <button onclick="explainCode()" class="group relative bg-gray-700/70 hover:bg-gray-600/80 border border-gray-600 hover:border-blue-500 text-white py-2.5 px-3 rounded-lg text-sm font-medium flex items-center justify-center transition-all duration-200 shadow-md hover:shadow-blue-500/20"> | |
| <div class="absolute inset-0 bg-blue-500/10 group-hover:bg-blue-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> | |
| <i data-feather="book-open" class="mr-2 w-4 h-4 text-blue-400"></i> | |
| <span class="relative">Explain</span> | |
| </button> | |
| <button onclick="commentCode()" class="group relative bg-gray-700/70 hover:bg-gray-600/80 border border-gray-600 hover:border-purple-500 text-white py-2.5 px-3 rounded-lg text-sm font-medium flex items-center justify-center transition-all duration-200 shadow-md hover:shadow-purple-500/20"> | |
| <div class="absolute inset-0 bg-purple-500/10 group-hover:bg-purple-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> | |
| <i data-feather="message-square" class="mr-2 w-4 h-4 text-purple-400"></i> | |
| <span class="relative">Comment</span> | |
| </button> | |
| <button onclick="analyzeCode()" class="group relative bg-gray-700/70 hover:bg-gray-600/80 border border-gray-600 hover:border-red-500 text-white py-2.5 px-3 rounded-lg text-sm font-medium flex items-center justify-center transition-all duration-200 shadow-md hover:shadow-red-500/20"> | |
| <div class="absolute inset-0 bg-red-500/10 group-hover:bg-red-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> | |
| <i data-feather="bug" class="mr-2 w-4 h-4 text-red-400"></i> | |
| <span class="relative">Find Bugs</span> | |
| </button> | |
| <button onclick="documentCode()" class="group relative bg-gray-700/70 hover:bg-gray-600/80 border border-gray-600 hover:border-green-500 text-white py-2.5 px-3 rounded-lg text-sm font-medium flex items-center justify-center transition-all duration-200 shadow-md hover:shadow-green-500/20"> | |
| <div class="absolute inset-0 bg-green-500/10 group-hover:bg-green-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> | |
| <i data-feather="file-text" class="mr-2 w-4 h-4 text-green-400"></i> | |
| <span class="relative">Document</span> | |
| </button> | |
| <button onclick="fixCode()" class="group relative bg-gray-700/70 hover:bg-gray-600/80 border border-gray-600 hover:border-indigo-500 text-white py-2.5 px-3 rounded-lg text-sm font-medium flex items-center justify-center transition-all duration-200 shadow-md hover:shadow-indigo-500/20"> | |
| <div class="absolute inset-0 bg-indigo-500/10 group-hover:bg-indigo-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> | |
| <i data-feather="wrench" class="mr-2 w-4 h-4 text-indigo-400"></i> | |
| <span class="relative">Fix Code</span> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Documentation Panel --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center mb-4"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-blue-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-purple-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-pink-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">Documentation</div> | |
| </div> | |
| <div id="documentationPanel" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-y-auto"> | |
| <div class="text-blue-400">/** | |
| * <span class="text-purple-400">@function</span> calculateTotal | |
| * <span class="text-purple-400">@description</span> Calculates the total price of items in a shopping cart | |
| * <span class="text-purple-400">@param</span> {Array} items - Array of item objects with price and quantity | |
| * <span class="text-purple-400">@returns</span> {Number} Total calculated amount | |
| * <span class="text-purple-400">@throws</span> {Error} If items is not an array | |
| */</div> | |
| </div> | |
| </div> | |
| <!-- Comments Panel --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center mb-4"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-green-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-red-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">Comments</div> | |
| </div> | |
| <div id="commentsPanel" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-y-auto"> | |
| <div class="text-green-400">// Function declaration with items parameter</div> | |
| <div class="text-green-400 mt-2">// Input validation - checks if items is an array</div> | |
| <div class="text-green-400 mt-2">// Initialize total to 0</div> | |
| <div class="text-green-400 mt-2">// Loop through each item in the array</div> | |
| <div class="text-green-400 mt-2">// Convert price to number, default to 0 if invalid</div> | |
| <div class="text-green-400 mt-2">// Calculate line total (price * quantity)</div> | |
| <div class="text-green-400 mt-2">// Return the calculated total</div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Documentation and Comments Section --> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mt-8"> | |
| <!-- Documentation Panel --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <div class="flex items-center"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-blue-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-purple-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-pink-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">Documentation</div> | |
| </div> | |
| <button onclick="downloadDocumentation()" class="text-gray-400 hover:text-white p-1 rounded hover:bg-gray-700/50 transition-all duration-200" title="Download Documentation"> | |
| <i data-feather="download" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| <div id="documentationPanel" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-y-auto"> | |
| <div class="text-blue-400">/** | |
| * <span class="text-purple-400">@function</span> calculateTotal | |
| * <span class="text-purple-400">@description</span> Calculates the total price of items in a shopping cart | |
| * <span class="text-purple-400">@param</span> {Array} items - Array of item objects with price and quantity | |
| * <span class="text-purple-400">@returns</span> {Number} Total calculated amount | |
| * <span class="text-purple-400">@throws</span> {Error} If items is not an array | |
| */</div> | |
| </div> | |
| </div> | |
| <!-- Comments Panel --> | |
| <div class="code-editor p-4 glow"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <div class="flex items-center"> | |
| <div class="flex space-x-2 mr-4"> | |
| <div class="w-3 h-3 rounded-full bg-green-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-red-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-400">Comments</div> | |
| </div> | |
| <button onclick="downloadComments()" class="text-gray-400 hover:text-white p-1 rounded hover:bg-gray-700/50 transition-all duration-200" title="Download Comments"> | |
| <i data-feather="download" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| <div id="commentsPanel" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-y-auto"> | |
| <div class="text-green-400">// Function declaration with items parameter</div> | |
| <div class="text-green-400 mt-2">// Input validation - checks if items is an array</div> | |
| <div class="text-green-400 mt-2">// Initialize total to 0</div> | |
| <div class="text-green-400 mt-2">// Loop through each item in the array</div> | |
| <div class="text-green-400 mt-2">// Convert price to number, default to 0 if invalid</div> | |
| <div class="text-green-400 mt-2">// Calculate line total (price * quantity)</div> | |
| <div class="text-green-400 mt-2">// Return the calculated total</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| </script> | |
| <!-- Enhanced Code Explanation Section --> | |
| <div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto bg-gradient-to-br from-gray-800/50 to-gray-900/60 rounded-lg border border-gray-700/50"> | |
| <div class="text-center mb-12"> | |
| <h2 class="text-3xl font-extrabold text-white sm:text-4xl"> | |
| <span class="gradient-text">Code Explanation</span> | |
| </h2> | |
| <p class="mt-3 max-w-2xl mx-auto text-lg text-gray-300"> | |
| Our AI breaks down your code line by line for better understanding and learning. | |
| </p> | |
| </div> | |
| <div class="grid grid-cols-1 lg:grid-cols-2 gap-8"> | |
| <div class="code-editor p-4"> | |
| <div class="flex items-center mb-4"> | |
| <div class="text-sm text-gray-400">Code Breakdown</div> | |
| </div> | |
| <div id="codeExplanation" class="text-gray-300 text-sm font-mono space-y-4"> | |
| <div> | |
| <div class="text-primary font-medium">Function Declaration:</div> | |
| <div class="text-gray-400 ml-4">Defines a function named 'calculateTotal' that takes an 'items' parameter</div> | |
| </div> | |
| <div> | |
| <div class="text-primary font-medium">Input Validation:</div> | |
| <div class="text-gray-400 ml-4">Checks if 'items' is an array, throws error if not</div> | |
| </div> | |
| <div> | |
| <div class="text-primary font-medium">Total Calculation:</div> | |
| <div class="text-gray-400 ml-4">Iterates through items array, converts prices to numbers, handles missing quantities</div> | |
| </div> | |
| <div> | |
| <div class="text-primary font-medium">Return Value:</div> | |
| <div class="text-gray-400 ml-4">Returns the calculated total after processing all items</div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="code-editor p-4"> | |
| <div class="flex items-center mb-4"> | |
| <div class="text-sm text-gray-400">Optimization Tips</div> | |
| </div> | |
| <div class="text-gray-300 text-sm font-mono space-y-4"> | |
| <div class="flex items-start"> | |
| <i data-feather="zap" class="text-yellow-400 mr-2 mt-0.5 flex-shrink-0"></i> | |
| <div> | |
| <div class="font-medium">Use reduce() instead of forEach:</div> | |
| <div class="text-gray-400">Could make the total calculation more concise</div> | |
| </div> | |
| </div> | |
| <div class="flex items-start"> | |
| <i data-feather="alert-triangle" class="text-red-400 mr-2 mt-0.5 flex-shrink-0"></i> | |
| <div> | |
| <div class="font-medium">Watch for floating point math:</div> | |
| <div class="text-gray-400">Currency calculations should use fixed decimal places</div> | |
| </div> | |
| </div> | |
| <div class="flex items-start"> | |
| <i data-feather="code" class="text-blue-400 mr-2 mt-0.5 flex-shrink-0"></i> | |
| <div> | |
| <div class="font-medium">Add TypeScript:</div> | |
| <div class="text-gray-400">Would catch type issues at compile time</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- CTA Section --> | |
| <div class="bg-gradient-to-r from-primary/20 to-secondary/20 py-16 px-4 sm:px-6 lg:px-8"> | |
| <div class="max-w-3xl mx-auto text-center"> | |
| <h2 class="text-3xl font-extrabold text-white sm:text-4xl"> | |
| Ready to revolutionize your coding workflow? | |
| </h2> | |
| <p class="mt-3 text-xl text-gray-300"> | |
| Join thousands of developers who are coding smarter with AI assistance. | |
| </p> | |
| <div class="mt-10 sm:flex sm:justify-center"> | |
| <div class="rounded-md shadow"> | |
| <a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-primary hover:bg-primary/90 md:py-4 md:text-lg md:px-10"> | |
| Start free trial | |
| </a> | |
| </div> | |
| <div class="mt-3 rounded-md shadow sm:mt-0 sm:ml-3"> | |
| <a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-primary bg-white hover:bg-gray-50 md:py-4 md:text-lg md:px-10"> | |
| See pricing | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Footer --> | |
| <footer class="bg-gray-900/80 backdrop-blur-md border-t border-gray-800 mt-20"> | |
| <div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8"> | |
| <div class="grid grid-cols-2 md:grid-cols-4 gap-8"> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-400 tracking-wider uppercase">Product</h3> | |
| <ul class="mt-4 space-y-4"> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Features</a></li> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Pricing</a></li> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">API</a></li> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Integrations</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-400 tracking-wider uppercase">Resources</h3> | |
| <ul class="mt-4 space-y-4"> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Documentation</a></li> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Guides</a></li> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Blog</a></li> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">Support</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-400 tracking-wider uppercase">Company</h3> | |
| <ul class="mt-4 space-y-4"> | |
| <li><a href="#" class="text-base text-gray-300 hover:text-white">About</a></li | |
| </body> | |
| </html> |