dev-Rachitgarg commited on
Commit
878f875
·
verified ·
1 Parent(s): a815ebe

make the input js div same just as code explain div

Browse files
Files changed (1) hide show
  1. index.html +29 -18
index.html CHANGED
@@ -221,37 +221,48 @@
221
  </button>
222
  </div>
223
  </div>
224
- <div id="codeEditor" class="w-full h-80 bg-gray-900 text-gray-100 font-mono text-sm p-4 rounded overflow-auto focus:outline-none focus:ring-2 focus:ring-primary" contenteditable="true" spellcheck="false">
225
- <span class="text-purple-400">function</span> <span class="text-yellow-300">calculateTotal</span>(<span class="text-blue-400">items</span>) {
226
- <span class="text-green-400">if</span> (!Array.isArray(<span class="text-blue-400">items</span>)) {
227
- <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>);
228
- }
229
-
230
- <span class="text-purple-400">let</span> total = <span class="text-blue-400">0</span>;
231
- <span class="text-blue-400">items</span>.forEach(<span class="text-blue-400">item</span> => {
232
- <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>;
233
- total += price * (<span class="text-blue-400">item</span>.quantity || <span class="text-blue-400">1</span>);
234
- });
235
-
236
- <span class="text-green-400">return</span> total;
237
- }</div>
 
 
 
 
 
 
 
 
 
 
 
238
  <div class="grid grid-cols-2 gap-3 mt-4">
239
- <button onclick="explainCode()" class="group relative bg-gray-800/50 hover:bg-gray-700/70 border border-gray-700 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">
240
  <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>
241
  <i data-feather="book-open" class="mr-2 w-4 h-4 text-blue-400"></i>
242
  <span class="relative">Explain</span>
243
  </button>
244
- <button onclick="commentCode()" class="group relative bg-gray-800/50 hover:bg-gray-700/70 border border-gray-700 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">
245
  <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>
246
  <i data-feather="message-square" class="mr-2 w-4 h-4 text-purple-400"></i>
247
  <span class="relative">Comment</span>
248
  </button>
249
- <button onclick="analyzeCode()" class="group relative bg-gray-800/50 hover:bg-gray-700/70 border border-gray-700 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">
250
  <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>
251
  <i data-feather="bug" class="mr-2 w-4 h-4 text-red-400"></i>
252
  <span class="relative">Find Bugs</span>
253
  </button>
254
- <button onclick="documentCode()" class="group relative bg-gray-800/50 hover:bg-gray-700/70 border border-gray-700 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">
255
  <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>
256
  <i data-feather="file-text" class="mr-2 w-4 h-4 text-green-400"></i>
257
  <span class="relative">Document</span>
 
221
  </button>
222
  </div>
223
  </div>
224
+ <div id="codeEditor" class="w-full h-80 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>
228
+ </div>
229
+ <div class="mt-2">
230
+ <div class="text-primary font-medium">Input Validation:</div>
231
+ <div class="text-gray-400 ml-4"><span class="text-green-400">if</span> (!Array.isArray(<span class="text-blue-400">items</span>)) {</div>
232
+ <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>
233
+ <div class="text-gray-400 ml-4">}</div>
234
+ </div>
235
+ <div class="mt-2">
236
+ <div class="text-primary font-medium">Total Calculation:</div>
237
+ <div class="text-gray-400 ml-4"><span class="text-purple-400">let</span> total = <span class="text-blue-400">0</span>;</div>
238
+ <div class="text-gray-400 ml-4"><span class="text-blue-400">items</span>.forEach(<span class="text-blue-400">item</span> => {</div>
239
+ <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>
240
+ <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>
241
+ <div class="text-gray-400 ml-4">});</div>
242
+ </div>
243
+ <div class="mt-2">
244
+ <div class="text-primary font-medium">Return Value:</div>
245
+ <div class="text-gray-400 ml-4"><span class="text-green-400">return</span> total;</div>
246
+ <div class="text-gray-400 ml-4">}</div>
247
+ </div>
248
+ </div>
249
  <div class="grid grid-cols-2 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>
253
  <span class="relative">Explain</span>
254
  </button>
255
+ <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">
256
  <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>
257
  <i data-feather="message-square" class="mr-2 w-4 h-4 text-purple-400"></i>
258
  <span class="relative">Comment</span>
259
  </button>
260
+ <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">
261
  <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>
262
  <i data-feather="bug" class="mr-2 w-4 h-4 text-red-400"></i>
263
  <span class="relative">Find Bugs</span>
264
  </button>
265
+ <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">
266
  <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>
267
  <i data-feather="file-text" class="mr-2 w-4 h-4 text-green-400"></i>
268
  <span class="relative">Document</span>