Spaces:
Running
Running
Update templates/philosophie.html
Browse files- templates/philosophie.html +156 -1000
templates/philosophie.html
CHANGED
@@ -1,1023 +1,179 @@
|
|
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>
|
7 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
8 |
-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
|
9 |
-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
|
10 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.7.3/sweetalert2.all.min.js"></script>
|
11 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.3.0/marked.min.js"></script>
|
12 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
|
13 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/locale/fr.js"></script>
|
14 |
-
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.7.3/sweetalert2.min.css" rel="stylesheet">
|
15 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
16 |
-
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
|
17 |
-
<style>
|
18 |
-
/* Styles pour le Glow Up */
|
19 |
-
:root {
|
20 |
-
font-family: 'Inter', sans-serif;
|
21 |
-
--transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
22 |
-
--transition-fast: all 0.15s ease-out;
|
23 |
-
--violet-gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #c084fc 100%);
|
24 |
-
}
|
25 |
-
|
26 |
-
html {
|
27 |
-
scroll-behavior: smooth;
|
28 |
-
-webkit-overflow-scrolling: touch;
|
29 |
-
}
|
30 |
-
|
31 |
-
body {
|
32 |
-
will-change: scroll-position;
|
33 |
-
-webkit-font-smoothing: antialiased;
|
34 |
-
-moz-osx-font-smoothing: grayscale;
|
35 |
-
}
|
36 |
-
|
37 |
-
/* Loader magnifique avec animations */
|
38 |
-
.progress-container {
|
39 |
-
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
40 |
-
border: 2px solid #e2e8f0;
|
41 |
-
position: relative;
|
42 |
-
overflow: hidden;
|
43 |
-
}
|
44 |
-
|
45 |
-
.progress-container::before {
|
46 |
-
content: '';
|
47 |
-
position: absolute;
|
48 |
-
top: 0;
|
49 |
-
left: -100%;
|
50 |
-
width: 100%;
|
51 |
-
height: 100%;
|
52 |
-
background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.1), transparent);
|
53 |
-
animation: shimmer 2s infinite;
|
54 |
-
}
|
55 |
-
|
56 |
-
@keyframes shimmer {
|
57 |
-
0% { left: -100%; }
|
58 |
-
100% { left: 100%; }
|
59 |
-
}
|
60 |
-
|
61 |
-
.progress-bar {
|
62 |
-
background: var(--violet-gradient);
|
63 |
-
height: 100%;
|
64 |
-
transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
|
65 |
-
position: relative;
|
66 |
-
overflow: hidden;
|
67 |
-
box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
|
68 |
-
}
|
69 |
-
|
70 |
-
.progress-bar::after {
|
71 |
-
content: '';
|
72 |
-
position: absolute;
|
73 |
-
top: 0;
|
74 |
-
left: 0;
|
75 |
-
right: 0;
|
76 |
-
bottom: 0;
|
77 |
-
background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.3) 50%, transparent 70%);
|
78 |
-
animation: progressGlow 2s ease-in-out infinite;
|
79 |
-
}
|
80 |
-
|
81 |
-
@keyframes progressGlow {
|
82 |
-
0%, 100% { transform: translateX(-100%) skewX(-15deg); }
|
83 |
-
50% { transform: translateX(200%) skewX(-15deg); }
|
84 |
-
}
|
85 |
-
|
86 |
-
.loading-dots {
|
87 |
-
display: inline-flex;
|
88 |
-
align-items: center;
|
89 |
-
}
|
90 |
-
|
91 |
-
.loading-dots span {
|
92 |
-
width: 8px;
|
93 |
-
height: 8px;
|
94 |
-
border-radius: 50%;
|
95 |
-
background: #8b5cf6;
|
96 |
-
margin: 0 2px;
|
97 |
-
animation: loadingDots 1.4s infinite ease-in-out both;
|
98 |
-
}
|
99 |
-
|
100 |
-
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
|
101 |
-
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
|
102 |
-
|
103 |
-
@keyframes loadingDots {
|
104 |
-
0%, 80%, 100% {
|
105 |
-
transform: scale(0.8);
|
106 |
-
opacity: 0.5;
|
107 |
-
}
|
108 |
-
40% {
|
109 |
-
transform: scale(1.2);
|
110 |
-
opacity: 1;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
/* Animation de fondu pour le streaming */
|
115 |
-
.streaming-text {
|
116 |
-
opacity: 0;
|
117 |
-
animation: fadeInUp 0.6s ease-out forwards;
|
118 |
-
}
|
119 |
-
|
120 |
-
@keyframes fadeInUp {
|
121 |
-
from {
|
122 |
-
opacity: 0;
|
123 |
-
transform: translateY(20px);
|
124 |
-
}
|
125 |
-
to {
|
126 |
-
opacity: 1;
|
127 |
-
transform: translateY(0);
|
128 |
-
}
|
129 |
-
}
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
opacity: 0;
|
134 |
-
animation: wordFadeIn 0.3s ease-out forwards;
|
135 |
-
}
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
transform: translateY(10px) scale(0.95);
|
141 |
-
}
|
142 |
-
to {
|
143 |
-
opacity: 1;
|
144 |
-
transform: translateY(0) scale(1);
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
/* Pulse effect pour le contenu en cours de génération */
|
149 |
-
.generating-pulse {
|
150 |
-
animation: pulseGlow 2s ease-in-out infinite;
|
151 |
-
}
|
152 |
-
|
153 |
-
@keyframes pulseGlow {
|
154 |
-
0%, 100% {
|
155 |
-
box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
|
156 |
-
transform: scale(1);
|
157 |
-
}
|
158 |
-
50% {
|
159 |
-
box-shadow: 0 0 30px rgba(139, 92, 246, 0.2);
|
160 |
-
transform: scale(1.01);
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
/* Styles pour le texte en cours de streaming */
|
165 |
-
.streaming-cursor::after {
|
166 |
-
content: '|';
|
167 |
-
animation: cursorBlink 1s infinite;
|
168 |
-
color: #8b5cf6;
|
169 |
-
margin-left: 2px;
|
170 |
-
}
|
171 |
-
|
172 |
-
@keyframes cursorBlink {
|
173 |
-
0%, 50% { opacity: 1; }
|
174 |
-
51%, 100% { opacity: 0; }
|
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 |
-
|
215 |
-
.
|
216 |
-
|
217 |
-
}
|
218 |
-
|
219 |
-
.prose h1, .prose h2, .prose h3 {
|
220 |
-
margin-top: 1.5em;
|
221 |
-
margin-bottom: 0.8em;
|
222 |
-
line-height: 1.3;
|
223 |
-
}
|
224 |
-
|
225 |
-
.animate-fadeIn {
|
226 |
-
animation: fadeIn 0.4s ease-out forwards;
|
227 |
-
transform: translateZ(0);
|
228 |
-
will-change: opacity, transform;
|
229 |
-
}
|
230 |
-
|
231 |
-
@keyframes fadeIn {
|
232 |
-
from {
|
233 |
-
opacity: 0;
|
234 |
-
transform: translateY(15px) translateZ(0);
|
235 |
-
}
|
236 |
-
to {
|
237 |
-
opacity: 1;
|
238 |
-
transform: translateY(0) translateZ(0);
|
239 |
-
}
|
240 |
-
}
|
241 |
-
|
242 |
-
.select2-container--default .select2-selection--single {
|
243 |
-
border: 1px solid #d1d5db;
|
244 |
-
border-radius: 0.75rem;
|
245 |
-
height: auto;
|
246 |
-
padding: 0.75rem 1rem;
|
247 |
-
background-color: white;
|
248 |
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
249 |
-
}
|
250 |
-
|
251 |
-
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
252 |
-
color: #111827;
|
253 |
-
line-height: inherit;
|
254 |
-
padding-right: 1.5rem;
|
255 |
-
}
|
256 |
-
|
257 |
-
.select2-results__option .course-author {
|
258 |
-
font-size: 0.875rem;
|
259 |
-
color: #6b7280;
|
260 |
-
display: block;
|
261 |
-
margin-top: 0.1rem;
|
262 |
-
}
|
263 |
-
|
264 |
-
.select2-dropdown {
|
265 |
-
border-radius: 0.75rem;
|
266 |
-
border: 1px solid #d1d5db;
|
267 |
-
box-shadow: 0 4px 6px -1px rgba(0,0,0,.1);
|
268 |
-
}
|
269 |
-
|
270 |
-
#image-preview {
|
271 |
-
max-height: 200px;
|
272 |
-
border-radius: 0.75rem;
|
273 |
-
box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
|
274 |
-
}
|
275 |
-
|
276 |
-
summary {
|
277 |
-
list-style: none;
|
278 |
-
}
|
279 |
-
|
280 |
-
summary::-webkit-details-marker {
|
281 |
-
display: none;
|
282 |
-
}
|
283 |
-
|
284 |
-
@media (max-width: 640px) {
|
285 |
-
.max-w-3xl {
|
286 |
-
max-width: 100%;
|
287 |
-
margin-left: 0.5rem;
|
288 |
-
margin-right: 0.5rem;
|
289 |
-
}
|
290 |
-
|
291 |
-
#response, #thinking-wrapper {
|
292 |
-
overflow-x: hidden;
|
293 |
-
}
|
294 |
-
|
295 |
-
.prose {
|
296 |
-
font-size: 0.95rem;
|
297 |
-
line-height: 1.6;
|
298 |
-
}
|
299 |
-
|
300 |
-
.animate-fadeIn {
|
301 |
-
animation-duration: 0.2s;
|
302 |
-
}
|
303 |
-
}
|
304 |
-
|
305 |
-
.generation-container {
|
306 |
-
contain: layout style;
|
307 |
-
transform: translateZ(0);
|
308 |
-
}
|
309 |
-
|
310 |
-
textarea {
|
311 |
-
resize: none;
|
312 |
-
-webkit-appearance: none;
|
313 |
-
}
|
314 |
-
|
315 |
-
button {
|
316 |
-
touch-action: manipulation;
|
317 |
-
-webkit-tap-highlight-color: transparent;
|
318 |
-
transition: var(--transition-fast);
|
319 |
-
}
|
320 |
-
|
321 |
-
.content-scrollable {
|
322 |
-
-webkit-overflow-scrolling: touch;
|
323 |
-
scroll-behavior: smooth;
|
324 |
-
}
|
325 |
</style>
|
326 |
</head>
|
327 |
-
<body
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
</
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
<p class="mt-2 text-md text-gray-600">Créez des dissertations et analyses pertinentes et structurées.</p>
|
355 |
-
</div>
|
356 |
-
</div>
|
357 |
-
|
358 |
-
<div class="p-6 sm:p-8 border-t border-gray-200 space-y-6">
|
359 |
-
<!-- Type Selection -->
|
360 |
-
<div class="space-y-2">
|
361 |
-
<label for="type-select" class="block text-sm font-medium text-gray-700">Type de travail</label>
|
362 |
-
<select id="type-select" class="w-full rounded-xl border-gray-300 shadow-sm focus:border-violet-500 focus:ring-violet-500 bg-white py-3 px-4">
|
363 |
-
<option value="1">Sujet Type 1</option>
|
364 |
-
<option value="2">Sujet Type 2 (Citation)</option>
|
365 |
-
<option value="3">Sujet Type 3</option>
|
366 |
-
</select>
|
367 |
-
</div>
|
368 |
-
|
369 |
-
<!-- Conteneur pour les champs texte -->
|
370 |
-
<div id="text-input-container">
|
371 |
-
<!-- Course Selection -->
|
372 |
-
<div class="space-y-2">
|
373 |
-
<label for="course-select" class="block text-sm font-medium text-gray-700">Utiliser un cours comme contexte</label>
|
374 |
-
<select id="course-select" class="w-full">
|
375 |
-
<option value="">Choisir un cours...</option>
|
376 |
-
</select>
|
377 |
-
</div>
|
378 |
-
<!-- Question Input -->
|
379 |
-
<div class="space-y-2 mt-4">
|
380 |
-
<label for="question" class="block text-sm font-medium text-gray-700">Sujet de dissertation</label>
|
381 |
-
<textarea id="question" rows="4" class="w-full rounded-xl border-gray-300 shadow-sm focus:border-violet-500 focus:ring-violet-500 resize-none bg-white py-3 px-4" placeholder="Saisissez votre sujet de dissertation... ex: 'La liberté consiste-t-elle à faire tout ce que l'on veut ?'"></textarea>
|
382 |
-
</div>
|
383 |
-
</div>
|
384 |
-
|
385 |
-
<!-- Conteneur pour l'upload d'image -->
|
386 |
-
<div id="image-input-container" class="hidden">
|
387 |
-
<div class="space-y-2">
|
388 |
-
<label for="image-upload" class="block text-sm font-medium text-gray-700">Charger un document pour analyse</label>
|
389 |
-
<input type="file" id="image-upload" accept="image/jpeg, image/png, image/webp" class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-violet-50 file:text-violet-700 hover:file:bg-violet-100 cursor-pointer"/>
|
390 |
-
<div class="mt-4 flex justify-center"><img id="image-preview" src="" alt="Aperçu de l'image" class="hidden"/></div>
|
391 |
-
</div>
|
392 |
-
</div>
|
393 |
-
|
394 |
-
<!-- Submit Button -->
|
395 |
-
<div class="pt-4">
|
396 |
-
<button id="submit-btn" class="w-full flex items-center justify-center py-3.5 px-6 rounded-xl bg-violet-600 text-white font-semibold shadow-md shadow-violet-200 hover:bg-violet-700 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:ring-offset-2">
|
397 |
-
<svg class="h-5 w-5 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 000-1.5h-3.25V5z" clip-rule="evenodd" /></svg>
|
398 |
-
Générer la dissertation
|
399 |
-
</button>
|
400 |
-
</div>
|
401 |
</div>
|
|
|
402 |
</div>
|
403 |
|
404 |
-
|
405 |
-
<
|
406 |
-
<div class="bg-white border border-gray-200 rounded-xl shadow-lg p-8 generating-pulse">
|
407 |
-
<div class="text-center space-y-6">
|
408 |
-
<div class="mx-auto w-16 h-16 relative">
|
409 |
-
<svg class="w-16 h-16 text-violet-600 animate-spin" fill="none" viewBox="0 0 24 24">
|
410 |
-
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
411 |
-
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
412 |
-
</svg>
|
413 |
-
</div>
|
414 |
-
|
415 |
-
<div class="space-y-3">
|
416 |
-
<h3 class="text-xl font-semibold text-gray-800">Génération en cours</h3>
|
417 |
-
<p id="loading-message" class="text-gray-600">Initialisation de l'IA philosophique</p>
|
418 |
-
<div class="loading-dots">
|
419 |
-
<span></span>
|
420 |
-
<span></span>
|
421 |
-
<span></span>
|
422 |
-
</div>
|
423 |
-
</div>
|
424 |
-
|
425 |
-
<!-- Barre de progression -->
|
426 |
-
<div class="space-y-2">
|
427 |
-
<div class="flex justify-between text-sm text-gray-600">
|
428 |
-
<span>Progression</span>
|
429 |
-
<span id="progress-percentage">0%</span>
|
430 |
-
</div>
|
431 |
-
<div class="progress-container w-full h-3 rounded-full">
|
432 |
-
<div id="progress-bar" class="progress-bar w-0 rounded-full"></div>
|
433 |
-
</div>
|
434 |
-
</div>
|
435 |
-
</div>
|
436 |
-
</div>
|
437 |
-
</div>
|
438 |
-
|
439 |
-
<!-- Thinking Process Section -->
|
440 |
-
<div id="thinking-wrapper" class="hidden mt-8 generation-container">
|
441 |
-
<details id="thinking-container" class="bg-white border border-gray-200 rounded-xl shadow-sm">
|
442 |
-
<summary class="flex justify-between items-center p-4 cursor-pointer">
|
443 |
-
<h3 class="text-md font-semibold text-gray-700">Processus de pensée de l'IA</h3>
|
444 |
-
<svg class="h-5 w-5 text-gray-500 transition-transform transform open:rotate-180" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
445 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
446 |
-
</svg>
|
447 |
-
</summary>
|
448 |
-
<div id="thinking-process" class="p-4 border-t border-gray-200 text-sm text-gray-600 prose prose-sm max-w-none max-h-64 overflow-y-auto content-scrollable">
|
449 |
-
</div>
|
450 |
-
</details>
|
451 |
-
</div>
|
452 |
-
|
453 |
-
<!-- Response Section -->
|
454 |
-
<div id="response" class="hidden mt-6 generation-container">
|
455 |
-
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 sm:p-8 prose prose-violet max-w-none">
|
456 |
-
</div>
|
457 |
-
</div>
|
458 |
-
|
459 |
-
<!-- Action Buttons -->
|
460 |
-
<div id="action-buttons" class="hidden mt-6 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
461 |
-
<button id="copy-btn" class="w-full flex items-center justify-center py-3 px-6 rounded-xl bg-gray-100 text-gray-800 font-medium border border-gray-200 hover:bg-gray-200 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2">
|
462 |
-
<svg class="h-5 w-5 mr-2" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75" /></svg>
|
463 |
-
Copier le texte
|
464 |
-
</button>
|
465 |
-
</div>
|
466 |
|
467 |
-
|
468 |
-
|
469 |
-
<h3 class="text-xl font-bold text-gray-800 mb-4">Historique</h3>
|
470 |
-
<div id="dissertations-list" class="space-y-3">
|
471 |
-
</div>
|
472 |
</div>
|
473 |
</div>
|
474 |
-
</
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
placeholder: 'Optionnel : choisir un cours...',
|
487 |
-
allowClear: true,
|
488 |
-
templateResult: function (course) {
|
489 |
-
if (!course.id) { return course.text; }
|
490 |
-
return $(`<span>${course.text}</span><span class="course-author">Pr. ${$(course.element).data('author')}</span>`);
|
491 |
-
},
|
492 |
-
templateSelection: function (course) { return course.text; },
|
493 |
-
});
|
494 |
-
marked.setOptions({ breaks: true, gfm: true, headerIds: false, mangle: false });
|
495 |
-
moment.locale('fr');
|
496 |
-
const Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 3000, timerProgressBar: true });
|
497 |
-
|
498 |
-
// Variables pour le loader et streaming
|
499 |
-
let currentProgress = 0;
|
500 |
-
let progressInterval;
|
501 |
-
let streamingTimeout;
|
502 |
-
|
503 |
-
// Messages de chargement rotatifs
|
504 |
-
const loadingMessages = [
|
505 |
-
"Initialisation de l'IA philosophique",
|
506 |
-
"Analyse du sujet proposé",
|
507 |
-
"Recherche des concepts clés",
|
508 |
-
"Construction de l'argumentation",
|
509 |
-
"Structuration de la dissertation",
|
510 |
-
"Vérification de la cohérence",
|
511 |
-
"Finalisation de la réponse"
|
512 |
-
];
|
513 |
-
|
514 |
-
// Fonction pour simuler le progress loader
|
515 |
-
function startProgressLoader() {
|
516 |
-
currentProgress = 0;
|
517 |
-
let messageIndex = 0;
|
518 |
-
|
519 |
-
$('#loading-section').removeClass('hidden').addClass('animate-fadeIn');
|
520 |
-
$('#progress-bar').css('width', '0%');
|
521 |
-
$('#progress-percentage').text('0%');
|
522 |
-
|
523 |
-
// Animation du message
|
524 |
-
const messageInterval = setInterval(() => {
|
525 |
-
$('#loading-message').fadeOut(300, function() {
|
526 |
-
$(this).text(loadingMessages[messageIndex]).fadeIn(300);
|
527 |
-
messageIndex = (messageIndex + 1) % loadingMessages.length;
|
528 |
-
});
|
529 |
-
}, 2000);
|
530 |
-
|
531 |
-
// Animation de la barre de progression
|
532 |
-
progressInterval = setInterval(() => {
|
533 |
-
if (currentProgress < 95) {
|
534 |
-
// Progression plus rapide au début, plus lente vers la fin
|
535 |
-
const increment = currentProgress < 30 ? Math.random() * 8 + 3 :
|
536 |
-
currentProgress < 60 ? Math.random() * 4 + 2 :
|
537 |
-
Math.random() * 2 + 0.5;
|
538 |
-
|
539 |
-
currentProgress = Math.min(currentProgress + increment, 95);
|
540 |
-
updateProgressBar(currentProgress);
|
541 |
-
}
|
542 |
-
}, 300);
|
543 |
-
|
544 |
-
// Nettoyer après 30 secondes max
|
545 |
-
setTimeout(() => {
|
546 |
-
clearInterval(messageInterval);
|
547 |
-
clearInterval(progressInterval);
|
548 |
-
completeProgress();
|
549 |
-
}, 30000);
|
550 |
-
}
|
551 |
-
|
552 |
-
function updateProgressBar(progress) {
|
553 |
-
$('#progress-bar').css('width', progress + '%');
|
554 |
-
$('#progress-percentage').text(Math.round(progress) + '%');
|
555 |
-
}
|
556 |
-
|
557 |
-
function completeProgress() {
|
558 |
-
clearInterval(progressInterval);
|
559 |
-
currentProgress = 100;
|
560 |
-
updateProgressBar(100);
|
561 |
-
|
562 |
-
setTimeout(() => {
|
563 |
-
$('#loading-section').fadeOut(500, function() {
|
564 |
-
startStreamingDisplay();
|
565 |
-
});
|
566 |
-
}, 800);
|
567 |
-
}
|
568 |
-
|
569 |
-
// Fonction pour démarrer l'affichage en streaming avec effet de fondu
|
570 |
-
function startStreamingDisplay() {
|
571 |
-
// Simuler des données reçues (remplacer par vraies données de l'API)
|
572 |
-
simulateStreamingData();
|
573 |
-
}
|
574 |
-
|
575 |
-
// Simulation du streaming avec de vraies données (remplacer par l'appel API réel)
|
576 |
-
function simulateStreamingData() {
|
577 |
-
// Exemple de données - remplacer par les vraies données de votre API
|
578 |
-
const sampleThinking = `## Analyse du sujet
|
579 |
-
|
580 |
-
Le sujet "La liberté consiste-t-elle à faire tout ce que l'on veut ?" interroge la nature même de la liberté. Il faut distinguer entre liberté et licence, entre pouvoir et droit.
|
581 |
-
|
582 |
-
## Plan envisagé
|
583 |
-
1. La liberté comme absence de contraintes
|
584 |
-
2. Les limites nécessaires à la liberté
|
585 |
-
3. La liberté authentique comme autodétermination`;
|
586 |
-
|
587 |
-
const sampleResponse = `# La liberté consiste-t-elle à faire tout ce que l'on veut ?
|
588 |
-
|
589 |
-
## Introduction
|
590 |
-
|
591 |
-
La question de la liberté traverse toute l'histoire de la philosophie. À première vue, être libre semble signifier pouvoir agir selon ses désirs, sans contrainte. Cependant, cette conception spontanée de la liberté pose problème : peut-on vraiment identifier liberté et licence ? La liberté véritable ne suppose-t-elle pas au contraire certaines limites ?
|
592 |
-
|
593 |
-
## I. La liberté comme absence de contraintes
|
594 |
-
|
595 |
-
### A. La conception commune de la liberté
|
596 |
-
|
597 |
-
Dans l'usage courant, être libre c'est faire ce que l'on veut, quand on le veut. Cette conception négative de la liberté la définit par l'absence d'obstacles extérieurs à nos actions.
|
598 |
-
|
599 |
-
### B. La liberté naturelle selon Hobbes
|
600 |
-
|
601 |
-
Thomas Hobbes définit la liberté comme "l'absence d'obstacles extérieurs". Dans l'état de nature, chaque individu a le droit à tout, y compris au corps d'autrui.
|
602 |
-
|
603 |
-
## II. Les limites nécessaires à la liberté
|
604 |
-
|
605 |
-
### A. La liberté des uns s'arrête où commence celle des autres
|
606 |
-
|
607 |
-
John Stuart Mill, dans "De la liberté", établit le principe de non-nuisance : ma liberté ne doit pas porter atteinte à celle d'autrui.
|
608 |
-
|
609 |
-
### B. Les contraintes comme conditions de la liberté
|
610 |
-
|
611 |
-
Paradoxalement, certaines contraintes peuvent être libératrices. Les règles du jeu au tennis ne limitent pas le joueur, elles rendent le jeu possible.
|
612 |
-
|
613 |
-
## III. La liberté authentique comme autodétermination
|
614 |
-
|
615 |
-
### A. La liberté selon Kant
|
616 |
-
|
617 |
-
Pour Kant, la vraie liberté n'est pas de suivre ses inclinations, mais d'agir selon des principes rationnels que l'on s'est donnés à soi-même.
|
618 |
-
|
619 |
-
### B. L'autonomie comme essence de la liberté
|
620 |
-
|
621 |
-
Être libre, c'est être autonome, c'est-à-dire se donner ses propres lois. Cela implique une maîtrise de soi et une réflexion sur ses actes.
|
622 |
-
|
623 |
-
## Conclusion
|
624 |
-
|
625 |
-
La liberté ne peut se réduire à la simple capacité de faire tout ce que l'on veut. Une telle conception conduirait au chaos et à la négation même de la liberté. La véritable liberté réside dans l'autodétermination rationnelle, dans la capacité à agir selon des principes que l'on s'est librement choisis. Ainsi, les contraintes ne s'opposent pas nécessairement à la liberté ; elles peuvent même la rendre possible.`;
|
626 |
-
|
627 |
-
// Démarrer le streaming avec effet de fondu
|
628 |
-
startWordByWordStreaming(sampleThinking, sampleResponse);
|
629 |
-
}
|
630 |
-
|
631 |
-
// Fonction pour l'affichage mot par mot avec effet de fondu
|
632 |
-
function startWordByWordStreaming(thinkingText, responseText) {
|
633 |
-
// Afficher d'abord la section de pensée
|
634 |
-
$('#thinking-wrapper').removeClass('hidden').addClass('animate-fadeIn');
|
635 |
-
streamTextWordByWord('#thinking-process', thinkingText, 50, () => {
|
636 |
-
// Une fois la pensée terminée, afficher la réponse
|
637 |
-
$('#response').removeClass('hidden').addClass('animate-fadeIn');
|
638 |
-
streamTextWordByWord('#response > div', responseText, 30, () => {
|
639 |
-
// Une fois terminé, afficher les boutons d'action
|
640 |
-
$('#action-buttons').removeClass('hidden').addClass('animate-fadeIn');
|
641 |
-
Toast.fire({ icon: 'success', title: 'Génération terminée !' });
|
642 |
-
|
643 |
-
// Sauvegarder la dissertation
|
644 |
-
let title;
|
645 |
-
if ($('#type-select').val() === '3') {
|
646 |
-
const fileName = $('#image-upload')[0].files[0]?.name || "Analyse de document";
|
647 |
-
title = `Analyse (Sujet Type 3): ${fileName}`;
|
648 |
-
} else {
|
649 |
-
title = $('#question').val().trim();
|
650 |
-
}
|
651 |
-
saveDissertation(title, responseText);
|
652 |
-
});
|
653 |
-
});
|
654 |
-
}
|
655 |
-
|
656 |
-
// Fonction pour streamer le texte mot par mot
|
657 |
-
function streamTextWordByWord(selector, text, delay = 50, callback) {
|
658 |
-
const container = $(selector);
|
659 |
-
container.empty();
|
660 |
-
|
661 |
-
// Convertir le markdown en HTML
|
662 |
-
const htmlContent = marked.parse(text);
|
663 |
-
|
664 |
-
// Créer un élément temporaire pour extraire le texte
|
665 |
-
const tempDiv = $('<div>').html(htmlContent);
|
666 |
-
|
667 |
-
// Fonction récursive pour traiter chaque nœud
|
668 |
-
function processNode(node, targetContainer) {
|
669 |
-
if (node.nodeType === Node.TEXT_NODE) {
|
670 |
-
// Nœud texte - streamer mot par mot
|
671 |
-
const words = node.textContent.split(/(\s+)/);
|
672 |
-
let wordIndex = 0;
|
673 |
-
|
674 |
-
function addNextWord() {
|
675 |
-
if (wordIndex < words.length) {
|
676 |
-
const word = words[wordIndex];
|
677 |
-
const span = $('<span>').addClass('word-by-word').text(word);
|
678 |
-
span.css('animation-delay', '0s');
|
679 |
-
targetContainer.append(span);
|
680 |
-
|
681 |
-
setTimeout(() => {
|
682 |
-
wordIndex++;
|
683 |
-
addNextWord();
|
684 |
-
}, delay);
|
685 |
-
} else if (callback && node === tempDiv.get(0).lastChild) {
|
686 |
-
setTimeout(callback, 500);
|
687 |
-
}
|
688 |
-
}
|
689 |
-
|
690 |
-
addNextWord();
|
691 |
-
|
692 |
-
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
693 |
-
// Nœud élément - recréer l'élément et traiter ses enfants
|
694 |
-
const newElement = $(`<${node.tagName.toLowerCase()}>`);
|
695 |
-
|
696 |
-
// Copier les attributs
|
697 |
-
Array.from(node.attributes).forEach(attr => {
|
698 |
-
newElement.attr(attr.name, attr.value);
|
699 |
-
});
|
700 |
-
|
701 |
-
targetContainer.append(newElement);
|
702 |
-
|
703 |
-
// Traiter les enfants
|
704 |
-
Array.from(node.childNodes).forEach(child => {
|
705 |
-
processNode(child, newElement);
|
706 |
-
});
|
707 |
-
}
|
708 |
-
}
|
709 |
-
|
710 |
-
// Démarrer le traitement
|
711 |
-
Array.from(tempDiv.get(0).childNodes).forEach(child => {
|
712 |
-
processNode(child, container);
|
713 |
-
});
|
714 |
-
|
715 |
-
// Auto-scroll pendant le streaming
|
716 |
-
const scrollInterval = setInterval(() => {
|
717 |
-
smoothScrollToBottom();
|
718 |
-
}, 200);
|
719 |
-
|
720 |
-
setTimeout(() => {
|
721 |
-
clearInterval(scrollInterval);
|
722 |
-
}, (text.split(' ').length * delay) + 2000);
|
723 |
-
}
|
724 |
-
|
725 |
-
// Fonction de scroll optimisée
|
726 |
-
function smoothScrollToBottom() {
|
727 |
-
const targetScrollTop = Math.max(0, document.documentElement.scrollHeight - window.innerHeight - 50);
|
728 |
-
window.scrollTo({
|
729 |
-
top: targetScrollTop,
|
730 |
-
behavior: 'smooth'
|
731 |
-
});
|
732 |
-
}
|
733 |
-
|
734 |
-
// --- Gestion de l'interface ---
|
735 |
-
$('#type-select').change(function() {
|
736 |
-
const type = $(this).val();
|
737 |
-
// Cacher les sections de résultat lors du changement de type
|
738 |
-
$('#loading-section, #thinking-wrapper, #response, #action-buttons').addClass('hidden');
|
739 |
-
|
740 |
-
if (type === '3') { // Sujet Type 3
|
741 |
-
$('#text-input-container').hide();
|
742 |
-
$('#image-input-container').show().addClass('animate-fadeIn');
|
743 |
-
$('#deepthink-btn').hide();
|
744 |
-
$('#submit-btn').html('<svg class="h-5 w-5 mr-2" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" /></svg>Analyser le sujet');
|
745 |
-
} else { // Dissertation texte
|
746 |
-
$('#text-input-container').show().addClass('animate-fadeIn');
|
747 |
-
$('#image-input-container').hide();
|
748 |
-
$('#deepthink-btn').show();
|
749 |
-
$('#submit-btn').html('<svg class="h-5 w-5 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 000-1.5h-3.25V5z" clip-rule="evenodd" /></svg>Générer la dissertation');
|
750 |
-
}
|
751 |
-
}).trigger('change');
|
752 |
-
|
753 |
-
$('#image-upload').change(function(e) {
|
754 |
-
if (e.target.files && e.target.files[0]) {
|
755 |
-
const reader = new FileReader();
|
756 |
-
reader.onload = (event) => $('#image-preview').attr('src', event.target.result).removeClass('hidden').addClass('animate-fadeIn');
|
757 |
-
reader.readAsDataURL(e.target.files[0]);
|
758 |
}
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
if (!question) {
|
775 |
-
Swal.fire('Erreur', 'Veuillez saisir un sujet.', 'error');
|
776 |
-
return;
|
777 |
-
}
|
778 |
-
}
|
779 |
-
|
780 |
-
// Cacher les sections précédentes et démarrer le loader
|
781 |
-
$('#thinking-wrapper, #response, #action-buttons').addClass('hidden');
|
782 |
-
startProgressLoader();
|
783 |
-
|
784 |
-
// Simuler une génération (remplacer par l'appel API réel)
|
785 |
-
setTimeout(() => {
|
786 |
-
completeProgress();
|
787 |
-
}, Math.random() * 3000 + 2000); // Entre 2 et 5 secondes
|
788 |
-
|
789 |
-
/*
|
790 |
-
// Code pour l'appel API réel (décommenter et adapter) :
|
791 |
-
const data = type === '3' ?
|
792 |
-
new FormData().append('image', $('#image-upload')[0].files[0]) :
|
793 |
-
{ question: $('#question').val().trim(), type, courseId: $('#course-select').val() || null };
|
794 |
-
|
795 |
-
const url = type === '3' ? '/stream_philo_image' :
|
796 |
-
isDeepThink ? '/stream_philo_deepthink' : '/stream_philo';
|
797 |
-
|
798 |
-
handleRealStreamedGeneration(url, {
|
799 |
-
method: 'POST',
|
800 |
-
headers: type !== '3' ? { 'Content-Type': 'application/json' } : undefined,
|
801 |
-
body: type === '3' ? data : JSON.stringify(data)
|
802 |
-
});
|
803 |
-
*/
|
804 |
-
});
|
805 |
-
|
806 |
-
// Fonction pour les vrais appels API streamés (à utiliser quand l'API est prête)
|
807 |
-
async function handleRealStreamedGeneration(url, options) {
|
808 |
-
startProgressLoader();
|
809 |
-
|
810 |
-
let fullResponseText = '', fullThinkingText = '';
|
811 |
-
|
812 |
-
try {
|
813 |
-
const response = await fetch(url, options);
|
814 |
-
if (!response.ok) throw new Error(await response.text());
|
815 |
-
|
816 |
-
// Compléter la barre de progression
|
817 |
-
completeProgress();
|
818 |
-
|
819 |
-
const reader = response.body.getReader();
|
820 |
-
const decoder = new TextDecoder();
|
821 |
-
let buffer = '';
|
822 |
-
|
823 |
-
while (true) {
|
824 |
-
const { value, done } = await reader.read();
|
825 |
-
if (done) break;
|
826 |
-
|
827 |
-
buffer += decoder.decode(value, { stream: true });
|
828 |
-
const lines = buffer.split('\n');
|
829 |
-
buffer = lines.pop();
|
830 |
-
|
831 |
-
for (const line of lines) {
|
832 |
-
if (line.trim() === '') continue;
|
833 |
-
try {
|
834 |
-
const data = JSON.parse(line.trim());
|
835 |
-
|
836 |
-
if (data.type === 'thought') {
|
837 |
-
fullThinkingText += data.content;
|
838 |
-
} else if (data.type === 'answer') {
|
839 |
-
fullResponseText += data.content;
|
840 |
-
} else if (data.type === 'error') {
|
841 |
-
throw new Error(data.content);
|
842 |
-
}
|
843 |
-
} catch (e) {
|
844 |
-
console.error("Erreur JSON parse:", line, e);
|
845 |
-
}
|
846 |
-
}
|
847 |
-
}
|
848 |
-
|
849 |
-
// Démarrer l'affichage streaming avec les vraies données
|
850 |
-
startWordByWordStreaming(fullThinkingText, fullResponseText);
|
851 |
-
|
852 |
-
} catch (error) {
|
853 |
-
$('#loading-section').addClass('hidden');
|
854 |
-
Swal.fire({ icon: 'error', title: 'Erreur', text: error.message || "Une erreur inconnue est survenue." });
|
855 |
-
}
|
856 |
-
}
|
857 |
-
|
858 |
-
// --- Fonctions de gestion de l'historique ---
|
859 |
-
function loadCourses() {
|
860 |
-
// Simuler le chargement des cours
|
861 |
-
const sampleCourses = [
|
862 |
-
{ id: '1', title: 'Introduction à la philosophie politique', author: 'Martin' },
|
863 |
-
{ id: '2', title: 'Éthique et morale', author: 'Dubois' },
|
864 |
-
{ id: '3', title: 'Métaphysique contemporaine', author: 'Laurent' }
|
865 |
-
];
|
866 |
-
|
867 |
-
const select = $('#course-select');
|
868 |
-
sampleCourses.forEach(course => {
|
869 |
-
const newOption = new Option(course.title, course.id, false, false);
|
870 |
-
$(newOption).data('author', course.author);
|
871 |
-
select.append(newOption);
|
872 |
-
});
|
873 |
-
select.trigger('change');
|
874 |
-
|
875 |
-
/*
|
876 |
-
// Code pour l'appel API réel :
|
877 |
-
$.ajax({
|
878 |
-
url: '/api/philosophy/courses',
|
879 |
-
method: 'GET',
|
880 |
-
}).done(function(courses) {
|
881 |
-
const select = $('#course-select');
|
882 |
-
courses.forEach(course => {
|
883 |
-
const newOption = new Option(course.title, course.id, false, false);
|
884 |
-
$(newOption).data('author', course.author);
|
885 |
-
select.append(newOption);
|
886 |
});
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
localStorage.setItem('dissertations', JSON.stringify(saved));
|
900 |
-
updateSavedDissertationsList();
|
901 |
-
}
|
902 |
-
|
903 |
-
function deleteDissertation(index) {
|
904 |
-
let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
|
905 |
-
saved.splice(index, 1);
|
906 |
-
localStorage.setItem('dissertations', JSON.stringify(saved));
|
907 |
-
updateSavedDissertationsList();
|
908 |
-
Toast.fire({ icon: 'info', title: 'Dissertation supprimée' });
|
909 |
-
}
|
910 |
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
if (saved.length === 0) {
|
916 |
-
list.append('<p class="text-gray-500 text-center py-4">Aucune dissertation dans l\'historique.</p>');
|
917 |
return;
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
const item = $(`
|
923 |
-
<div class="border border-gray-200 bg-white rounded-xl shadow-sm transition-shadow hover:shadow-md">
|
924 |
-
<button class="collapsible rounded-t-xl w-full text-left">
|
925 |
-
<div class="flex justify-between items-center w-full p-4">
|
926 |
-
<span class="font-medium text-gray-800">${title}</span>
|
927 |
-
<span class="text-gray-500 text-sm flex-shrink-0 ml-4">${date}</span>
|
928 |
-
</div>
|
929 |
-
</button>
|
930 |
-
<div class="content prose max-w-none border-t border-gray-200">
|
931 |
-
<div class="inner-content p-4 content-scrollable"></div>
|
932 |
-
<div class="p-4 border-t border-gray-200 bg-gray-50 rounded-b-xl">
|
933 |
-
<button class="delete-btn text-sm text-red-600 hover:text-red-800 font-medium" data-index="${index}">Supprimer</button>
|
934 |
-
</div>
|
935 |
-
</div>
|
936 |
-
</div>
|
937 |
-
`);
|
938 |
-
item.find('.inner-content').html(marked.parse(diss.content));
|
939 |
-
list.append(item);
|
940 |
-
});
|
941 |
-
}
|
942 |
-
|
943 |
-
// Gestion des interactions avec l'historique
|
944 |
-
$('#dissertations-list').on('click', '.collapsible', function() {
|
945 |
-
const content = $(this).next('.content');
|
946 |
-
const isVisible = content.is(':visible');
|
947 |
-
|
948 |
-
content.stop(true, true).slideToggle({
|
949 |
-
duration: 300,
|
950 |
-
easing: 'swing',
|
951 |
-
start: function() {
|
952 |
-
$(this).css('overflow', 'hidden');
|
953 |
-
},
|
954 |
-
complete: function() {
|
955 |
-
$(this).css('overflow', isVisible ? 'hidden' : 'visible');
|
956 |
}
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
// Optimisations mobiles
|
979 |
-
let ticking = false;
|
980 |
-
|
981 |
-
function updateScrollPosition() {
|
982 |
-
ticking = false;
|
983 |
-
}
|
984 |
-
|
985 |
-
window.addEventListener('scroll', function() {
|
986 |
-
if (!ticking) {
|
987 |
-
requestAnimationFrame(updateScrollPosition);
|
988 |
-
ticking = true;
|
989 |
}
|
990 |
-
|
991 |
-
|
992 |
-
let resizeTimer;
|
993 |
-
window.addEventListener('resize', function() {
|
994 |
-
clearTimeout(resizeTimer);
|
995 |
-
resizeTimer = setTimeout(function() {
|
996 |
-
if (window.innerWidth <= 640) {
|
997 |
-
$('body').addClass('mobile-optimized');
|
998 |
-
} else {
|
999 |
-
$('body').removeClass('mobile-optimized');
|
1000 |
-
}
|
1001 |
-
}, 250);
|
1002 |
-
}, { passive: true });
|
1003 |
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
$(document).on('touchstart', 'button, .collapsible', function() {
|
1008 |
-
$(this).addClass('touch-active');
|
1009 |
-
});
|
1010 |
-
|
1011 |
-
$(document).on('touchend', 'button, .collapsible', function() {
|
1012 |
-
const element = $(this);
|
1013 |
-
setTimeout(() => element.removeClass('touch-active'), 150);
|
1014 |
-
});
|
1015 |
-
}
|
1016 |
|
1017 |
-
|
1018 |
-
|
1019 |
-
updateSavedDissertationsList();
|
1020 |
-
});
|
1021 |
-
</script>
|
1022 |
</body>
|
1023 |
</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>Assistant de Philosophie (Vue.js)</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
|
9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
|
|
|
|
|
|
10 |
|
11 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
12 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
13 |
+
<link href="https://fonts.googleapis.com/css2?family=Kalam&family=Lato:wght@400;700&display=swap" rel="stylesheet">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
<style>
|
16 |
+
body { font-family: 'Lato', sans-serif; background-color: #f4f4f9; margin: 0; padding: 20px; color: #333; }
|
17 |
+
.container { max-width: 900px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
|
18 |
+
h1 { text-align: center; color: #2c3e50; }
|
19 |
+
textarea { width: 100%; padding: 10px; border-radius: 4px; border: 1px solid #ddd; min-height: 80px; margin-bottom: 10px; font-size: 16px; }
|
20 |
+
button { display: block; width: 100%; padding: 15px; background-color: #2980b9; color: white; border: none; border-radius: 5px; font-size: 18px; cursor: pointer; transition: background-color 0.3s; }
|
21 |
+
button:hover { background-color: #3498db; }
|
22 |
+
button:disabled { background-color: #95a5a6; cursor: not-allowed; }
|
23 |
+
.loader { display: block; border: 8px solid #f3f3f3; border-top: 8px solid #3498db; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 20px auto; }
|
24 |
+
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
25 |
+
.error { color: #c0392b; text-align: center; margin-top: 20px; font-weight: bold; }
|
26 |
+
|
27 |
+
.dissertation-paper {
|
28 |
+
font-family: 'Kalam', cursive;
|
29 |
+
font-size: 20px;
|
30 |
+
color: #1a2a4c;
|
31 |
+
background-color: #fdfaf4;
|
32 |
+
line-height: 1.8;
|
33 |
+
background-image: linear-gradient(transparent 97%, #d8e2ee 98%);
|
34 |
+
background-size: 100% 36px;
|
35 |
+
border-left: 2px solid #ffaaab;
|
36 |
+
padding-left: 4em;
|
37 |
+
margin: 40px -30px -30px -30px;
|
38 |
+
padding-top: 30px;
|
39 |
+
padding-bottom: 30px;
|
40 |
+
padding-right: 30px;
|
41 |
+
-webkit-print-color-adjust: exact;
|
42 |
+
print-color-adjust: exact;
|
43 |
+
-webkit-font-smoothing: antialiased;
|
44 |
+
background-clip: padding-box;
|
45 |
+
}
|
46 |
+
.dissertation-paper h2 { font-size: 1.5em; text-align: center; margin-bottom: 1.8em; }
|
47 |
+
.dissertation-paper h3 { font-size: 1.2em; margin-top: 3.6em; margin-bottom: 1.8em; text-transform: uppercase; text-decoration: underline; }
|
48 |
+
.dissertation-paper .development-block { margin-top: 3.6em; }
|
49 |
+
.dissertation-paper p { text-align: justify; margin: 0; padding: 0; }
|
50 |
+
.dissertation-paper .prof { text-align: center; font-style: italic; margin-bottom: 1.8em; }
|
51 |
+
.dissertation-paper .indented { text-indent: 3em; }
|
52 |
+
.dissertation-paper .transition { margin-top: 1.8em; margin-bottom: 1.8em; font-style: italic; color: #4a6a9c; }
|
53 |
+
.dissertation-paper .pdf-button-container { text-align: center; margin-top: 3.6em; }
|
54 |
+
.dissertation-paper .pdf-button { font-family: 'Lato', sans-serif; font-size: 16px; padding: 10px 20px; width: auto; }
|
55 |
+
.dissertation-paper, .dissertation-paper * { box-sizing: border-box; }
|
56 |
+
.avoid-page-break { page-break-inside: avoid; break-inside: avoid; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
</style>
|
58 |
</head>
|
59 |
+
<body>
|
60 |
+
<div id="app" class="container">
|
61 |
+
<h1>Assistant de Dissertation Philosophique</h1>
|
62 |
+
|
63 |
+
<form @submit.prevent="generateDissertation">
|
64 |
+
<textarea v-model="question" placeholder="Entrez votre sujet de dissertation ici..."></textarea>
|
65 |
+
<button type="submit" :disabled="isLoading">
|
66 |
+
[[ isLoading ? 'Génération en cours...' : 'Générer la dissertation' ]]
|
67 |
+
</button>
|
68 |
+
</form>
|
69 |
+
|
70 |
+
<div v-if="isLoading" class="loader"></div>
|
71 |
+
<p v-if="errorMessage" class="error">[[ errorMessage ]]</p>
|
72 |
+
|
73 |
+
<div v-if="dissertation" id="dissertation-content" class="dissertation-paper">
|
74 |
+
<h2>Sujet : [[ dissertation.sujet ]]</h2>
|
75 |
+
<p class="prof">Prof : [[ dissertation.prof ]]</p>
|
76 |
+
|
77 |
+
<h3>Introduction</h3>
|
78 |
+
<p class="indented">[[ dissertation.introduction ]]</p>
|
79 |
+
|
80 |
+
<div v-for="partie in dissertation.parties" :key="partie.chapeau" class="avoid-page-break">
|
81 |
+
<div class="development-block">
|
82 |
+
<p class="indented">[[ partie.chapeau ]]</p>
|
83 |
+
<p v-for="(arg, idx) in partie.arguments" :key="idx" class="indented">
|
84 |
+
[[ arg.paragraphe_argumentatif ]]
|
85 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</div>
|
87 |
+
<p v-if="partie.transition" class="indented transition">[[ partie.transition ]]</p>
|
88 |
</div>
|
89 |
|
90 |
+
<h3>Conclusion</h3>
|
91 |
+
<p class="indented">[[ dissertation.conclusion ]]</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
+
<div class="pdf-button-container" data-html2canvas-ignore="true">
|
94 |
+
<button class="pdf-button" @click="generatePDF">Télécharger en PDF</button>
|
|
|
|
|
|
|
95 |
</div>
|
96 |
</div>
|
97 |
+
</div>
|
98 |
+
|
99 |
+
<script>
|
100 |
+
const { createApp } = Vue;
|
101 |
+
|
102 |
+
const app = createApp({
|
103 |
+
data() {
|
104 |
+
return {
|
105 |
+
question: '',
|
106 |
+
isLoading: false,
|
107 |
+
errorMessage: null,
|
108 |
+
dissertation: null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
+
},
|
111 |
+
methods: {
|
112 |
+
async generateDissertation() {
|
113 |
+
if (!this.question.trim()) {
|
114 |
+
this.errorMessage = "Veuillez entrer un sujet de dissertation.";
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
this.isLoading = true;
|
118 |
+
this.errorMessage = null;
|
119 |
+
this.dissertation = null;
|
120 |
+
try {
|
121 |
+
const response = await fetch('/api/generate_dissertation', {
|
122 |
+
method: 'POST',
|
123 |
+
headers: { 'Content-Type': 'application/json' },
|
124 |
+
body: JSON.stringify({ question: this.question })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
});
|
126 |
+
const data = await response.json();
|
127 |
+
if (!response.ok) {
|
128 |
+
throw new Error(data.error || "Une erreur inconnue est survenue.");
|
129 |
+
}
|
130 |
+
this.dissertation = data;
|
131 |
+
await new Promise(r => setTimeout(r, 50));
|
132 |
+
} catch (error) {
|
133 |
+
this.errorMessage = error.message;
|
134 |
+
} finally {
|
135 |
+
this.isLoading = false;
|
136 |
+
}
|
137 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
+
async generatePDF() {
|
140 |
+
const element = document.getElementById('dissertation-content');
|
141 |
+
if (!element) {
|
142 |
+
this.errorMessage = "Contenu introuvable pour le PDF.";
|
|
|
|
|
143 |
return;
|
144 |
+
}
|
145 |
+
try {
|
146 |
+
if (document.fonts && document.fonts.ready) {
|
147 |
+
await document.fonts.ready;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
+
window.scrollTo(0, 0);
|
150 |
+
|
151 |
+
const options = {
|
152 |
+
margin: [10, 10, 10, 10], // mm (voir jsPDF.unit ci-dessous)
|
153 |
+
filename: 'dissertation-philosophie.pdf',
|
154 |
+
image: { type: 'jpeg', quality: 0.98 },
|
155 |
+
html2canvas: {
|
156 |
+
scale: 2,
|
157 |
+
useCORS: true,
|
158 |
+
logging: true,
|
159 |
+
backgroundColor: '#ffffff'
|
160 |
+
},
|
161 |
+
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
162 |
+
};
|
163 |
+
|
164 |
+
await html2pdf().set(options).from(element).save();
|
165 |
+
} catch (err) {
|
166 |
+
console.error('Erreur html2pdf:', err);
|
167 |
+
this.errorMessage = "Erreur lors de la génération du PDF. Voir la console pour les détails.";
|
168 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
}
|
170 |
+
}
|
171 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
// ⚠️ Changer les délimiteurs pour éviter le conflit avec Jinja2
|
174 |
+
app.config.compilerOptions.delimiters = ['[[', ']]'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
+
app.mount('#app');
|
177 |
+
</script>
|
|
|
|
|
|
|
178 |
</body>
|
179 |
</html>
|