Docfile commited on
Commit
010586f
·
verified ·
1 Parent(s): f779617

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +90 -47
templates/index.html CHANGED
@@ -8,10 +8,6 @@
8
  <!-- Tailwind CSS -->
9
  <script src="https://cdn.tailwindcss.com"></script>
10
 
11
- <!-- React et ReactDOM -->
12
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
13
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
14
-
15
  <!-- Babel -->
16
  <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
17
 
@@ -38,7 +34,38 @@
38
  <div id="root"></div>
39
 
40
  <script type="text/babel">
41
- const { useState, useRef, useEffect } = React;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  // Fonction utilitaire pour rendre les formules LaTeX
44
  const renderMath = (content, isBlock = false) => {
@@ -198,83 +225,99 @@
198
  }, []);
199
 
200
  return (
201
- <div className="p-4">
202
- <div className="max-w-4xl mx-auto">
203
- <div className="p-6">
204
- <div className="text-center mb-8">
205
- <h1 className="text-4xl font-bold text-blue-600">Mariam M-0</h1>
206
- <p className="text-gray-600">Solution Mathématique Intelligente</p>
207
  </div>
208
 
209
- <form onSubmit={handleSubmit} className="space-y-6">
210
- <div className="relative p-8 text-center bg-gray-50 border-2 border-dashed border-gray-300 hover:border-blue-500 transition-colors rounded-lg">
211
  <input
212
  type="file"
213
- onChange={(e) => handleFileSelect(e.target.files[0])}
214
  accept="image/*"
215
- className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
216
  />
217
- <div className="space-y-3">
218
- <div className="w-16 h-16 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
219
- <svg className="w-8 h-8 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
220
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
221
  </svg>
222
  </div>
223
- <p className="text-gray-700 font-medium">Déposez votre image ici</p>
224
- <p className="text-gray-500 text-sm">ou cliquez pour sélectionner</p>
225
  </div>
226
  </div>
227
 
228
- {previewUrl && (
229
- <div className="text-center">
230
- <img src={previewUrl} alt="Prévisualisation" className="max-w-sm mx-auto h-auto object-contain" />
231
- </div>
232
  )}
233
 
234
  <button
235
  type="submit"
236
- className="w-full py-3 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-lg transition-colors"
237
  >
238
  Résoudre le problème
239
  </button>
240
  </form>
241
 
242
- {loading && (
243
- <div className="mt-8 text-center">
244
- <div className="w-12 h-12 border-3 border-blue-500 border-t-transparent rounded-full animate-spin mx-auto" />
245
- <p className="mt-4 text-gray-600">Analyse en cours...</p>
246
- </div>
247
  )}
248
 
249
- {showSolution && (
250
- <div className="mt-8 space-y-6">
251
- <div className="border-t pt-4">
252
  <button
253
- onClick={() => setIsThoughtsOpen(!isThoughtsOpen)}
254
- className="w-full flex justify-between items-center p-2"
255
  >
256
- <span className="font-medium text-gray-700">Processus de Réflexion</span>
257
- {elapsed > 0 && <span className="text-blue-500 text-sm">{elapsed}s</span>}
258
  </button>
259
- <div className={`transition-all duration-300 overflow-hidden ${isThoughtsOpen ? 'max-h-96' : 'max-h-0'}`}>
260
- <div ref={thoughtsRef} className="p-4 text-gray-600 overflow-y-auto" />
261
  </div>
262
  </div>
263
 
264
- <div className="border-t pt-6">
265
- <h3 className="text-xl font-bold text-gray-800 mb-4">Solution</h3>
266
- <div ref={answerRef} className="text-gray-700 overflow-y-auto max-h-96" />
267
  </div>
268
- </div>
269
  )}
270
  </div>
271
  </div>
272
- </div>
273
  );
274
  }
275
 
276
- const root = ReactDOM.createRoot(document.getElementById('root'));
277
- root.render(<MathSolver />);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  </script>
279
  </body>
280
  </html>
 
8
  <!-- Tailwind CSS -->
9
  <script src="https://cdn.tailwindcss.com"></script>
10
 
 
 
 
 
11
  <!-- Babel -->
12
  <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
13
 
 
34
  <div id="root"></div>
35
 
36
  <script type="text/babel">
