Docfile commited on
Commit
9806663
·
verified ·
1 Parent(s): f323dc2

Upload index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +34 -13
templates/index.html CHANGED
@@ -5,8 +5,8 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Mariam M-0 | Solution Mathématique</title>
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
8
-
9
- <!-- Configuration MathJax optimisée -->
10
  <script>
11
  window.MathJax = {
12
  tex: {
@@ -17,18 +17,24 @@
17
  },
18
  options: {
19
  enableMenu: false,
20
- messageStyle: 'none'
 
 
 
 
 
 
 
21
  },
22
  startup: {
23
  pageReady: () => {
24
- return MathJax.startup.defaultPageReady().then(() => {
25
- console.log('MathJax initial typeset complete');
26
- });
27
  }
28
  }
29
  };
30
  </script>
31
- <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" defer></script>
32
  <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.min.js" defer></script>
33
 
34
  <style>
@@ -100,6 +106,7 @@
100
  margin-left: 8px;
101
  }
102
  </style>
 
103
  </head>
104
  <body class="p-4">
105
  <div class="max-w-4xl mx-auto">
@@ -172,6 +179,7 @@
172
 
173
  let startTime = null;
174
  let timerInterval = null;
 
175
 
176
  const updateTimestamp = () => {
177
  if (startTime) {
@@ -224,6 +232,18 @@
224
  handleFileSelect(e.dataTransfer.files[0]);
225
  });
226
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  form.addEventListener('submit', async e => {
228
  e.preventDefault();
229
  const file = imageInput.files[0];
@@ -237,6 +257,7 @@
237
  solution.classList.add('hidden');
238
  thoughtsContent.innerHTML = '';
239
  answerContent.innerHTML = '';
 
240
  thoughtsBox.classList.add('open');
241
 
242
  const formData = new FormData();
@@ -271,13 +292,13 @@
271
  if (!data.content) return;
272
 
273
  const container = currentMode === 'thinking' ? thoughtsContent : answerContent;
274
- container.innerHTML += marked.parse(data.content);
275
-
276
- if (currentMode === 'answering' && window.MathJax) {
277
- MathJax.typesetPromise([container]).catch(console.error);
 
 
278
  }
279
-
280
- container.scrollTop = container.scrollHeight;
281
  });
282
  };
283
 
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Mariam M-0 | Solution Mathématique</title>
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
8
+
9
+ <!-- Optimized MathJax Configuration -->
10
  <script>
11
  window.MathJax = {
12
  tex: {
 
17
  },
18
  options: {
19
  enableMenu: false,
20
+ messageStyle: 'none',
21
+ renderActions: {
22
+ // Add a new action to handle our delayed typesetting
23
+ add: [135, 'delayedTypeset', (doc) => {
24
+ // Typeset the entire answerContent
25
+ return MathJax.typesetPromise([document.getElementById('answerContent')]);
26
+ }]
27
+ }
28
  },
29
  startup: {
30
  pageReady: () => {
31
+ console.log('MathJax is fully loaded and ready.');
32
+ window.mathJaxReady = true; // Signal that MathJax is ready
 
33
  }
34
  }
35
  };
36
  </script>
37
+ <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script" async></script>
38
  <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.min.js" defer></script>
39
 
40
  <style>
 
106
  margin-left: 8px;
107
  }
108
  </style>
109
+
110
  </head>
111
  <body class="p-4">
112
  <div class="max-w-4xl mx-auto">
 
179
 
180
  let startTime = null;
181
  let timerInterval = null;
182
+ let answerBuffer = '';
183
 
184
  const updateTimestamp = () => {
185
  if (startTime) {
 
232
  handleFileSelect(e.dataTransfer.files[0]);
233
  });
234
 
235
+ const typesetAnswerIfReady = () => {
236
+ if (window.mathJaxReady) {
237
+ MathJax.startup.document.elements = [document.getElementById('answerContent')];
238
+ MathJax.typeset();
239
+
240
+ answerContent.scrollTop = answerContent.scrollHeight;
241
+ } else {
242
+ // If not ready, wait a bit and try again
243
+ setTimeout(typesetAnswerIfReady, 200);
244
+ }
245
+ };
246
+
247
  form.addEventListener('submit', async e => {
248
  e.preventDefault();
249
  const file = imageInput.files[0];
 
257
  solution.classList.add('hidden');
258
  thoughtsContent.innerHTML = '';
259
  answerContent.innerHTML = '';
260
+ answerBuffer = '';
261
  thoughtsBox.classList.add('open');
262
 
263
  const formData = new FormData();
 
292
  if (!data.content) return;
293
 
294
  const container = currentMode === 'thinking' ? thoughtsContent : answerContent;
295
+
296
+ if (currentMode === 'answering'){
297
+ container.innerHTML += marked.parse(data.content);
298
+ typesetAnswerIfReady();
299
+ } else {
300
+ container.innerHTML += marked.parse(data.content);
301
  }
 
 
302
  });
303
  };
304