Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +484 -205
templates/index.html
CHANGED
@@ -1,215 +1,494 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
</head>
|
125 |
<body>
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
-
<
|
128 |
-
|
129 |
-
|
130 |
-
</header>
|
131 |
-
|
132 |
-
<main>
|
133 |
-
<section class="card">
|
134 |
-
<h2>Version Gratuite</h2>
|
135 |
-
<p>3 problèmes gratuits par jour avec explication pas-à-pas.</p>
|
136 |
-
|
137 |
-
<ul class="features">
|
138 |
-
<li><i class="fas fa-check-circle"></i> Problèmes basiques</li>
|
139 |
-
<li><i class="fas fa-check-circle"></i> 3 par jour</li>
|
140 |
-
<li><i class="fas fa-check-circle"></i> Explications détaillées</li>
|
141 |
-
<li class="disabled"><i class="fas fa-times-circle"></i><span>Code avancé (Pro)</span></li>
|
142 |
-
<li class="disabled"><i class="fas fa-times-circle"></i><span>Illimité (Pro)</span></li>
|
143 |
-
<li class="disabled"><i class="fas fa-times-circle"></i><span>Support prioritaire (Pro)</span></li>
|
144 |
-
</ul>
|
145 |
-
|
146 |
-
<div class="upload">
|
147 |
-
<input type="file" id="imgInput" accept="image/*">
|
148 |
-
<button class="btn" id="btnSelect"><i class="fas fa-upload"></i> Choisir une image</button>
|
149 |
-
</div>
|
150 |
-
<img id="imgPreview" class="preview" alt="Aperçu du problème">
|
151 |
-
<button class="btn secondary" id="btnSolve" style="display:none;"><i class="fas fa-calculator"></i> Résoudre</button>
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
</div>
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
</body>
|
215 |
-
</html>
|
|
|
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">
|
6 |
+
<title>Math Solver - Version Gratuite</title>
|
7 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
|
8 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css" rel="stylesheet">
|
9 |
+
<style>
|
10 |
+
:root {
|
11 |
+
--primary-color: #4a6fa5;
|
12 |
+
--secondary-color: #166088;
|
13 |
+
--accent-color: #4fc3f7;
|
14 |
+
--background-color: #f8f9fa;
|
15 |
+
--text-color: #333;
|
16 |
+
--box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
17 |
+
--code-bg: #2c323c;
|
18 |
+
--output-bg: #f1f8f9;
|
19 |
+
}
|
20 |
+
|
21 |
+
body {
|
22 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
23 |
+
line-height: 1.6;
|
24 |
+
margin: 0;
|
25 |
+
padding: 0;
|
26 |
+
background-color: var(--background-color);
|
27 |
+
color: var(--text-color);
|
28 |
+
}
|
29 |
+
|
30 |
+
.container {
|
31 |
+
max-width: 1000px;
|
32 |
+
margin: 0 auto;
|
33 |
+
padding: 20px;
|
34 |
+
}
|
35 |
+
|
36 |
+
header {
|
37 |
+
text-align: center;
|
38 |
+
padding: 20px 0;
|
39 |
+
margin-bottom: 30px;
|
40 |
+
}
|
41 |
+
|
42 |
+
.logo {
|
43 |
+
font-size: 2.5rem;
|
44 |
+
font-weight: bold;
|
45 |
+
color: var(--primary-color);
|
46 |
+
margin-bottom: 10px;
|
47 |
+
}
|
48 |
+
|
49 |
+
.subtitle {
|
50 |
+
font-size: 1.2rem;
|
51 |
+
color: var(--secondary-color);
|
52 |
+
margin-bottom: 20px;
|
53 |
+
}
|
54 |
+
|
55 |
+
.content-box {
|
56 |
+
background-color: white;
|
57 |
+
border-radius: 10px;
|
58 |
+
box-shadow: var(--box-shadow);
|
59 |
+
padding: 30px;
|
60 |
+
margin-bottom: 30px;
|
61 |
+
text-align: center;
|
62 |
+
}
|
63 |
+
|
64 |
+
h1 {
|
65 |
+
color: var(--primary-color);
|
66 |
+
margin-top: 0;
|
67 |
+
}
|
68 |
+
|
69 |
+
.feature-list {
|
70 |
+
list-style-type: none;
|
71 |
+
padding: 0;
|
72 |
+
margin: 30px 0;
|
73 |
+
text-align: left;
|
74 |
+
}
|
75 |
+
|
76 |
+
.feature-list li {
|
77 |
+
padding: 10px 0;
|
78 |
+
margin-bottom: 10px;
|
79 |
+
display: flex;
|
80 |
+
align-items: center;
|
81 |
+
}
|
82 |
+
|
83 |
+
.feature-list i {
|
84 |
+
color: var(--accent-color);
|
85 |
+
margin-right: 10px;
|
86 |
+
font-size: 1.2rem;
|
87 |
+
}
|
88 |
+
|
89 |
+
.cta-button {
|
90 |
+
display: inline-block;
|
91 |
+
background-color: var(--primary-color);
|
92 |
+
color: white;
|
93 |
+
padding: 12px 25px;
|
94 |
+
border-radius: 5px;
|
95 |
+
text-decoration: none;
|
96 |
+
font-weight: bold;
|
97 |
+
transition: all 0.3s ease;
|
98 |
+
margin: 20px 10px;
|
99 |
+
border: none;
|
100 |
+
cursor: pointer;
|
101 |
+
}
|
102 |
+
|
103 |
+
.cta-button:hover {
|
104 |
+
background-color: var(--secondary-color);
|
105 |
+
transform: translateY(-2px);
|
106 |
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
|
107 |
+
}
|
108 |
+
|
109 |
+
.upgrade-section {
|
110 |
+
margin-top: 30px;
|
111 |
+
padding: 20px;
|
112 |
+
border-top: 1px solid #ddd;
|
113 |
+
}
|
114 |
+
|
115 |
+
footer {
|
116 |
+
text-align: center;
|
117 |
+
padding: 20px 0;
|
118 |
+
color: #666;
|
119 |
+
font-size: 0.9rem;
|
120 |
+
}
|
121 |
+
|
122 |
+
#solution {
|
123 |
+
background: #fff;
|
124 |
+
padding: 20px;
|
125 |
+
border-radius: 8px;
|
126 |
+
text-align: left;
|
127 |
+
line-height: 1.8;
|
128 |
+
font-size: 16px;
|
129 |
+
}
|
130 |
+
|
131 |
+
.code-section {
|
132 |
+
margin: 20px 0;
|
133 |
+
border-radius: 8px;
|
134 |
+
overflow: hidden;
|
135 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
136 |
+
}
|
137 |
+
|
138 |
+
.code-header {
|
139 |
+
background-color: #343a40;
|
140 |
+
color: white;
|
141 |
+
padding: 8px 15px;
|
142 |
+
font-size: 14px;
|
143 |
+
font-family: 'Courier New', monospace;
|
144 |
+
display: flex;
|
145 |
+
justify-content: space-between;
|
146 |
+
align-items: center;
|
147 |
+
}
|
148 |
+
|
149 |
+
.code-content {
|
150 |
+
margin: 0;
|
151 |
+
padding: 15px;
|
152 |
+
background-color: var(--code-bg);
|
153 |
+
color: #e6e6e6;
|
154 |
+
overflow-x: auto;
|
155 |
+
font-family: 'Courier New', monospace;
|
156 |
+
font-size: 14px;
|
157 |
+
line-height: 1.5;
|
158 |
+
}
|
159 |
+
|
160 |
+
.output-section {
|
161 |
+
background-color: var(--output-bg);
|
162 |
+
padding: 15px;
|
163 |
+
border-radius: 0 0 8px 8px;
|
164 |
+
border-top: 1px solid #ddd;
|
165 |
+
color: #333;
|
166 |
+
font-family: 'Courier New', monospace;
|
167 |
+
font-size: 14px;
|
168 |
+
white-space: pre-wrap;
|
169 |
+
overflow-x: auto;
|
170 |
+
}
|
171 |
+
|
172 |
+
.step-section {
|
173 |
+
margin: 25px 0;
|
174 |
+
padding: 15px;
|
175 |
+
background-color: #f9f9f9;
|
176 |
+
border-left: 4px solid var(--primary-color);
|
177 |
+
border-radius: 0 8px 8px 0;
|
178 |
+
overflow-x: auto; /* Pour les formules LaTeX larges */
|
179 |
+
white-space: pre-wrap; /* Preserve whitespace/line breaks from stream */
|
180 |
+
}
|
181 |
+
|
182 |
+
.latex-display {
|
183 |
+
overflow-x: auto;
|
184 |
+
padding: 10px 0;
|
185 |
+
margin: 15px 0;
|
186 |
+
text-align: center;
|
187 |
+
}
|
188 |
+
|
189 |
+
.thinking-indicator, .executing-indicator, .answering-indicator {
|
190 |
+
display: flex;
|
191 |
+
align-items: center;
|
192 |
+
padding: 10px;
|
193 |
+
margin: 10px 0;
|
194 |
+
border-radius: 8px;
|
195 |
+
font-size: 0.9rem;
|
196 |
+
}
|
197 |
+
|
198 |
+
.thinking-indicator {
|
199 |
+
background-color: #e3f2fd;
|
200 |
+
color: #1565c0;
|
201 |
+
}
|
202 |
+
|
203 |
+
.executing-indicator {
|
204 |
+
background-color: #ede7f6;
|
205 |
+
color: #5e35b1;
|
206 |
+
}
|
207 |
+
|
208 |
+
.answering-indicator {
|
209 |
+
background-color: #e8f5e9;
|
210 |
+
color: #2e7d32;
|
211 |
+
}
|
212 |
+
|
213 |
+
.indicator-icon {
|
214 |
+
margin-right: 10px;
|
215 |
+
animation: pulse 1.5s infinite ease-in-out;
|
216 |
+
}
|
217 |
+
|
218 |
+
@keyframes pulse {
|
219 |
+
0% { opacity: 0.6; }
|
220 |
+
50% { opacity: 1; }
|
221 |
+
100% { opacity: 0.6; }
|
222 |
+
}
|
223 |
+
|
224 |
+
/* Styles spécifiques à MathJax pour le rendu */
|
225 |
+
/* Ensure rendered math doesn't cause excessive layout shifts or overflow */
|
226 |
+
mjx-container {
|
227 |
+
overflow-x: auto;
|
228 |
+
overflow-y: hidden;
|
229 |
+
display: block; /* Treat block math as a block */
|
230 |
+
margin: 1em 0; /* Add some vertical spacing */
|
231 |
+
text-align: initial; /* Inherit text alignment from parent */
|
232 |
+
}
|
233 |
+
mjx-assistive-mml { /* Hide the assistive MML */
|
234 |
+
display: none !important;
|
235 |
+
}
|
236 |
+
|
237 |
+
/* Ensure inline math flows correctly */
|
238 |
+
.MathJax nobr,.MathJax .mjx-chtml{
|
239 |
+
display: inline-block !important; /* Keep inline math inline */
|
240 |
+
white-space: normal !important; /* Allow text wrapping around inline math */
|
241 |
+
}
|
242 |
+
.step-section span.MathJax_Preview { /* Hide MathJax preview spans */
|
243 |
+
display: none !important;
|
244 |
+
}
|
245 |
+
|
246 |
+
</style>
|
247 |
</head>
|
248 |
<body>
|
249 |
+
<div class="container">
|
250 |
+
<header>
|
251 |
+
<div class="logo">Math Solver</div>
|
252 |
+
<div class="subtitle">La solution intelligente pour vos problèmes mathématiques</div>
|
253 |
+
</header>
|
254 |
|
255 |
+
<div class="content-box">
|
256 |
+
<h1>Version Gratuite</h1>
|
257 |
+
<p>Vous utilisez actuellement la version gratuite de Math Solver qui vous permet de résoudre 3 problèmes par jour.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
+
<div class="feature-list">
|
260 |
+
<h2>Fonctionnalités disponibles :</h2>
|
261 |
+
<ul class="feature-list">
|
262 |
+
<li><i class="fas fa-check-circle"></i> Résolution de problèmes mathématiques basiques</li>
|
263 |
+
<li><i class="fas fa-check-circle"></i> 3 résolutions gratuites par jour</li>
|
264 |
+
<li><i class="fas fa-check-circle"></i> Explication des étapes de résolution</li>
|
265 |
+
<li><i class="fas fa-times-circle"></i> <span style="color: #999;">Mode d'exécution de code avancé (version Pro)</span></li>
|
266 |
+
<li><i class="fas fa-times-circle"></i> <span style="color: #999;">Résolutions illimitées (version Pro)</span></li>
|
267 |
+
<li><i class="fas fa-times-circle"></i> <span style="color: #999;">Support prioritaire (version Pro)</span></li>
|
268 |
+
</ul>
|
269 |
+
</div>
|
270 |
+
|
271 |
+
<div class="upload-section">
|
272 |
+
<form id="imageForm" enctype="multipart/form-data">
|
273 |
+
<input type="file" id="imageInput" name="image" accept="image/*" style="display: none;">
|
274 |
+
<button type="button" id="uploadButton" class="cta-button" onclick="document.getElementById('imageInput').click()">
|
275 |
+
<i class="fas fa-upload"></i> Télécharger une image
|
276 |
+
</button>
|
277 |
+
</form>
|
278 |
+
|
279 |
+
<p id="uploadStatus"></p>
|
280 |
+
<div id="imagePreview" style="display: none; margin: 20px auto; max-width: 500px;">
|
281 |
+
<img id="preview" style="width: 100%; border-radius: 8px; box-shadow: var(--box-shadow);">
|
282 |
+
</div>
|
283 |
+
|
284 |
+
<button id="solveButton" class="cta-button" style="display: none; background-color: var(--secondary-color);">
|
285 |
+
<i class="fas fa-calculator"></i> Résoudre ce problème
|
286 |
+
</button>
|
287 |
+
</div>
|
288 |
|
289 |
+
<div id="solutionOutput" style="margin-top: 30px; text-align: left; display: none;">
|
290 |
+
<h3>Solution :</h3>
|
291 |
+
<div id="loadingIndicator" class="thinking-indicator" style="display: none;">
|
292 |
+
<i class="fas fa-brain indicator-icon"></i>
|
293 |
+
<span>Je réfléchis au problème...</span>
|
294 |
+
</div>
|
295 |
+
<div id="solution" style="background: #fff; padding: 20px; border-radius: 8px;"></div>
|
296 |
+
</div>
|
297 |
+
|
298 |
+
<div class="upgrade-section">
|
299 |
+
<h2>Besoin de plus de puissance ?</h2>
|
300 |
+
<p>Passez à la version Pro pour des fonctionnalités avancées et des résolutions illimitées.</p>
|
301 |
+
<a href="#" class="cta-button">Passer à la version Pro</a>
|
302 |
+
</div>
|
303 |
+
</div>
|
304 |
+
|
305 |
+
<footer>
|
306 |
+
<p>© 2025 Math Solver. Tous droits réservés.</p>
|
307 |
+
</footer>
|
308 |
</div>
|
309 |
+
|
310 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
311 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/python.min.js"></script>
|
312 |
+
|
313 |
+
<!-- MathJax Configuration -->
|
314 |
+
<script>
|
315 |
+
window.MathJax = {
|
316 |
+
tex: {
|
317 |
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
318 |
+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
|
319 |
+
processEscapes: true,
|
320 |
+
processEnvironments: true,
|
321 |
+
packages: {'[+]': ['ams', 'noerrors', 'physics', 'cancel', 'color', 'mhchem', 'mathtools']}
|
322 |
+
},
|
323 |
+
options: {
|
324 |
+
enableMenu: false, // Disable menu
|
325 |
+
ignoreHtmlClass: 'code-content', // Don't process code blocks
|
326 |
+
processHtmlClass: 'step-section|latex-display', // Only process these classes
|
327 |
+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'] // Skip these tags
|
328 |
+
},
|
329 |
+
loader: {
|
330 |
+
load: ['[tex]/ams', '[tex]/noerrors', '[tex]/physics', '[tex]/cancel', '[tex]/color', '[tex]/mhchem', '[tex]/mathtools']
|
331 |
+
},
|
332 |
+
svg: {
|
333 |
+
fontCache: 'global'
|
334 |
+
}
|
335 |
+
};
|
336 |
+
</script>
|
337 |
+
<!-- Load MathJax library -->
|
338 |
+
<script id="MathJax-script" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.js"></script>
|
339 |
+
|
340 |
+
<script>
|
341 |
+
document.getElementById('imageInput').addEventListener('change', function(event) {
|
342 |
+
const file = event.target.files[0];
|
343 |
+
if (file) {
|
344 |
+
const reader = new FileReader();
|
345 |
+
reader.onload = function(e) {
|
346 |
+
document.getElementById('preview').src = e.target.result;
|
347 |
+
document.getElementById('imagePreview').style.display = 'block';
|
348 |
+
document.getElementById('solveButton').style.display = 'inline-block';
|
349 |
+
document.getElementById('uploadStatus').textContent = `Image sélectionnée : ${file.name}`;
|
350 |
+
}
|
351 |
+
reader.readAsDataURL(file);
|
352 |
+
}
|
353 |
+
});
|
354 |
+
|
355 |
+
document.getElementById('solveButton').addEventListener('click', function() {
|
356 |
+
const formData = new FormData(document.getElementById('imageForm'));
|
357 |
+
const solutionOutput = document.getElementById('solutionOutput');
|
358 |
+
const loadingIndicator = document.getElementById('loadingIndicator');
|
359 |
+
const solution = document.getElementById('solution');
|
360 |
+
|
361 |
+
solutionOutput.style.display = 'block';
|
362 |
+
loadingIndicator.style.display = 'flex';
|
363 |
+
solution.innerHTML = ''; // Clear previous solution
|
364 |
+
|
365 |
+
fetch('/solved', {
|
366 |
+
method: 'POST',
|
367 |
+
body: formData
|
368 |
+
})
|
369 |
+
.then(response => {
|
370 |
+
const reader = response.body.getReader();
|
371 |
+
const decoder = new TextDecoder();
|
372 |
+
let buffer = '';
|
373 |
+
|
374 |
+
function processStream({ done, value }) {
|
375 |
+
if (done) {
|
376 |
+
loadingIndicator.style.display = 'none';
|
377 |
+
// Optional: Final typeset on the whole container if needed, but per-chunk should be enough
|
378 |
+
// MathJax.typesetPromise([solution]).catch(e => console.error('Final MathJax typesetting error:', e));
|
379 |
+
return;
|
380 |
+
}
|
381 |
+
|
382 |
+
buffer += decoder.decode(value, { stream: true });
|
383 |
+
// Split by two newlines to get distinct chunks from the stream
|
384 |
+
const lines = buffer.split('\n\n');
|
385 |
+
buffer = lines.pop(); // Keep the last potentially incomplete chunk
|
386 |
+
|
387 |
+
for (const line of lines) {
|
388 |
+
if (line.startsWith('data: ')) {
|
389 |
+
try {
|
390 |
+
const data = JSON.parse(line.substr(6));
|
391 |
+
|
392 |
+
if (data.mode) {
|
393 |
+
// Update loading indicator based on mode
|
394 |
+
if (data.mode === 'thinking') {
|
395 |
+
loadingIndicator.className = 'thinking-indicator';
|
396 |
+
loadingIndicator.innerHTML = '<i class="fas fa-brain indicator-icon"></i><span>Je réfléchis au problème...</span>';
|
397 |
+
} else if (data.mode === 'answering') {
|
398 |
+
loadingIndicator.className = 'answering-indicator';
|
399 |
+
loadingIndicator.innerHTML = '<i class="fas fa-pencil-alt indicator-icon"></i><span>Rédaction de la solution...</span>';
|
400 |
+
} else if (data.mode === 'executing_code') {
|
401 |
+
loadingIndicator.className = 'executing-indicator';
|
402 |
+
loadingIndicator.innerHTML = '<i class="fas fa-code indicator-icon"></i><span>Exécution de code pour la résolution...</span>';
|
403 |
+
} else if (data.mode === 'code_result') {
|
404 |
+
loadingIndicator.className = 'executing-indicator';
|
405 |
+
loadingIndicator.innerHTML = '<i class="fas fa-terminal indicator-icon"></i><span>Traitement des résultats...</span>';
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
if (data.content) {
|
410 |
+
const content = data.content;
|
411 |
+
|
412 |
+
// Create a container for this new content chunk
|
413 |
+
const contentContainer = document.createElement('div');
|
414 |
+
|
415 |
+
if (content.includes('```python')) {
|
416 |
+
// Code block
|
417 |
+
const codeHtml = content.replace(/```python\n([\s\S]*?)\n```/g, function(match, p1) {
|
418 |
+
// Use <pre> and <code> for Highlight.js
|
419 |
+
return `<div class="code-section">
|
420 |
+
<div class="code-header">
|
421 |
+
<span>Code Python</span>
|
422 |
+
</div>
|
423 |
+
<pre class="code-content"><code class="language-python">${p1}</code></pre>
|
424 |
+
</div>`;
|
425 |
+
});
|
426 |
+
contentContainer.innerHTML = codeHtml;
|
427 |
+
solution.appendChild(contentContainer);
|
428 |
+
// Apply syntax highlighting
|
429 |
+
contentContainer.querySelectorAll('pre code').forEach((block) => {
|
430 |
+
hljs.highlightElement(block);
|
431 |
+
});
|
432 |
+
} else if (content.includes('Résultat d\'exécution:')) {
|
433 |
+
// Code output block
|
434 |
+
const outputHtml = content.replace(/Résultat d'exécution:\n```\n([\s\S]*?)\n```/g, function(match, p1) {
|
435 |
+
return `<div class="output-section">${p1}</div>`;
|
436 |
+
});
|
437 |
+
contentContainer.innerHTML = outputHtml;
|
438 |
+
solution.appendChild(contentContainer);
|
439 |
+
} else {
|
440 |
+
// Regular text, might contain LaTeX.
|
441 |
+
// Add a class that MathJax is configured to process.
|
442 |
+
contentContainer.className = 'step-section';
|
443 |
+
contentContainer.innerHTML = content;
|
444 |
+
solution.appendChild(contentContainer);
|
445 |
+
|
446 |
+
// Tell MathJax to process the newly added content container
|
447 |
+
// MathJax.typesetPromise takes an array of elements or element IDs.
|
448 |
+
MathJax.typesetPromise([contentContainer]).catch(e => console.error('MathJax typesetting error:', e));
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
if (data.error) {
|
453 |
+
const errorDiv = document.createElement('div');
|
454 |
+
errorDiv.style.color = 'red';
|
455 |
+
errorDiv.style.margin = '15px 0';
|
456 |
+
errorDiv.style.padding = '10px';
|
457 |
+
errorDiv.style.background = '#ffeeee';
|
458 |
+
errorDiv.style.borderRadius = '5px';
|
459 |
+
errorDiv.textContent = `Erreur: ${data.error}`;
|
460 |
+
solution.appendChild(errorDiv);
|
461 |
+
loadingIndicator.style.display = 'none'; // Hide loading on error
|
462 |
+
}
|
463 |
+
} catch (e) {
|
464 |
+
console.error('Error parsing JSON from stream:', e, line);
|
465 |
+
}
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
// Scroll to bottom as new content arrives
|
470 |
+
window.scrollTo(0, document.body.scrollHeight);
|
471 |
+
|
472 |
+
// Read the next chunk from the stream
|
473 |
+
return reader.read().then(processStream);
|
474 |
+
}
|
475 |
+
|
476 |
+
// Start reading the stream
|
477 |
+
return reader.read().then(processStream);
|
478 |
+
})
|
479 |
+
.catch(error => {
|
480 |
+
const errorDiv = document.createElement('div');
|
481 |
+
errorDiv.style.color = 'red';
|
482 |
+
errorDiv.style.margin = '15px 0';
|
483 |
+
errorDiv.style.padding = '10px';
|
484 |
+
errorDiv.style.background = '#ffeeee';
|
485 |
+
errorDiv.style.borderRadius = '5px';
|
486 |
+
errorDiv.textContent = `Erreur de connexion ou du serveur: ${error}`;
|
487 |
+
solution.appendChild(errorDiv);
|
488 |
+
loadingIndicator.style.display = 'none'; // Hide loading on fetch error
|
489 |
+
console.error('Fetch error:', error);
|
490 |
+
});
|
491 |
+
});
|
492 |
+
</script>
|
493 |
</body>
|
494 |
+
</html>
|