dev-Rachitgarg commited on
Commit
25bc2b1
·
verified ·
1 Parent(s): 12e6bc2

add the option to download and copy the code nd also add buutton to fix the code and make code explainer more aprearing and good

Browse files
Files changed (1) hide show
  1. index.html +54 -9
index.html CHANGED
@@ -206,7 +206,7 @@
206
  <div class="grid grid-cols-1 gap-8">
207
  <!-- Enhanced Code Editor with VS Code-like styling -->
208
  <div class="code-editor p-4 glow">
209
- <div class="flex items-center justify-between mb-4">
210
  <div class="flex items-center">
211
  <div class="flex space-x-2 mr-4">
212
  <div class="w-3 h-3 rounded-full bg-red-500"></div>
@@ -216,12 +216,17 @@
216
  <div class="text-sm text-gray-400">input.js</div>
217
  </div>
218
  <div class="flex space-x-2">
219
- <button onclick="downloadCode()" class="text-gray-400 hover:text-white p-1">
 
 
 
 
220
  <i data-feather="download" class="w-4 h-4"></i>
 
221
  </button>
222
  </div>
223
  </div>
224
- <div id="codeEditor" class="w-full h-96 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-auto">
225
  <div>
226
  <div class="text-primary font-medium">Function Declaration:</div>
227
  <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>
@@ -246,7 +251,7 @@
246
  <div class="text-gray-400 ml-4">}</div>
247
  </div>
248
  </div>
249
- <div class="grid grid-cols-4 gap-3 mt-4">
250
  <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">
251
  <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>
252
  <i data-feather="book-open" class="mr-2 w-4 h-4 text-blue-400"></i>
@@ -267,6 +272,11 @@
267
  <i data-feather="file-text" class="mr-2 w-4 h-4 text-green-400"></i>
268
  <span class="relative">Document</span>
269
  </button>
 
 
 
 
 
270
  </div>
271
  </div>
272
  </div>
@@ -353,10 +363,45 @@
353
  </div>
354
  </div>
355
  </div>
356
-
357
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  function analyzeCode() {
359
- const code = document.getElementById('codeInput').value;
360
  const bugTerminal = document.getElementById('bugTerminal');
361
 
362
  // Clear terminal
@@ -411,9 +456,9 @@
411
  `;
412
  }
413
  </script>
414
- <!-- Code Explanation Section -->
415
- <div class="py-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto bg-gray-800/50 rounded-lg">
416
- <div class="text-center mb-12">
417
  <h2 class="text-3xl font-extrabold text-white sm:text-4xl">
418
  <span class="gradient-text">Code Explanation</span>
419
  </h2>
 
206
  <div class="grid grid-cols-1 gap-8">
207
  <!-- Enhanced Code Editor with VS Code-like styling -->
208
  <div class="code-editor p-4 glow">
209
+ <div class="flex items-center justify-between mb-4">
210
  <div class="flex items-center">
211
  <div class="flex space-x-2 mr-4">
212
  <div class="w-3 h-3 rounded-full bg-red-500"></div>
 
216
  <div class="text-sm text-gray-400">input.js</div>
217
  </div>
218
  <div class="flex space-x-2">
219
+ <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">
220
+ <i data-feather="copy" class="w-4 h-4"></i>
221
+ <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>
222
+ </button>
223
+ <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">
224
  <i data-feather="download" class="w-4 h-4"></i>
225
+ <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>
226
  </button>
227
  </div>
228
  </div>
229
+ <div id="codeEditor" class="w-full h-96 bg-gray-800 text-gray-300 font-mono text-sm p-4 rounded overflow-auto">
230
  <div>
231
  <div class="text-primary font-medium">Function Declaration:</div>
232
  <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>
 
251
  <div class="text-gray-400 ml-4">}</div>
252
  </div>
253
  </div>
254
+ <div class="grid grid-cols-5 gap-3 mt-4">
255
  <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">
256
  <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>
257
  <i data-feather="book-open" class="mr-2 w-4 h-4 text-blue-400"></i>
 
272
  <i data-feather="file-text" class="mr-2 w-4 h-4 text-green-400"></i>
273
  <span class="relative">Document</span>
274
  </button>
275
+ <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">
276
+ <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>
277
+ <i data-feather="wrench" class="mr-2 w-4 h-4 text-indigo-400"></i>
278
+ <span class="relative">Fix Code</span>
279
+ </button>
280
  </div>
281
  </div>
282
  </div>
 
363
  </div>
364
  </div>
365
  </div>
 
366
  <script>
367
+ function copyCode() {
368
+ const code = document.getElementById('codeEditor').textContent;
369
+ navigator.clipboard.writeText(code);
370
+
371
+ // Show copied notification
372
+ const notification = document.createElement('div');
373
+ notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded-md shadow-lg';
374
+ notification.textContent = 'Code copied to clipboard!';
375
+ document.body.appendChild(notification);
376
+
377
+ setTimeout(() => {
378
+ notification.remove();
379
+ }, 2000);
380
+ }
381
+
382
+ function downloadCode() {
383
+ const code = document.getElementById('codeEditor').textContent;
384
+ const blob = new Blob([code], { type: 'text/javascript' });
385
+ const url = URL.createObjectURL(blob);
386
+
387
+ const a = document.createElement('a');
388
+ a.href = url;
389
+ a.download = 'code.js';
390
+ document.body.appendChild(a);
391
+ a.click();
392
+ document.body.removeChild(a);
393
+ URL.revokeObjectURL(url);
394
+ }
395
+
396
+ function fixCode() {
397
+ analyzeCode();
398
+ setTimeout(() => {
399
+ applyFix();
400
+ }, 2000);
401
+ }
402
+
403
  function analyzeCode() {
404
+ const code = document.getElementById('codeInput').value;
405
  const bugTerminal = document.getElementById('bugTerminal');
406
 
407
  // Clear terminal
 
456
  `;
457
  }
458
  </script>
459
+ <!-- Enhanced Code Explanation Section -->
460
+ <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">
461
+ <div class="text-center mb-12">
462
  <h2 class="text-3xl font-extrabold text-white sm:text-4xl">
463
  <span class="gradient-text">Code Explanation</span>
464
  </h2>