Docfile commited on
Commit
06bb0a2
·
verified ·
1 Parent(s): 58fc92d

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +113 -19
templates/index.html CHANGED
@@ -11,10 +11,94 @@
11
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
12
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
13
  <style>
14
- /* ... (votre CSS existant) ... */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  </style>
16
  <script>
17
- // ... (votre configuration de marked et MathJax) ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  </script>
19
  </head>
20
 
@@ -146,15 +230,17 @@
146
  result.innerHTML = marked.parse(generatedResult);
147
 
148
  // Rendre les maths avec MathJax
149
- MathJax.typesetPromise([result])
150
- .then(() => {
151
- result.classList.remove('math-hidden');
152
- })
153
- .catch((err) => {
154
- console.error('Erreur MathJax:', err);
155
- result.innerHTML = "Erreur lors du rendu des mathématiques.";
156
- result.classList.remove('math-hidden');
157
- });
 
 
158
 
159
  } catch (error) {
160
  console.error('Erreur:', error);
@@ -178,16 +264,24 @@
178
  // Sauvegarder la réponse dans le localStorage
179
  saveButton.addEventListener('click', function () {
180
  const timestamp = new Date().toLocaleString();
181
- const savedData = {
182
- timestamp: timestamp,
183
- image: imagePreview.src,
184
- result: generatedResult
185
- };
186
 
187
- localStorage.setItem('savedResult-' + Date.now(), JSON.stringify(savedData));
 
 
 
 
 
 
 
188
 
189
- // Message de confirmation (optionnel)
190
- alert('Réponse sauvegardée!');
 
 
 
 
 
191
  });
192
  </script>
193
  </body>
 
11
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
12
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
13
  <style>
14
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
15
+
16
+ body {
17
+ font-family: 'Poppins', sans-serif;
18
+ }
19
+
20
+ .loader {
21
+ width: 48px;
22
+ height: 48px;
23
+ border: 5px solid #FFF;
24
+ border-bottom-color: #3B82F6;
25
+ border-radius: 50%;
26
+ display: inline-block;
27
+ box-sizing: border-box;
28
+ animation: rotation 1s linear infinite;
29
+ }
30
+
31
+ @keyframes rotation {
32
+ 0% {
33
+ transform: rotate(0deg);
34
+ }
35
+
36
+ 100% {
37
+ transform: rotate(360deg);
38
+ }
39
+ }
40
+
41
+ .math-content {
42
+ font-size: 1.1em;
43
+ line-height: 1.6;
44
+ overflow-x: auto;
45
+ }
46
+
47
+ .math-content p {
48
+ margin-bottom: 1rem;
49
+ }
50
+
51
+ .math-content .MathJax {
52
+ overflow-x: auto;
53
+ overflow-y: hidden;
54
+ padding: 0.5rem 0;
55
+ }
56
+
57
+ @media (max-width: 640px) {
58
+ .math-content .MathJax {
59
+ font-size: 0.9em;
60
+ }
61
+ }
62
+
63
+ .math-hidden {
64
+ visibility: hidden;
65
+ }
66
  </style>
67
  <script>
68
+ // Configuration de marked
69
+ marked.setOptions({
70
+ breaks: true,
71
+ gfm: true,
72
+ headerIds: false
73
+ });
74
+
75
+ // Configuration de MathJax
76
+ MathJax = {
77
+ tex: {
78
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
79
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
80
+ processEscapes: true,
81
+ macros: {
82
+ R: "{\\mathbb{R}}",
83
+ N: "{\\mathbb{N}}",
84
+ Z: "{\\mathbb{Z}}",
85
+ vecv: ["\\begin{pmatrix}#1\\\\#2\\\\#3\\end{pmatrix}", 3]
86
+ }
87
+ },
88
+ svg: {
89
+ fontCache: 'global'
90
+ },
91
+ options: {
92
+ renderActions: {
93
+ addMenu: [],
94
+ checkLoading: [150, (doc) => {
95
+ document.querySelectorAll('.math-content').forEach(el => {
96
+ el.classList.remove('math-hidden');
97
+ });
98
+ }]
99
+ }
100
+ }
101
+ };
102
  </script>
103
  </head>
104
 
 
230
  result.innerHTML = marked.parse(generatedResult);
231
 
232
  // Rendre les maths avec MathJax
233
+ setTimeout(() => {
234
+ MathJax.typesetPromise([result])
235
+ .then(() => {
236
+ result.classList.remove('math-hidden');
237
+ })
238
+ .catch((err) => {
239
+ console.error('Erreur MathJax:', err);
240
+ result.innerHTML = "Erreur lors du rendu des mathématiques.";
241
+ result.classList.remove('math-hidden');
242
+ });
243
+ }, 0);
244
 
245
  } catch (error) {
246
  console.error('Erreur:', error);
 
264
  // Sauvegarder la réponse dans le localStorage
265
  saveButton.addEventListener('click', function () {
266
  const timestamp = new Date().toLocaleString();
267
+ const file = imageInput.files[0];
 
 
 
 
268
 
269
+ if (file) {
270
+ const reader = new FileReader();
271
+ reader.onload = function (e) {
272
+ const savedData = {
273
+ timestamp: timestamp,
274
+ image: e.target.result, // On sauvegarde la data URL de l'image
275
+ result: generatedResult
276
+ };
277
 
278
+ localStorage.setItem('savedResult-' + Date.now(), JSON.stringify(savedData));
279
+ alert('Réponse sauvegardée!');
280
+ };
281
+ reader.readAsDataURL(file); // On lit l'image comme une data URL
282
+ } else {
283
+ alert('Aucune image sélectionnée.');
284
+ }
285
  });
286
  </script>
287
  </body>