Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +90 -10
templates/index.html
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
@@ -27,11 +28,74 @@
|
|
27 |
}
|
28 |
|
29 |
@keyframes rotation {
|
30 |
-
0% {
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
</head>
|
|
|
35 |
<body class="bg-gray-50 min-h-screen">
|
36 |
<!-- Navbar -->
|
37 |
<nav class="bg-white shadow-lg">
|
@@ -56,10 +120,12 @@
|
|
56 |
<!-- Upload Section -->
|
57 |
<form id="upload-form" enctype="multipart/form-data">
|
58 |
<div class="flex flex-col items-center justify-center w-full">
|
59 |
-
<label for="image-input"
|
|
|
60 |
<div class="flex flex-col items-center justify-center pt-5 pb-6">
|
61 |
<i class="fas fa-cloud-upload-alt text-4xl text-blue-500 mb-4"></i>
|
62 |
-
<p class="mb-2 text-sm text-gray-500"><span class="font-semibold">Cliquez pour
|
|
|
63 |
<p class="text-xs text-gray-500">PNG, JPG ou JPEG</p>
|
64 |
</div>
|
65 |
<input id="image-input" type="file" name="image" class="hidden" accept="image/*" />
|
@@ -81,19 +147,19 @@
|
|
81 |
<!-- Result Section -->
|
82 |
<div id="result-container" class="hidden mt-8">
|
83 |
<h2 class="text-xl font-semibold text-gray-800 mb-4">Résolution détaillée :</h2>
|
84 |
-
<div id="result" class="bg-gray-50 rounded-lg p-6 prose max-w-none"></div>
|
85 |
</div>
|
86 |
</div>
|
87 |
</div>
|
88 |
|
89 |
<script>
|
90 |
-
document.getElementById('image-input').addEventListener('change', async function(e) {
|
91 |
const file = e.target.files[0];
|
92 |
if (file) {
|
93 |
// Show preview
|
94 |
const preview = document.getElementById('image-preview');
|
95 |
const reader = new FileReader();
|
96 |
-
reader.onload = function(e) {
|
97 |
preview.src = e.target.result;
|
98 |
preview.classList.remove('hidden');
|
99 |
};
|
@@ -102,6 +168,7 @@
|
|
102 |
// Show loading
|
103 |
document.getElementById('loading').classList.remove('hidden');
|
104 |
document.getElementById('result-container').classList.add('hidden');
|
|
|
105 |
|
106 |
try {
|
107 |
const formData = new FormData();
|
@@ -113,14 +180,26 @@
|
|
113 |
});
|
114 |
|
115 |
const data = await response.json();
|
116 |
-
|
117 |
// Hide loading
|
118 |
document.getElementById('loading').classList.add('hidden');
|
119 |
-
|
120 |
// Show result
|
121 |
document.getElementById('result-container').classList.remove('hidden');
|
122 |
document.getElementById('result').innerHTML = data.result;
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
} catch (error) {
|
125 |
console.error('Erreur:', error);
|
126 |
// Hide loading
|
@@ -131,4 +210,5 @@
|
|
131 |
});
|
132 |
</script>
|
133 |
</body>
|
|
|
134 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
3 |
+
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
28 |
}
|
29 |
|
30 |
@keyframes rotation {
|
31 |
+
0% {
|
32 |
+
transform: rotate(0deg);
|
33 |
+
}
|
34 |
+
|
35 |
+
100% {
|
36 |
+
transform: rotate(360deg);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
.math-content {
|
41 |
+
font-size: 1.1em;
|
42 |
+
line-height: 1.6;
|
43 |
+
overflow-x: auto;
|
44 |
+
}
|
45 |
+
|
46 |
+
.math-content p {
|
47 |
+
margin-bottom: 1rem;
|
48 |
+
}
|
49 |
+
|
50 |
+
.math-content .MathJax {
|
51 |
+
overflow-x: auto;
|
52 |
+
overflow-y: hidden;
|
53 |
+
/* Empêche le défilement vertical dans les équations */
|
54 |
+
padding: 0.5rem 0; /* Ajoute un peu d'espace */
|
55 |
+
}
|
56 |
+
|
57 |
+
/* Ajustement pour les petits écrans */
|
58 |
+
@media (max-width: 640px) {
|
59 |
+
.math-content .MathJax {
|
60 |
+
font-size: 0.9em; /* Réduire la taille de la police sur les petits écrans */
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/* Classe pour masquer le contenu pendant que MathJax n'a pas traité */
|
65 |
+
.math-hidden {
|
66 |
+
visibility: hidden;
|
67 |
}
|
68 |
</style>
|
69 |
+
<script>
|
70 |
+
MathJax = {
|
71 |
+
tex: {
|
72 |
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
73 |
+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
|
74 |
+
processEscapes: true,
|
75 |
+
macros: {
|
76 |
+
R: "{\\mathbb{R}}",
|
77 |
+
N: "{\\mathbb{N}}",
|
78 |
+
Z: "{\\mathbb{Z}}",
|
79 |
+
vecv: ["\\begin{pmatrix}#1\\\\#2\\\\#3\\end{pmatrix}", 3]
|
80 |
+
}
|
81 |
+
},
|
82 |
+
svg: {
|
83 |
+
fontCache: 'global'
|
84 |
+
},
|
85 |
+
options: {
|
86 |
+
renderActions: {
|
87 |
+
addMenu: [], // Désactive l'ajout du menu contextuel
|
88 |
+
checkLoading: [150, (doc) => { // Vérifie si MathJax a terminé toutes les 150ms
|
89 |
+
document.querySelectorAll('.math-content').forEach(el => {
|
90 |
+
el.classList.remove('math-hidden');
|
91 |
+
});
|
92 |
+
}]
|
93 |
+
}
|
94 |
+
}
|
95 |
+
};
|
96 |
+
</script>
|
97 |
</head>
|
98 |
+
|
99 |
<body class="bg-gray-50 min-h-screen">
|
100 |
<!-- Navbar -->
|
101 |
<nav class="bg-white shadow-lg">
|
|
|
120 |
<!-- Upload Section -->
|
121 |
<form id="upload-form" enctype="multipart/form-data">
|
122 |
<div class="flex flex-col items-center justify-center w-full">
|
123 |
+
<label for="image-input"
|
124 |
+
class="flex flex-col items-center justify-center w-full h-64 border-2 border-blue-300 border-dashed rounded-lg cursor-pointer bg-gray-50 hover:bg-gray-100 transition duration-300">
|
125 |
<div class="flex flex-col items-center justify-center pt-5 pb-6">
|
126 |
<i class="fas fa-cloud-upload-alt text-4xl text-blue-500 mb-4"></i>
|
127 |
+
<p class="mb-2 text-sm text-gray-500"><span class="font-semibold">Cliquez pour
|
128 |
+
upload</span> ou glissez-déposez</p>
|
129 |
<p class="text-xs text-gray-500">PNG, JPG ou JPEG</p>
|
130 |
</div>
|
131 |
<input id="image-input" type="file" name="image" class="hidden" accept="image/*" />
|
|
|
147 |
<!-- Result Section -->
|
148 |
<div id="result-container" class="hidden mt-8">
|
149 |
<h2 class="text-xl font-semibold text-gray-800 mb-4">Résolution détaillée :</h2>
|
150 |
+
<div id="result" class="bg-gray-50 rounded-lg p-6 prose max-w-none math-content math-hidden"></div>
|
151 |
</div>
|
152 |
</div>
|
153 |
</div>
|
154 |
|
155 |
<script>
|
156 |
+
document.getElementById('image-input').addEventListener('change', async function (e) {
|
157 |
const file = e.target.files[0];
|
158 |
if (file) {
|
159 |
// Show preview
|
160 |
const preview = document.getElementById('image-preview');
|
161 |
const reader = new FileReader();
|
162 |
+
reader.onload = function (e) {
|
163 |
preview.src = e.target.result;
|
164 |
preview.classList.remove('hidden');
|
165 |
};
|
|
|
168 |
// Show loading
|
169 |
document.getElementById('loading').classList.remove('hidden');
|
170 |
document.getElementById('result-container').classList.add('hidden');
|
171 |
+
document.getElementById('result').classList.add('math-hidden'); // Masquer le contenu pendant le traitement
|
172 |
|
173 |
try {
|
174 |
const formData = new FormData();
|
|
|
180 |
});
|
181 |
|
182 |
const data = await response.json();
|
183 |
+
|
184 |
// Hide loading
|
185 |
document.getElementById('loading').classList.add('hidden');
|
186 |
+
|
187 |
// Show result
|
188 |
document.getElementById('result-container').classList.remove('hidden');
|
189 |
document.getElementById('result').innerHTML = data.result;
|
190 |
+
|
191 |
+
// Rendre les maths avec MathJax
|
192 |
+
MathJax.typesetPromise([document.getElementById('result')]) .then(() => {
|
193 |
+
document.getElementById('result').classList.remove('math-hidden');
|
194 |
+
})
|
195 |
+
.catch((err) => {
|
196 |
+
console.error('Erreur MathJax:', err);
|
197 |
+
// Gérer l'erreur MathJax, par exemple afficher un message d'erreur
|
198 |
+
document.getElementById('result').innerHTML = "Erreur lors du rendu des mathématiques.";
|
199 |
+
document.getElementById('result').classList.remove('math-hidden'); // Démasquer même en cas d'erreur pour afficher le message.
|
200 |
+
|
201 |
+
});
|
202 |
+
|
203 |
} catch (error) {
|
204 |
console.error('Erreur:', error);
|
205 |
// Hide loading
|
|
|
210 |
});
|
211 |
</script>
|
212 |
</body>
|
213 |
+
|
214 |
</html>
|