dev-Rachitgarg commited on
Commit
b243d45
·
verified ·
1 Parent(s): 18ba748

make input js at the top and refine the code explainer

Browse files
Files changed (1) hide show
  1. index.html +77 -1
index.html CHANGED
@@ -273,8 +273,84 @@ tailwind.config = {
273
  <!-- Interactive Code Section -->
274
  <div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
275
  <div class="grid grid-cols-1 gap-8">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  <!-- Combined Analysis Panel -->
277
- <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
278
  <!-- Left Column - Bug Analysis and Fixed Code -->
279
  <div class="space-y-8">
280
  <!-- Bug Analysis -->
 
273
  <!-- Interactive Code Section -->
274
  <div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
275
  <div class="grid grid-cols-1 gap-8">
276
+ <!-- Input JS Editor -->
277
+ <div class="code-editor p-4 glow">
278
+ <div class="flex items-center justify-between mb-4">
279
+ <div class="flex items-center">
280
+ <div class="flex space-x-2 mr-4">
281
+ <div class="w-3 h-3 rounded-full bg-red-500"></div>
282
+ <div class="w-3 h-3 rounded-full bg-yellow-500"></div>
283
+ <div class="w-3 h-3 rounded-full bg-green-500"></div>
284
+ </div>
285
+ <div class="text-sm text-gray-400">input.js</div>
286
+ </div>
287
+ <div class="flex space-x-2">
288
+ <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">
289
+ <i data-feather="copy" class="w-4 h-4"></i>
290
+ <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>
291
+ </button>
292
+ <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">
293
+ <i data-feather="download" class="w-4 h-4"></i>
294
+ <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>
295
+ </button>
296
+ </div>
297
+ </div>
298
+ <div id="codeEditor" class="w-full h-96 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-auto">
299
+ <div>
300
+ <div class="text-primary font-medium">Function Declaration:</div>
301
+ <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>
302
+ </div>
303
+ <div class="mt-2">
304
+ <div class="text-primary font-medium">Input Validation:</div>
305
+ <div class="text-gray-400 ml-4"><span class="text-green-400">if</span> (!Array.isArray(<span class="text-blue-400">items</span>)) {</div>
306
+ <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>
307
+ <div class="text-gray-400 ml-4">}</div>
308
+ </div>
309
+ <div class="mt-2">
310
+ <div class="text-primary font-medium">Total Calculation:</div>
311
+ <div class="text-gray-400 ml-4"><span class="text-purple-400">let</span> total = <span class="text-blue-400">0</span>;</div>
312
+ <div class="text-gray-400 ml-4"><span class="text-blue-400">items</span>.forEach(<span class="text-blue-400">item</span> => {</div>
313
+ <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>
314
+ <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>
315
+ <div class="text-gray-400 ml-4">});</div>
316
+ </div>
317
+ <div class="mt-2">
318
+ <div class="text-primary font-medium">Return Value:</div>
319
+ <div class="text-gray-400 ml-4"><span class="text-green-400">return</span> total;</div>
320
+ <div class="text-gray-400 ml-4">}</div>
321
+ </div>
322
+ </div>
323
+ <div class="grid grid-cols-5 gap-3 mt-4">
324
+ <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">
325
+ <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>
326
+ <i data-feather="book-open" class="mr-2 w-4 h-4 text-blue-400"></i>
327
+ <span class="relative">Explain</span>
328
+ </button>
329
+ <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">
330
+ <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>
331
+ <i data-feather="message-square" class="mr-2 w-4 h-4 text-purple-400"></i>
332
+ <span class="relative">Comment</span>
333
+ </button>
334
+ <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">
335
+ <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>
336
+ <i data-feather="bug" class="mr-2 w-4 h-4 text-red-400"></i>
337
+ <span class="relative">Find Bugs</span>
338
+ </button>
339
+ <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">
340
+ <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>
341
+ <i data-feather="file-text" class="mr-2 w-4 h-4 text-green-400"></i>
342
+ <span class="relative">Document</span>
343
+ </button>
344
+ <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">
345
+ <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>
346
+ <i data-feather="wrench" class="mr-2 w-4 h-4 text-indigo-400"></i>
347
+ <span class="relative">Fix Code</span>
348
+ </button>
349
+ </div>
350
+ </div>
351
+
352
  <!-- Combined Analysis Panel -->
353
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
354
  <!-- Left Column - Bug Analysis and Fixed Code -->
355
  <div class="space-y-8">
356
  <!-- Bug Analysis -->