Update templates/math.html
Browse files- templates/math.html +147 -45
templates/math.html
CHANGED
@@ -10,18 +10,69 @@
|
|
10 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
11 |
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
12 |
<style>
|
13 |
-
.dropzone {
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
.
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
.
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
</style>
|
26 |
<script>
|
27 |
window.MathJax = {
|
@@ -29,11 +80,31 @@
|
|
29 |
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
30 |
displayMath: [['$$', '$$'], ['\\[', '\\]']],
|
31 |
processEscapes: true,
|
32 |
-
macros: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
},
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
};
|
38 |
</script>
|
39 |
<script>
|
@@ -57,7 +128,8 @@
|
|
57 |
<div class="container mx-auto px-4 py-8 max-w-4xl">
|
58 |
<header class="text-center mb-12">
|
59 |
<h1 class="text-4xl font-bold text-blue-800 mb-4">Résolution de Problèmes Mathématiques</h1>
|
60 |
-
<p class="text-gray-600 text-lg">Soumettez une image de votre problème mathématique pour obtenir une
|
|
|
61 |
</header>
|
62 |
<div class="mb-8">
|
63 |
<form id="uploadForm" class="space-y-4">
|
@@ -67,16 +139,26 @@
|
|
67 |
<div class="flex flex-col items-center space-y-4">
|
68 |
<i class="fas fa-cloud-upload-alt text-4xl text-blue-600"></i>
|
69 |
<div class="text-lg text-gray-700">
|
70 |
-
Glissez votre image ici ou <span class="text-blue-600 font-semibold">cliquez pour
|
|
|
71 |
</div>
|
72 |
<p class="text-sm text-gray-500">Formats acceptés: PNG, JPG, JPEG</p>
|
73 |
</div>
|
74 |
</div>
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
<div class="flex justify-center items-center space-x-4">
|
77 |
-
<select id="modelChoice" name="model_choice"
|
78 |
-
|
79 |
-
<option value="
|
|
|
80 |
</select>
|
81 |
<button type="submit"
|
82 |
class="px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors duration-200 flex items-center space-x-2 disabled:opacity-50 disabled:cursor-not-allowed">
|
@@ -94,7 +176,8 @@
|
|
94 |
|
95 |
<div id="response" class="hidden">
|
96 |
<div class="bg-white rounded-lg shadow-lg p-6 mb-8">
|
97 |
-
<h2 id="modelUsed" class="text-2xl font-semibold text-blue-800 mb-4">Solution (Modèle: <span
|
|
|
98 |
<div id="latexContent" class="prose max-w-none math-content math-hidden"></div>
|
99 |
</div>
|
100 |
</div>
|
@@ -102,7 +185,8 @@
|
|
102 |
<div id="savedResponsesSection" class="mt-8">
|
103 |
<div class="flex justify-between items-center mb-4">
|
104 |
<h2 class="text-2xl font-semibold text-blue-800">Réponses Sauvegardées</h2>
|
105 |
-
<button id="clearSavedResponses"
|
|
|
106 |
<i class="fas fa-trash-alt"></i> Effacer Tout
|
107 |
</button>
|
108 |
</div>
|
@@ -131,18 +215,26 @@
|
|
131 |
const clearSavedResponsesButton = document.getElementById('clearSavedResponses');
|
132 |
const modelChoiceSelect = document.getElementById('modelChoice');
|
133 |
const modelNameSpan = document.getElementById('modelName');
|
|
|
134 |
|
135 |
let mathJaxReady = false;
|
136 |
window.MathJax.startup.promise.then(() => {
|
137 |
mathJaxReady = true;
|
138 |
});
|
139 |
|
140 |
-
marked.setOptions({
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
function showError(message) {
|
143 |
errorText.textContent = message;
|
144 |
errorMessage.classList.remove('hidden');
|
145 |
-
setTimeout(() => {
|
|
|
|
|
146 |
}
|
147 |
|
148 |
async function renderMathContent(text) {
|
@@ -168,10 +260,22 @@
|
|
168 |
}
|
169 |
}
|
170 |
|
171 |
-
function handleDragOver(e) {
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
function handleDrop(e) {
|
174 |
-
e.preventDefault();
|
|
|
|
|
175 |
const files = e.dataTransfer.files;
|
176 |
if (files.length > 0 && files[0].type.startsWith('image/')) {
|
177 |
fileInput.files = files;
|
@@ -238,19 +342,13 @@
|
|
238 |
await localforage.clear();
|
239 |
console.log('Réponses sauvegardées effacées');
|
240 |
loadSavedResponses();
|
241 |
-
Swal.fire(
|
242 |
-
'Effacé!',
|
243 |
-
'Les réponses ont été supprimées.',
|
244 |
-
'success'
|
245 |
-
);
|
246 |
} catch (error) {
|
247 |
-
console.error(
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
'
|
252 |
-
'error'
|
253 |
-
);
|
254 |
}
|
255 |
}
|
256 |
});
|
@@ -260,13 +358,15 @@
|
|
260 |
try {
|
261 |
savedResponsesContainer.innerHTML = '';
|
262 |
const keys = await localforage.keys();
|
263 |
-
keys.sort((a, b) => parseInt(b.replace('response-', '').split('-')[0]) - parseInt(a
|
|
|
264 |
|
265 |
for (const key of keys) {
|
266 |
const response = await localforage.getItem(key);
|
267 |
-
const [
|
268 |
const responseItem = document.createElement('div');
|
269 |
-
responseItem.className =
|
|
|
270 |
|
271 |
const header = document.createElement('div');
|
272 |
header.className = 'saved-response-header';
|
@@ -298,7 +398,8 @@
|
|
298 |
await localforage.removeItem(key);
|
299 |
responseItem.remove();
|
300 |
} catch (error) {
|
301 |
-
console.error('Erreur lors de la suppression de la réponse:',
|
|
|
302 |
showError('Erreur lors de la suppression de la réponse');
|
303 |
}
|
304 |
});
|
@@ -323,6 +424,7 @@
|
|
323 |
const formData = new FormData();
|
324 |
formData.append('image', fileInput.files[0]);
|
325 |
formData.append('model_choice', modelChoiceSelect.value);
|
|
|
326 |
|
327 |
try {
|
328 |
submitButton.disabled = true;
|
@@ -360,4 +462,4 @@
|
|
360 |
</script>
|
361 |
</body>
|
362 |
|
363 |
-
</html>
|
|
|
10 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
11 |
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
12 |
<style>
|
13 |
+
.dropzone {
|
14 |
+
border: 2px dashed #4F46E5;
|
15 |
+
transition: all 0.3s ease;
|
16 |
+
}
|
17 |
+
|
18 |
+
.dropzone:hover {
|
19 |
+
border-color: #312E81;
|
20 |
+
background-color: rgba(79, 70, 229, 0.1);
|
21 |
+
}
|
22 |
+
|
23 |
+
.loading {
|
24 |
+
display: none;
|
25 |
+
}
|
26 |
+
|
27 |
+
.loading.active {
|
28 |
+
display: flex;
|
29 |
+
}
|
30 |
+
|
31 |
+
.math-content {
|
32 |
+
font-size: 1.1em;
|
33 |
+
line-height: 1.6;
|
34 |
+
overflow-x: auto;
|
35 |
+
}
|
36 |
+
|
37 |
+
.math-content p {
|
38 |
+
margin-bottom: 1rem;
|
39 |
+
white-space: pre-wrap;
|
40 |
+
}
|
41 |
+
|
42 |
+
.math-content .MathJax {
|
43 |
+
overflow-x: auto;
|
44 |
+
overflow-y: hidden;
|
45 |
+
padding: 0.5rem 0;
|
46 |
+
}
|
47 |
+
|
48 |
+
@media (max-width: 640px) {
|
49 |
+
.math-content .MathJax {
|
50 |
+
font-size: 0.9em;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
.math-hidden {
|
55 |
+
visibility: hidden;
|
56 |
+
}
|
57 |
+
|
58 |
+
.saved-response-header {
|
59 |
+
cursor: pointer;
|
60 |
+
display: flex;
|
61 |
+
justify-content: space-between;
|
62 |
+
align-items: center;
|
63 |
+
padding: 0.75rem 1rem;
|
64 |
+
background-color: #f3f4f6;
|
65 |
+
border-bottom: 1px solid #e5e7eb;
|
66 |
+
}
|
67 |
+
|
68 |
+
.saved-response-content {
|
69 |
+
padding: 1rem;
|
70 |
+
display: none;
|
71 |
+
}
|
72 |
+
|
73 |
+
.saved-response-item.open .saved-response-content {
|
74 |
+
display: block;
|
75 |
+
}
|
76 |
</style>
|
77 |
<script>
|
78 |
window.MathJax = {
|
|
|
80 |
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
81 |
displayMath: [['$$', '$$'], ['\\[', '\\]']],
|
82 |
processEscapes: true,
|
83 |
+
macros: {
|
84 |
+
R: "{\\mathbb{R}}",
|
85 |
+
N: "{\\mathbb{N}}",
|
86 |
+
Z: "{\\mathbb{Z}}",
|
87 |
+
vecv: ["\\begin{pmatrix}#1\\\\#2\\\\#3\\end{pmatrix}", 3]
|
88 |
+
}
|
89 |
+
},
|
90 |
+
svg: {
|
91 |
+
fontCache: 'global'
|
92 |
},
|
93 |
+
startup: {
|
94 |
+
pageReady: () => {
|
95 |
+
return Promise.resolve();
|
96 |
+
}
|
97 |
+
},
|
98 |
+
options: {
|
99 |
+
renderActions: {
|
100 |
+
addMenu: [],
|
101 |
+
checkLoading: [150, () => {
|
102 |
+
document.querySelectorAll('.math-content').forEach(el => {
|
103 |
+
el.classList.remove('math-hidden');
|
104 |
+
});
|
105 |
+
}]
|
106 |
+
}
|
107 |
+
}
|
108 |
};
|
109 |
</script>
|
110 |
<script>
|
|
|
128 |
<div class="container mx-auto px-4 py-8 max-w-4xl">
|
129 |
<header class="text-center mb-12">
|
130 |
<h1 class="text-4xl font-bold text-blue-800 mb-4">Résolution de Problèmes Mathématiques</h1>
|
131 |
+
<p class="text-gray-600 text-lg">Soumettez une image de votre problème mathématique pour obtenir une
|
132 |
+
solution détaillée</p>
|
133 |
</header>
|
134 |
<div class="mb-8">
|
135 |
<form id="uploadForm" class="space-y-4">
|
|
|
139 |
<div class="flex flex-col items-center space-y-4">
|
140 |
<i class="fas fa-cloud-upload-alt text-4xl text-blue-600"></i>
|
141 |
<div class="text-lg text-gray-700">
|
142 |
+
Glissez votre image ici ou <span class="text-blue-600 font-semibold">cliquez pour
|
143 |
+
sélectionner</span>
|
144 |
</div>
|
145 |
<p class="text-sm text-gray-500">Formats acceptés: PNG, JPG, JPEG</p>
|
146 |
</div>
|
147 |
</div>
|
148 |
|
149 |
+
<div class="space-y-4">
|
150 |
+
<label for="customInstruction" class="block text-gray-700 font-medium">Instruction
|
151 |
+
personnalisée(pas obligatoire)</label>
|
152 |
+
<input type="text" id="customInstruction" name="custom_instruction"
|
153 |
+
class="w-full px-4 py-2 border rounded-lg focus:ring-blue-500 focus:border-blue-500"
|
154 |
+
placeholder="Exemple : Résoudre en utilisant le théorème de Pythagore">
|
155 |
+
</div>
|
156 |
+
|
157 |
<div class="flex justify-center items-center space-x-4">
|
158 |
+
<select id="modelChoice" name="model_choice"
|
159 |
+
class="rounded-md border-gray-300 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
|
160 |
+
<option value="mariam's">Mariam's (Rapide et performant)</option>
|
161 |
+
<option value="qwen2">Qwen2 (lent mais plus performant)</option>
|
162 |
</select>
|
163 |
<button type="submit"
|
164 |
class="px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors duration-200 flex items-center space-x-2 disabled:opacity-50 disabled:cursor-not-allowed">
|
|
|
176 |
|
177 |
<div id="response" class="hidden">
|
178 |
<div class="bg-white rounded-lg shadow-lg p-6 mb-8">
|
179 |
+
<h2 id="modelUsed" class="text-2xl font-semibold text-blue-800 mb-4">Solution (Modèle: <span
|
180 |
+
id="modelName"></span>)</h2>
|
181 |
<div id="latexContent" class="prose max-w-none math-content math-hidden"></div>
|
182 |
</div>
|
183 |
</div>
|
|
|
185 |
<div id="savedResponsesSection" class="mt-8">
|
186 |
<div class="flex justify-between items-center mb-4">
|
187 |
<h2 class="text-2xl font-semibold text-blue-800">Réponses Sauvegardées</h2>
|
188 |
+
<button id="clearSavedResponses"
|
189 |
+
class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors duration-200">
|
190 |
<i class="fas fa-trash-alt"></i> Effacer Tout
|
191 |
</button>
|
192 |
</div>
|
|
|
215 |
const clearSavedResponsesButton = document.getElementById('clearSavedResponses');
|
216 |
const modelChoiceSelect = document.getElementById('modelChoice');
|
217 |
const modelNameSpan = document.getElementById('modelName');
|
218 |
+
const customInstructionInput = document.getElementById('customInstruction');
|
219 |
|
220 |
let mathJaxReady = false;
|
221 |
window.MathJax.startup.promise.then(() => {
|
222 |
mathJaxReady = true;
|
223 |
});
|
224 |
|
225 |
+
marked.setOptions({
|
226 |
+
breaks: true,
|
227 |
+
gfm: true,
|
228 |
+
pedantic: false,
|
229 |
+
smartLists: true
|
230 |
+
});
|
231 |
|
232 |
function showError(message) {
|
233 |
errorText.textContent = message;
|
234 |
errorMessage.classList.remove('hidden');
|
235 |
+
setTimeout(() => {
|
236 |
+
errorMessage.classList.add('hidden');
|
237 |
+
}, 5000);
|
238 |
}
|
239 |
|
240 |
async function renderMathContent(text) {
|
|
|
260 |
}
|
261 |
}
|
262 |
|
263 |
+
function handleDragOver(e) {
|
264 |
+
e.preventDefault();
|
265 |
+
e.stopPropagation();
|
266 |
+
dropzone.classList.add('bg-blue-50');
|
267 |
+
}
|
268 |
+
|
269 |
+
function handleDragLeave(e) {
|
270 |
+
e.preventDefault();
|
271 |
+
e.stopPropagation();
|
272 |
+
dropzone.classList.remove('bg-blue-50');
|
273 |
+
}
|
274 |
+
|
275 |
function handleDrop(e) {
|
276 |
+
e.preventDefault();
|
277 |
+
e.stopPropagation();
|
278 |
+
dropzone.classList.remove('bg-blue-50');
|
279 |
const files = e.dataTransfer.files;
|
280 |
if (files.length > 0 && files[0].type.startsWith('image/')) {
|
281 |
fileInput.files = files;
|
|
|
342 |
await localforage.clear();
|
343 |
console.log('Réponses sauvegardées effacées');
|
344 |
loadSavedResponses();
|
345 |
+
Swal.fire('Effacé!', 'Les réponses ont été supprimées.', 'success');
|
|
|
|
|
|
|
|
|
346 |
} catch (error) {
|
347 |
+
console.error("Erreur lors de l'effacement des réponses sauvegardées:",
|
348 |
+
error);
|
349 |
+
showError("Erreur lors de l'effacement des réponses sauvegardées");
|
350 |
+
Swal.fire('Erreur!', 'Une erreur est survenue lors de la suppression.',
|
351 |
+
'error');
|
|
|
|
|
352 |
}
|
353 |
}
|
354 |
});
|
|
|
358 |
try {
|
359 |
savedResponsesContainer.innerHTML = '';
|
360 |
const keys = await localforage.keys();
|
361 |
+
keys.sort((a, b) => parseInt(b.replace('response-', '').split('-')[0]) - parseInt(a
|
362 |
+
.replace('response-', '').split('-')[0]));
|
363 |
|
364 |
for (const key of keys) {
|
365 |
const response = await localforage.getItem(key);
|
366 |
+
const [, timestamp, model] = key.split('-');
|
367 |
const responseItem = document.createElement('div');
|
368 |
+
responseItem.className =
|
369 |
+
'saved-response-item bg-white rounded-lg shadow-md overflow-hidden';
|
370 |
|
371 |
const header = document.createElement('div');
|
372 |
header.className = 'saved-response-header';
|
|
|
398 |
await localforage.removeItem(key);
|
399 |
responseItem.remove();
|
400 |
} catch (error) {
|
401 |
+
console.error('Erreur lors de la suppression de la réponse:',
|
402 |
+
error);
|
403 |
showError('Erreur lors de la suppression de la réponse');
|
404 |
}
|
405 |
});
|
|
|
424 |
const formData = new FormData();
|
425 |
formData.append('image', fileInput.files[0]);
|
426 |
formData.append('model_choice', modelChoiceSelect.value);
|
427 |
+
formData.append('custom_instruction', customInstructionInput.value);
|
428 |
|
429 |
try {
|
430 |
submitButton.disabled = true;
|
|
|
462 |
</script>
|
463 |
</body>
|
464 |
|
465 |
+
</html>
|