now make the actual terminal working nd another divs for bugs explainatio nadn one terminal for fixed code
Browse files- index.html +168 -29
index.html
CHANGED
|
@@ -201,58 +201,197 @@
|
|
| 201 |
</div>
|
| 202 |
</div>
|
| 203 |
</div>
|
| 204 |
-
|
| 205 |
-
<!-- Code Editor Demo -->
|
| 206 |
<div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
|
| 207 |
-
<div class="
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
<
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
</div>
|
| 222 |
</div>
|
| 223 |
</div>
|
| 224 |
-
|
|
|
|
|
|
|
| 225 |
<div class="flex items-center mb-4">
|
| 226 |
<div class="flex space-x-2 mr-4">
|
| 227 |
<div class="w-3 h-3 rounded-full bg-red-500"></div>
|
| 228 |
<div class="w-3 h-3 rounded-full bg-yellow-500"></div>
|
| 229 |
<div class="w-3 h-3 rounded-full bg-green-500"></div>
|
| 230 |
</div>
|
| 231 |
-
<div class="text-sm text-gray-400">
|
| 232 |
</div>
|
| 233 |
-
<pre class="text-gray-300 text-sm font-mono overflow-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
<span class="text-purple-400">function</span> <span class="text-yellow-300">calculateTotal</span>(items) {
|
| 235 |
-
<span class="text-gray-500">// AI suggests adding parameter validation</span>
|
| 236 |
<span class="text-green-400">if</span> (!Array.isArray(items)) {
|
| 237 |
<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>);
|
| 238 |
}
|
| 239 |
|
| 240 |
<span class="text-purple-400">let</span> total = <span class="text-blue-400">0</span>;
|
| 241 |
items.forEach(item => {
|
| 242 |
-
<span class="text-
|
|
|
|
|
|
|
| 243 |
<span class="text-purple-400">const</span> price = <span class="text-blue-400">Number</span>(item.price) || <span class="text-blue-400">0</span>;
|
| 244 |
-
total += price * (item.quantity || <span class="text-blue-400">1</span>);
|
| 245 |
});
|
| 246 |
|
| 247 |
-
<span class="text-gray-500">// AI suggests adding return type annotation</span>
|
| 248 |
<span class="text-green-400">return</span> total;
|
| 249 |
-
}
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
<div class="flex items-start">
|
| 252 |
-
<i data-feather="
|
| 253 |
<div>
|
| 254 |
-
<
|
| 255 |
-
<
|
| 256 |
</div>
|
| 257 |
</div>
|
| 258 |
</div>
|
|
@@ -261,7 +400,7 @@
|
|
| 261 |
</div>
|
| 262 |
|
| 263 |
<!-- CTA Section -->
|
| 264 |
-
|
| 265 |
<div class="max-w-3xl mx-auto text-center">
|
| 266 |
<h2 class="text-3xl font-extrabold text-white sm:text-4xl">
|
| 267 |
Ready to revolutionize your coding workflow?
|
|
|
|
| 201 |
</div>
|
| 202 |
</div>
|
| 203 |
</div>
|
| 204 |
+
<!-- Interactive Code Section -->
|
|
|
|
| 205 |
<div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
|
| 206 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
| 207 |
+
<!-- Original Code Editor -->
|
| 208 |
+
<div class="code-editor p-4 glow lg:col-span-1">
|
| 209 |
+
<div class="flex items-center mb-4">
|
| 210 |
+
<div class="flex space-x-2 mr-4">
|
| 211 |
+
<div class="w-3 h-3 rounded-full bg-red-500"></div>
|
| 212 |
+
<div class="w-3 h-3 rounded-full bg-yellow-500"></div>
|
| 213 |
+
<div class="w-3 h-3 rounded-full bg-green-500"></div>
|
| 214 |
+
</div>
|
| 215 |
+
<div class="text-sm text-gray-400">input.js</div>
|
| 216 |
+
</div>
|
| 217 |
+
<textarea id="codeInput" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded focus:outline-none focus:ring-2 focus:ring-primary" spellcheck="false">
|
| 218 |
+
function calculateTotal(items) {
|
| 219 |
+
if (!Array.isArray(items)) {
|
| 220 |
+
throw new Error('Items must be an array');
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
let total = 0;
|
| 224 |
+
items.forEach(item => {
|
| 225 |
+
const price = Number(item.price) || 0;
|
| 226 |
+
total += price * (item.quantity || 1);
|
| 227 |
+
});
|
| 228 |
+
|
| 229 |
+
return total;
|
| 230 |
+
}</textarea>
|
| 231 |
+
<button onclick="analyzeCode()" class="mt-4 w-full bg-primary hover:bg-primary/90 text-white py-2 px-4 rounded-md font-medium">
|
| 232 |
+
Analyze Code
|
| 233 |
+
</button>
|
| 234 |
+
</div>
|
| 235 |
+
|
| 236 |
+
<!-- Bug Explanation Terminal -->
|
| 237 |
+
<div class="code-editor p-4 glow lg:col-span-1">
|
| 238 |
+
<div class="flex items-center mb-4">
|
| 239 |
+
<div class="flex space-x-2 mr-4">
|
| 240 |
+
<div class="w-3 h-3 rounded-full bg-red-500"></div>
|
| 241 |
+
<div class="w-3 h-3 rounded-full bg-yellow-500"></div>
|
| 242 |
+
<div class="w-3 h-3 rounded-full bg-green-500"></div>
|
| 243 |
+
</div>
|
| 244 |
+
<div class="text-sm text-gray-400">Bug Analysis</div>
|
| 245 |
+
</div>
|
| 246 |
+
<div id="bugTerminal" class="w-full h-64 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-y-auto">
|
| 247 |
+
<div class="text-green-400">$ Waiting for code analysis...</div>
|
| 248 |
+
</div>
|
| 249 |
+
<div class="mt-4 p-3 bg-gray-800 rounded text-sm text-gray-300">
|
| 250 |
+
<div class="flex items-start">
|
| 251 |
+
<i data-feather="info" class="text-blue-400 mr-2 mt-0.5 flex-shrink-0"></i>
|
| 252 |
+
<div>
|
| 253 |
+
<span class="font-medium">AI Insights:</span> The analyzer will detect potential bugs, security issues, and optimization opportunities.
|
| 254 |
+
</div>
|
| 255 |
</div>
|
| 256 |
</div>
|
| 257 |
</div>
|
| 258 |
+
|
| 259 |
+
<!-- Fixed Code Editor -->
|
| 260 |
+
<div class="code-editor p-4 glow lg:col-span-1">
|
| 261 |
<div class="flex items-center mb-4">
|
| 262 |
<div class="flex space-x-2 mr-4">
|
| 263 |
<div class="w-3 h-3 rounded-full bg-red-500"></div>
|
| 264 |
<div class="w-3 h-3 rounded-full bg-yellow-500"></div>
|
| 265 |
<div class="w-3 h-3 rounded-full bg-green-500"></div>
|
| 266 |
</div>
|
| 267 |
+
<div class="text-sm text-gray-400">fixed.js</div>
|
| 268 |
</div>
|
| 269 |
+
<pre id="fixedCode" class="text-gray-300 text-sm font-mono h-64 overflow-auto bg-gray-800 p-4 rounded">
|
| 270 |
+
<span class="text-gray-500">// Fixed code will appear here after analysis</span></pre>
|
| 271 |
+
<button onclick="applyFix()" class="mt-4 w-full bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-md font-medium flex items-center justify-center">
|
| 272 |
+
<i data-feather="check-circle" class="mr-2"></i> Apply Fix
|
| 273 |
+
</button>
|
| 274 |
+
</div>
|
| 275 |
+
</div>
|
| 276 |
+
</div>
|
| 277 |
+
|
| 278 |
+
<script>
|
| 279 |
+
function analyzeCode() {
|
| 280 |
+
const code = document.getElementById('codeInput').value;
|
| 281 |
+
const bugTerminal = document.getElementById('bugTerminal');
|
| 282 |
+
|
| 283 |
+
// Clear terminal
|
| 284 |
+
bugTerminal.innerHTML = '<div class="text-green-400">$ Analyzing code...</div>';
|
| 285 |
+
|
| 286 |
+
// Simulate AI analysis
|
| 287 |
+
setTimeout(() => {
|
| 288 |
+
bugTerminal.innerHTML = `
|
| 289 |
+
<div class="text-green-400">$ Code analysis complete</div>
|
| 290 |
+
<div class="text-yellow-400">$ Found 2 potential issues:</div>
|
| 291 |
+
<div class="mt-2">
|
| 292 |
+
<div class="text-red-400">1. Line 3: Missing input validation for 'items' array elements</div>
|
| 293 |
+
<div class="text-gray-400 ml-4">- Items should be validated for required properties (price, quantity)</div>
|
| 294 |
+
</div>
|
| 295 |
+
<div class="mt-2">
|
| 296 |
+
<div class="text-red-400">2. Line 7: Potential floating point precision issue</div>
|
| 297 |
+
<div class="text-gray-400 ml-4">- Consider using toFixed(2) for currency calculations</div>
|
| 298 |
+
</div>
|
| 299 |
+
<div class="mt-4 text-green-400">$ Suggested fixes available</div>
|
| 300 |
+
`;
|
| 301 |
+
|
| 302 |
+
// Update fixed code
|
| 303 |
+
document.getElementById('fixedCode').innerHTML = `
|
| 304 |
<span class="text-purple-400">function</span> <span class="text-yellow-300">calculateTotal</span>(items) {
|
|
|
|
| 305 |
<span class="text-green-400">if</span> (!Array.isArray(items)) {
|
| 306 |
<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>);
|
| 307 |
}
|
| 308 |
|
| 309 |
<span class="text-purple-400">let</span> total = <span class="text-blue-400">0</span>;
|
| 310 |
items.forEach(item => {
|
| 311 |
+
<span class="text-green-400">if</span> (!item.price || !item.quantity) {
|
| 312 |
+
<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 have price and quantity'</span>);
|
| 313 |
+
}
|
| 314 |
<span class="text-purple-400">const</span> price = <span class="text-blue-400">Number</span>(item.price) || <span class="text-blue-400">0</span>;
|
| 315 |
+
total += <span class="text-blue-400">Number</span>((price * (item.quantity || <span class="text-blue-400">1</span>)).toFixed(<span class="text-blue-400">2</span>));
|
| 316 |
});
|
| 317 |
|
|
|
|
| 318 |
<span class="text-green-400">return</span> total;
|
| 319 |
+
}`;
|
| 320 |
+
}, 1500);
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
function applyFix() {
|
| 324 |
+
const fixedCode = document.getElementById('fixedCode').textContent;
|
| 325 |
+
document.getElementById('codeInput').value = fixedCode;
|
| 326 |
+
|
| 327 |
+
const bugTerminal = document.getElementById('bugTerminal');
|
| 328 |
+
bugTerminal.innerHTML = `
|
| 329 |
+
<div class="text-green-400">$ Fix applied successfully!</div>
|
| 330 |
+
<div class="text-gray-400 mt-2">Original code has been replaced with the fixed version.</div>
|
| 331 |
+
<div class="text-green-400 mt-4">$ Ready for new analysis</div>
|
| 332 |
+
`;
|
| 333 |
+
}
|
| 334 |
+
</script>
|
| 335 |
+
<!-- Code Explanation Section -->
|
| 336 |
+
<div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto bg-gray-800/50 rounded-lg">
|
| 337 |
+
<div class="text-center mb-12">
|
| 338 |
+
<h2 class="text-3xl font-extrabold text-white sm:text-4xl">
|
| 339 |
+
<span class="gradient-text">Code Explanation</span>
|
| 340 |
+
</h2>
|
| 341 |
+
<p class="mt-3 max-w-2xl mx-auto text-lg text-gray-300">
|
| 342 |
+
Our AI breaks down your code line by line for better understanding and learning.
|
| 343 |
+
</p>
|
| 344 |
+
</div>
|
| 345 |
+
|
| 346 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
| 347 |
+
<div class="code-editor p-4">
|
| 348 |
+
<div class="flex items-center mb-4">
|
| 349 |
+
<div class="text-sm text-gray-400">Code Breakdown</div>
|
| 350 |
+
</div>
|
| 351 |
+
<div id="codeExplanation" class="text-gray-300 text-sm font-mono space-y-4">
|
| 352 |
+
<div>
|
| 353 |
+
<div class="text-primary font-medium">Function Declaration:</div>
|
| 354 |
+
<div class="text-gray-400 ml-4">Defines a function named 'calculateTotal' that takes an 'items' parameter</div>
|
| 355 |
+
</div>
|
| 356 |
+
<div>
|
| 357 |
+
<div class="text-primary font-medium">Input Validation:</div>
|
| 358 |
+
<div class="text-gray-400 ml-4">Checks if 'items' is an array, throws error if not</div>
|
| 359 |
+
</div>
|
| 360 |
+
<div>
|
| 361 |
+
<div class="text-primary font-medium">Total Calculation:</div>
|
| 362 |
+
<div class="text-gray-400 ml-4">Iterates through items array, converts prices to numbers, handles missing quantities</div>
|
| 363 |
+
</div>
|
| 364 |
+
<div>
|
| 365 |
+
<div class="text-primary font-medium">Return Value:</div>
|
| 366 |
+
<div class="text-gray-400 ml-4">Returns the calculated total after processing all items</div>
|
| 367 |
+
</div>
|
| 368 |
+
</div>
|
| 369 |
+
</div>
|
| 370 |
+
|
| 371 |
+
<div class="code-editor p-4">
|
| 372 |
+
<div class="flex items-center mb-4">
|
| 373 |
+
<div class="text-sm text-gray-400">Optimization Tips</div>
|
| 374 |
+
</div>
|
| 375 |
+
<div class="text-gray-300 text-sm font-mono space-y-4">
|
| 376 |
+
<div class="flex items-start">
|
| 377 |
+
<i data-feather="zap" class="text-yellow-400 mr-2 mt-0.5 flex-shrink-0"></i>
|
| 378 |
+
<div>
|
| 379 |
+
<div class="font-medium">Use reduce() instead of forEach:</div>
|
| 380 |
+
<div class="text-gray-400">Could make the total calculation more concise</div>
|
| 381 |
+
</div>
|
| 382 |
+
</div>
|
| 383 |
+
<div class="flex items-start">
|
| 384 |
+
<i data-feather="alert-triangle" class="text-red-400 mr-2 mt-0.5 flex-shrink-0"></i>
|
| 385 |
+
<div>
|
| 386 |
+
<div class="font-medium">Watch for floating point math:</div>
|
| 387 |
+
<div class="text-gray-400">Currency calculations should use fixed decimal places</div>
|
| 388 |
+
</div>
|
| 389 |
+
</div>
|
| 390 |
<div class="flex items-start">
|
| 391 |
+
<i data-feather="code" class="text-blue-400 mr-2 mt-0.5 flex-shrink-0"></i>
|
| 392 |
<div>
|
| 393 |
+
<div class="font-medium">Add TypeScript:</div>
|
| 394 |
+
<div class="text-gray-400">Would catch type issues at compile time</div>
|
| 395 |
</div>
|
| 396 |
</div>
|
| 397 |
</div>
|
|
|
|
| 400 |
</div>
|
| 401 |
|
| 402 |
<!-- CTA Section -->
|
| 403 |
+
<div class="bg-gradient-to-r from-primary/20 to-secondary/20 py-16 px-4 sm:px-6 lg:px-8">
|
| 404 |
<div class="max-w-3xl mx-auto text-center">
|
| 405 |
<h2 class="text-3xl font-extrabold text-white sm:text-4xl">
|
| 406 |
Ready to revolutionize your coding workflow?
|