37
+ // Définition des hooks (similaire à React)
38
+ const useState = (initialValue) => {
39
+ let value = initialValue;
40
+ const setValue = (newValue) => {
41
+ value = newValue;
42
+ renderApp();
43
+ };
44
+ return [value, setValue];
45
+ };
46
+
47
+ const useRef = (initialValue) => {
48
+ return { current: initialValue };
49
+ };
50
+
51
+ const useEffect = (callback, dependencies) => {
52
+
53
+ useEffect.dependencies = useEffect.dependencies || [];
54
+
55
+ let hasChanged = false;
56
+ if (dependencies.length === 0) {
57
+ hasChanged = true;
58
+ } else {
59
+ hasChanged = dependencies.some((dep, i) => {
60
+ return useEffect.dependencies[i] !== dep;
61
+ });
62
+ }
63
+
64
+ if (hasChanged) {
65
+ useEffect.cleanup = useEffect.cleanup || callback();
66
+ useEffect.dependencies = dependencies;
67
+ }
68
+ };
69
 
70
  // Fonction utilitaire pour rendre les formules LaTeX
71
  const renderMath = (content, isBlock = false) => {
 
225
  }, []);
226
 
227
  return (
228
+ `<div class="p-4">
229
+ <div class="max-w-4xl mx-auto">
230
+ <div class="p-6">
231
+ <div class="text-center mb-8">
232
+ <h1 class="text-4xl font-bold text-blue-600">Mariam M-0</h1>
233
+ <p class="text-gray-600">Solution Mathématique Intelligente</p>
234
  </div>
235
 
236
+ <form onsubmit="handleSubmit(event)" class="space-y-6">
237
+ <div class="relative p-8 text-center bg-gray-50 border-2 border-dashed border-gray-300 hover:border-blue-500 transition-colors rounded-lg">
238
  <input
239
  type="file"
240
+ onchange="handleFileSelect(event.target.files[0])"
241
  accept="image/*"
242
+ class="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
243
  />
244
+ <div class="space-y-3">
245
+ <div class="w-16 h-16 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
246
+ <svg class="w-8 h-8 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
247
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
248
  </svg>
249
  </div>
250
+ <p class="text-gray-700 font-medium">Déposez votre image ici</p>
251
+ <p class="text-gray-500 text-sm">ou cliquez pour sélectionner</p>
252
  </div>
253
  </div>
254
 
255
+ ${previewUrl && (
256
+ `<div class="text-center">
257
+ <img src="${previewUrl}" alt="Prévisualisation" class="max-w-sm mx-auto h-auto object-contain" />
258
+ </div>`
259
  )}
260
 
261
  <button
262
  type="submit"
263
+ class="w-full py-3 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-lg transition-colors"
264
  >
265
  Résoudre le problème
266
  </button>
267
  </form>
268
 
269
+ ${loading && (
270
+ `<div class="mt-8 text-center">
271
+ <div class="w-12 h-12 border-3 border-blue-500 border-t-transparent rounded-full animate-spin mx-auto" />
272
+ <p class="mt-4 text-gray-600">Analyse en cours...</p>
273
+ </div>`
274
  )}
275
 
276
+ ${showSolution && (
277
+ `<div class="mt-8 space-y-6">
278
+ <div class="border-t pt-4">
279
  <button
280
+ onclick="setIsThoughtsOpen(!isThoughtsOpen)"
281
+ class="w-full flex justify-between items-center p-2"
282
  >
283
+ <span class="font-medium text-gray-700">Processus de Réflexion</span>
284
+ ${elapsed > 0 && `<span class="text-blue-500 text-sm">${elapsed}s</span>`}
285
  </button>
286
+ <div class="transition-all duration-300 overflow-hidden ${isThoughtsOpen ? 'max-h-96' : 'max-h-0'}">
287
+ <div id="thoughtsRef" class="p-4 text-gray-600 overflow-y-auto" />
288
  </div>
289
  </div>
290
 
291
+ <div class="border-t pt-6">
292
+ <h3 class="text-xl font-bold text-gray-800 mb-4">Solution</h3>
293
+ <div id="answerRef" class="text-gray-700 overflow-y-auto max-h-96" />
294
  </div>
295
+ </div>`
296
  )}
297
  </div>
298
  </div>
299
+ </div>`
300
  );
301
  }
302
 
303
+ // Fonction pour rendre l'application
304
+ const renderApp = () => {
305
+ const app = MathSolver();
306
+ document.getElementById('root').innerHTML = app;
307
+
308
+ // Récupération des éléments après le rendu
309
+ thoughtsRef.current = document.getElementById('thoughtsRef');
310
+ answerRef.current = document.getElementById('answerRef');
311
+
312
+ // Exécution des effets après chaque rendu
313
+ if(useEffect.cleanup) {
314
+ useEffect.cleanup();
315
+ useEffect.cleanup = null;
316
+ }
317
+ };
318
+
319
+ // Premier rendu de l'application
320
+ renderApp();
321
  </script>
322
  </body>
323
  </html>