Docfile commited on
Commit
67433f8
·
verified ·
1 Parent(s): a7279c7

Delete templates/philosophie.html

Browse files
Files changed (1) hide show
  1. templates/philosophie.html +0 -981
templates/philosophie.html DELETED
@@ -1,981 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="fr" class="scroll-smooth">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Mariam AI - Assistant Philosophique</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/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
9
- <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/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
- /* Variables pour des transitions plus fluides */
22
- --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
23
- --transition-fast: all 0.15s ease-out;
24
- }
25
-
26
- /* Optimisations pour le scroll fluide */
27
- html {
28
- scroll-behavior: smooth;
29
- -webkit-overflow-scrolling: touch;
30
- }
31
-
32
- body {
33
- /* Prévenir le reflow lors de la génération */
34
- will-change: scroll-position;
35
- /* Améliorer les performances sur mobile */
36
- -webkit-font-smoothing: antialiased;
37
- -moz-osx-font-smoothing: grayscale;
38
- }
39
-
40
- .collapsible {
41
- cursor: pointer;
42
- padding: 1rem;
43
- width: 100%;
44
- border: none;
45
- text-align: left;
46
- outline: none;
47
- transition: var(--transition-fast);
48
- /* Optimiser pour les interactions tactiles */
49
- touch-action: manipulation;
50
- -webkit-tap-highlight-color: transparent;
51
- }
52
-
53
- .collapsible:hover {
54
- background-color: #f9fafb;
55
- }
56
-
57
- .content {
58
- padding: 0 1rem;
59
- display: none;
60
- overflow: hidden;
61
- background-color: white;
62
- /* Transition plus fluide pour l'ouverture */
63
- transition: var(--transition-smooth);
64
- }
65
-
66
- /* Styles pour la lisibilité du Markdown généré */
67
- .prose {
68
- max-width: 100% !important;
69
- /* Optimiser le rendu du texte */
70
- text-rendering: optimizeLegibility;
71
- }
72
-
73
- #response .prose {
74
- color: #374151;
75
- word-wrap: break-word;
76
- overflow-wrap: break-word;
77
- /* Prévenir les débordements sur mobile */
78
- hyphens: auto;
79
- -webkit-hyphens: auto;
80
- -moz-hyphens: auto;
81
- }
82
-
83
- .prose p, .prose ul, .prose ol, .prose li {
84
- line-height: 1.75;
85
- }
86
-
87
- .prose h1, .prose h2, .prose h3 {
88
- margin-top: 1.5em;
89
- margin-bottom: 0.8em;
90
- line-height: 1.3;
91
- }
92
-
93
- /* Animation fadeIn optimisée */
94
- .animate-fadeIn {
95
- animation: fadeIn 0.4s ease-out forwards;
96
- /* Utiliser GPU pour l'animation */
97
- transform: translateZ(0);
98
- will-change: opacity, transform;
99
- }
100
-
101
- @keyframes fadeIn {
102
- from {
103
- opacity: 0;
104
- transform: translateY(15px) translateZ(0);
105
- }
106
- to {
107
- opacity: 1;
108
- transform: translateY(0) translateZ(0);
109
- }
110
- }
111
-
112
- /* Styles pour le loader élégant */
113
- .elegant-loader {
114
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
115
- border-radius: 1rem;
116
- padding: 2rem;
117
- box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
118
- backdrop-filter: blur(10px);
119
- border: 1px solid rgba(255, 255, 255, 0.2);
120
- }
121
-
122
- .loader-content {
123
- text-align: center;
124
- color: white;
125
- }
126
-
127
- .progress-container {
128
- background: rgba(255, 255, 255, 0.2);
129
- border-radius: 50px;
130
- padding: 4px;
131
- margin: 1.5rem 0;
132
- backdrop-filter: blur(10px);
133
- }
134
-
135
- .progress-bar {
136
- background: linear-gradient(90deg, #60a5fa, #34d399, #fbbf24);
137
- background-size: 200% 100%;
138
- border-radius: 50px;
139
- height: 12px;
140
- width: 0%;
141
- transition: width 0.3s ease;
142
- animation: progressGradient 2s ease-in-out infinite;
143
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
144
- }
145
-
146
- @keyframes progressGradient {
147
- 0%, 100% { background-position: 0% 50%; }
148
- 50% { background-position: 100% 50%; }
149
- }
150
-
151
- .loader-icon {
152
- display: inline-block;
153
- animation: float 3s ease-in-out infinite;
154
- font-size: 3rem;
155
- margin-bottom: 1rem;
156
- }
157
-
158
- @keyframes float {
159
- 0%, 100% { transform: translateY(0px) rotate(0deg); }
160
- 50% { transform: translateY(-10px) rotate(5deg); }
161
- }
162
-
163
- .thinking-particles {
164
- display: flex;
165
- justify-content: center;
166
- gap: 0.5rem;
167
- margin-top: 1rem;
168
- }
169
-
170
- .particle {
171
- width: 8px;
172
- height: 8px;
173
- background: rgba(255, 255, 255, 0.8);
174
- border-radius: 50%;
175
- animation: particle-bounce 1.4s ease-in-out infinite both;
176
- }
177
-
178
- .particle:nth-child(1) { animation-delay: -0.32s; }
179
- .particle:nth-child(2) { animation-delay: -0.16s; }
180
- .particle:nth-child(3) { animation-delay: 0s; }
181
-
182
- @keyframes particle-bounce {
183
- 0%, 80%, 100% { transform: scale(0.8) translateY(0); opacity: 0.7; }
184
- 40% { transform: scale(1.2) translateY(-10px); opacity: 1; }
185
- }
186
-
187
- /* Effet de pluie pour l'affichage du texte */
188
- .rain-text {
189
- opacity: 0;
190
- transform: translateY(-20px);
191
- animation: rainDrop 0.8s ease-out forwards;
192
- }
193
-
194
- @keyframes rainDrop {
195
- 0% {
196
- opacity: 0;
197
- transform: translateY(-20px) scale(0.95);
198
- }
199
- 50% {
200
- opacity: 0.7;
201
- transform: translateY(5px) scale(1.02);
202
- }
203
- 100% {
204
- opacity: 1;
205
- transform: translateY(0) scale(1);
206
- }
207
- }
208
-
209
- /* Styles pour Select2 */
210
- .select2-container--default .select2-selection--single {
211
- border: 1px solid #d1d5db;
212
- border-radius: 0.75rem;
213
- height: auto;
214
- padding: 0.75rem 1rem;
215
- background-color: white;
216
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
217
- }
218
-
219
- .select2-container--default .select2-selection--single .select2-selection__rendered {
220
- color: #111827;
221
- line-height: inherit;
222
- padding-right: 1.5rem;
223
- }
224
-
225
- .select2-results__option .course-author {
226
- font-size: 0.875rem;
227
- color: #6b7280;
228
- display: block;
229
- margin-top: 0.1rem;
230
- }
231
-
232
- .select2-dropdown {
233
- border-radius: 0.75rem;
234
- border: 1px solid #d1d5db;
235
- box-shadow: 0 4px 6px -1px rgba(0,0,0,.1);
236
- }
237
-
238
- /* Styles pour l'aperçu de l'image */
239
- #image-preview {
240
- max-height: 200px;
241
- border-radius: 0.75rem;
242
- box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
243
- }
244
-
245
- /* Cacher le marqueur par défaut de <details> */
246
- summary {
247
- list-style: none;
248
- }
249
-
250
- summary::-webkit-details-marker {
251
- display: none;
252
- }
253
-
254
- /* Optimisations mobiles */
255
- @media (max-width: 640px) {
256
- /* Réduire les marges sur mobile pour plus d'espace */
257
- .max-w-3xl {
258
- max-width: 100%;
259
- margin-left: 0.5rem;
260
- margin-right: 0.5rem;
261
- }
262
-
263
- /* Optimiser l'affichage des sections de contenu */
264
- #response, #thinking-wrapper {
265
- /* Éviter les débordements horizontaux */
266
- overflow-x: hidden;
267
- }
268
-
269
- /* Améliorer la lisibilité du texte généré */
270
- .prose {
271
- font-size: 0.95rem;
272
- line-height: 1.6;
273
- }
274
-
275
- /* Réduire l'animation pour économiser la batterie */
276
- .animate-fadeIn {
277
- animation-duration: 0.2s;
278
- }
279
-
280
- .elegant-loader {
281
- padding: 1.5rem;
282
- margin: 0.5rem;
283
- }
284
- }
285
-
286
- /* Conteneur de génération avec scroll optimisé */
287
- .generation-container {
288
- /* Conteneur stable pour éviter les recalculs de layout */
289
- contain: layout style;
290
- /* Optimiser les performances de scroll */
291
- transform: translateZ(0);
292
- }
293
-
294
- /* Améliorer les performances du textarea */
295
- textarea {
296
- /* Éviter les reflows pendant la saisie */
297
- resize: none;
298
- /* Optimiser sur mobile */
299
- -webkit-appearance: none;
300
- }
301
-
302
- /* Optimiser les boutons pour le tactile */
303
- button {
304
- touch-action: manipulation;
305
- -webkit-tap-highlight-color: transparent;
306
- transition: var(--transition-fast);
307
- }
308
-
309
- /* Scroll fluide pour les éléments avec beaucoup de contenu */
310
- .content-scrollable {
311
- -webkit-overflow-scrolling: touch;
312
- scroll-behavior: smooth;
313
- }
314
- </style>
315
- </head>
316
- <body class="bg-gray-50 text-gray-900">
317
- <!-- Navbar -->
318
- <nav class="bg-white/90 backdrop-blur-lg border-b border-gray-200 fixed w-full z-50">
319
- <div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
320
- <div class="flex justify-between items-center h-16">
321
- <div class="flex items-center space-x-3">
322
- <svg class="h-8 w-auto text-violet-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
323
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 18v-5.25m0 0a6.01 6.01 0 001.5-.189m-1.5.189a6.01 6.01 0 01-1.5-.189m3.75 7.478a12.06 12.06 0 01-4.5 0m3.75 2.311a15.045 15.045 0 01-7.5 0C4.508 19.663 2.25 15.184 2.25 10.5 2.25 5.816 5.816 2.25 10.5 2.25c4.684 0 8.25 3.566 8.25 8.25 0 4.684-2.258 9.163-5.25 11.584z" />
324
- </svg>
325
- <div class="text-xl font-bold text-gray-800">Mariam AI</div>
326
- </div>
327
- <div class="flex items-center">
328
- <span class="inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-violet-100 text-violet-800">
329
- Assistant Philosophique
330
- </span>
331
- </div>
332
- </div>
333
- </div>
334
- </nav>
335
-
336
- <!-- Main Content -->
337
- <main class="pt-24 pb-16 px-4 sm:px-6 lg:px-8">
338
- <div class="max-w-3xl mx-auto">
339
- <div class="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden">
340
- <div class="p-6 sm:p-8">
341
- <div class="text-center">
342
- <h1 class="text-3xl font-bold text-gray-900">Gen'Dissertation</h1>
343
- <p class="mt-2 text-md text-gray-600">Créez des dissertations et analyses pertinentes et structurées.</p>
344
- </div>
345
- </div>
346
-
347
- <div class="p-6 sm:p-8 border-t border-gray-200 space-y-6">
348
- <!-- Type Selection -->
349
- <div class="space-y-2">
350
- <label for="type-select" class="block text-sm font-medium text-gray-700">Type de travail</label>
351
- <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">
352
- <option value="1">Sujet Type 1</option>
353
- <option value="2">Sujet Type 2 (Citation)</option>
354
- <option value="3">Sujet Type 3</option>
355
- </select>
356
- </div>
357
-
358
- <!-- Conteneur pour les champs texte (visible par défaut) -->
359
- <div id="text-input-container">
360
- <!-- Course Selection -->
361
- <div class="space-y-2">
362
- <label for="course-select" class="block text-sm font-medium text-gray-700">Utiliser un cours comme contexte</label>
363
- <select id="course-select" class="w-full">
364
- <option value="">Choisir un cours...</option>
365
- </select>
366
- </div>
367
- <!-- Question Input -->
368
- <div class="space-y-2 mt-4">
369
- <label for="question" class="block text-sm font-medium text-gray-700">Sujet de dissertation</label>
370
- <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>
371
- </div>
372
- </div>
373
-
374
- <!-- Conteneur pour l'upload d'image (caché par défaut) -->
375
- <div id="image-input-container" class="hidden">
376
- <div class="space-y-2">
377
- <label for="image-upload" class="block text-sm font-medium text-gray-700">Charger un document pour analyse</label>
378
- <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"/>
379
- <div class="mt-4 flex justify-center"><img id="image-preview" src="" alt="Aperçu de l'image" class="hidden"/></div>
380
- </div>
381
- </div>
382
-
383
- <!-- Submit Button -->
384
- <div class="pt-4">
385
- <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">
386
- <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>
387
- Générer la dissertation
388
- </button>
389
- </div>
390
- </div>
391
- </div>
392
-
393
- <!-- Elegant Loading Section -->
394
- <div id="loading-section" class="hidden mt-8">
395
- <div class="elegant-loader">
396
- <div class="loader-content">
397
- <div class="loader-icon">🧠</div>
398
- <h3 class="text-xl font-bold mb-2">Réflexion en cours...</h3>
399
- <p class="text-white/80 mb-4" id="loading-status">Analyse du sujet</p>
400
-
401
- <div class="progress-container">
402
- <div class="progress-bar" id="progress-bar"></div>
403
- </div>
404
-
405
- <div class="flex justify-between text-sm text-white/70 mb-4">
406
- <span>Progression</span>
407
- <span id="progress-text">0%</span>
408
- </div>
409
-
410
- <div class="thinking-particles">
411
- <div class="particle"></div>
412
- <div class="particle"></div>
413
- <div class="particle"></div>
414
- </div>
415
- </div>
416
- </div>
417
- </div>
418
-
419
- <!-- Thinking Process Section (Collapsible) -->
420
- <div id="thinking-wrapper" class="hidden mt-8 generation-container">
421
- <details id="thinking-container" class="bg-white border border-gray-200 rounded-xl shadow-sm">
422
- <summary class="flex justify-between items-center p-4 cursor-pointer">
423
- <h3 class="text-md font-semibold text-gray-700">Processus de pensée de l'IA</h3>
424
- <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">
425
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
426
- </svg>
427
- </summary>
428
- <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">
429
- <!-- Le contenu du processus de pensée sera injecté ici -->
430
- </div>
431
- </details>
432
- </div>
433
-
434
- <!-- Response Section -->
435
- <div id="response" class="hidden mt-6 generation-container">
436
- <div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 sm:p-8 prose prose-violet max-w-none">
437
- <!-- Le contenu de la réponse sera injecté ici -->
438
- </div>
439
- </div>
440
-
441
- <!-- Action Buttons after generation -->
442
- <div id="action-buttons" class="hidden mt-6 grid grid-cols-1 sm:grid-cols-2 gap-4">
443
- <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">
444
- <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>
445
- Copier le texte
446
- </button>
447
- </div>
448
-
449
- <!-- Saved Dissertations Section -->
450
- <div class="mt-12">
451
- <h3 class="text-xl font-bold text-gray-800 mb-4">Historique</h3>
452
- <div id="dissertations-list" class="space-y-3">
453
- <!-- La liste des dissertations sauvegardées sera injectée ici -->
454
- </div>
455
- </div>
456
- </div>
457
- </main>
458
-
459
- <!-- Bouton flottant DeepThink -->
460
- <button id="deepthink-btn" class="fixed bottom-6 right-6 z-50 flex items-center bg-indigo-600 text-white px-5 py-3 rounded-full shadow-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-transform hover:scale-105">
461
- <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="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.898 20.562L16.25 22.5l-.648-1.938a3.375 3.375 0 00-2.672-2.672L11.25 18l1.938-.648a3.375 3.375 0 002.672-2.672L16.25 13.5l.648 1.938a3.375 3.375 0 002.672 2.672L21.75 18l-1.938.648a3.375 3.375 0 00-2.672 2.672z" /></svg>
462
- DeepThink
463
- </button>
464
-
465
- <script>
466
- $(document).ready(function() {
467
- // --- Initialisations ---
468
- $('#course-select').select2({
469
- placeholder: 'Optionnel : choisir un cours...',
470
- allowClear: true,
471
- templateResult: function (course) { if (!course.id) { return course.text; } return $(`<span>${course.text}</span><span class="course-author">Pr. ${$(course.element).data('author')}</span>`); },
472
- templateSelection: function (course) { return course.text; },
473
- });
474
- marked.setOptions({ breaks: true, gfm: true, headerIds: false, mangle: false });
475
- moment.locale('fr');
476
- const Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 3000, timerProgressBar: true });
477
-
478
- // Variables pour le système de chargement
479
- let progressInterval;
480
- let currentProgress = 0;
481
- let storedThinkingContent = '';
482
- let storedResponseContent = '';
483
-
484
- // Messages de statut pour le loader
485
- const loadingMessages = [
486
- "Analyse du sujet...",
487
- "Structuration des idées...",
488
- "Recherche de références...",
489
- "Développement de l'argumentation...",
490
- "Formulation des conclusions...",
491
- "Finalisation de la réponse..."
492
- ];
493
-
494
- // Fonction pour démarrer le loader élégant
495
- function startElegantLoader() {
496
- // Cacher les sections précédentes
497
- $('#thinking-wrapper, #response, #action-buttons').addClass('hidden');
498
-
499
- // Afficher le loader
500
- $('#loading-section').removeClass('hidden').addClass('animate-fadeIn');
501
-
502
- // Reset du progrès
503
- currentProgress = 0;
504
- $('#progress-bar').css('width', '0%');
505
- $('#progress-text').text('0%');
506
-
507
- // Animation du progrès avec messages dynamiques
508
- progressInterval = setInterval(() => {
509
- // Incrément intelligent du progrès
510
- if (currentProgress < 30) {
511
- currentProgress += Math.random() * 8 + 2; // 2-10% par étape
512
- } else if (currentProgress < 70) {
513
- currentProgress += Math.random() * 5 + 1; // 1-6% par étape
514
- } else if (currentProgress < 95) {
515
- currentProgress += Math.random() * 2 + 0.5; // 0.5-2.5% par étape
516
- } else {
517
- currentProgress = Math.min(currentProgress + 0.1, 99); // Très lent vers la fin
518
- }
519
-
520
- // Mise à jour de l'interface
521
- $('#progress-bar').css('width', currentProgress + '%');
522
- $('#progress-text').text(Math.floor(currentProgress) + '%');
523
-
524
- // Changement des messages de statut
525
- const messageIndex = Math.floor(currentProgress / 16.67); // 6 messages répartis sur 100%
526
- if (messageIndex < loadingMessages.length) {
527
- $('#loading-status').text(loadingMessages[messageIndex]);
528
- }
529
-
530
- }, 200); // Mise à jour toutes les 200ms
531
- }
532
-
533
- // Fonction pour terminer le loader et afficher le contenu
534
- function finishLoaderAndDisplay() {
535
- // Terminer le progrès à 100%
536
- currentProgress = 100;
537
- $('#progress-bar').css('width', '100%');
538
- $('#progress-text').text('100%');
539
- $('#loading-status').text('Génération terminée !');
540
-
541
- clearInterval(progressInterval);
542
-
543
- // Attendre un peu puis masquer le loader et afficher le contenu
544
- setTimeout(() => {
545
- $('#loading-section').addClass('hidden');
546
-
547
- // Afficher le processus de pensée s'il existe
548
- if (storedThinkingContent) {
549
- $('#thinking-wrapper').removeClass('hidden').addClass('animate-fadeIn');
550
- displayContentWithRainEffect($('#thinking-process'), marked.parse(storedThinkingContent));
551
- }
552
-
553
- // Afficher la réponse avec effet de pluie
554
- if (storedResponseContent) {
555
- $('#response').removeClass('hidden').addClass('animate-fadeIn');
556
- displayContentWithRainEffect($('#response > div'), marked.parse(storedResponseContent));
557
- }
558
-
559
- }, 800); // Délai pour laisser le temps de voir 100%
560
- }
561
-
562
- // Fonction pour afficher le contenu avec effet de pluie (goutte par goutte)
563
- function displayContentWithRainEffect(container, htmlContent) {
564
- container.empty();
565
-
566
- // Créer un div temporaire pour parser le HTML
567
- const tempDiv = $('<div>').html(htmlContent);
568
-
569
- // Extraire tous les éléments et textes
570
- const elements = [];
571
-
572
- function extractElements(node) {
573
- $(node).contents().each(function() {
574
- if (this.nodeType === Node.TEXT_NODE && this.textContent.trim()) {
575
- // Diviser le texte en mots
576
- const words = this.textContent.split(/(\s+)/);
577
- words.forEach(word => {
578
- if (word.trim()) {
579
- elements.push({
580
- type: 'text',
581
- content: word,
582
- parent: $(this).parent()[0] ? $(this).parent()[0].tagName.toLowerCase() : 'span'
583
- });
584
- } else if (word) {
585
- elements.push({
586
- type: 'space',
587
- content: word,
588
- parent: $(this).parent()[0] ? $(this).parent()[0].tagName.toLowerCase() : 'span'
589
- });
590
- }
591
- });
592
- } else if (this.nodeType === Node.ELEMENT_NODE) {
593
- // Pour les éléments HTML complets (images, liens, etc.)
594
- if (['img', 'br', 'hr'].includes(this.tagName.toLowerCase())) {
595
- elements.push({
596
- type: 'element',
597
- content: this.outerHTML,
598
- parent: null
599
- });
600
- } else {
601
- extractElements(this);
602
- }
603
- }
604
- });
605
- }
606
-
607
- extractElements(tempDiv);
608
-
609
- // Variables pour la reconstruction
610
- let currentElement = null;
611
- let elementIndex = 0;
612
-
613
- // Fonction récursive pour afficher les éléments avec délai
614
- function showNextElement() {
615
- if (elementIndex >= elements.length) {
616
- // Afficher les boutons d'action
617
- $('#action-buttons').removeClass('hidden').addClass('animate-fadeIn');
618
- Toast.fire({ icon: 'success', title: 'Génération terminée !' });
619
- return;
620
- }
621
-
622
- const item = elements[elementIndex];
623
-
624
- // Créer ou continuer l'élément parent
625
- if (!currentElement || currentElement.prop('tagName').toLowerCase() !== item.parent) {
626
- if (currentElement) {
627
- container.append(currentElement);
628
- }
629
- currentElement = $(`<${item.parent}></${item.parent}>`);
630
- }
631
-
632
- // Créer un span pour l'animation
633
- let span;
634
- if (item.type === 'element') {
635
- span = $(item.content);
636
- } else {
637
- span = $('<span>').text(item.content).addClass('rain-text');
638
- }
639
-
640
- currentElement.append(span);
641
-
642
- // Animation de l'élément
643
- setTimeout(() => {
644
- span.removeClass('rain-text');
645
-
646
- // Scroll fluide
647
- const containerOffset = container.offset();
648
- const windowHeight = $(window).height();
649
- if (containerOffset && containerOffset.top > windowHeight * 0.7) {
650
- $('html, body').animate({
651
- scrollTop: containerOffset.top - windowHeight * 0.3
652
- }, 300);
653
- }
654
-
655
- elementIndex++;
656
- showNextElement();
657
- }, 50 + Math.random() * 100); // Délai variable pour un effet plus naturel
658
- }
659
-
660
- // Démarrer l'affichage
661
- showNextElement();
662
-
663
- // S'assurer que le dernier élément est ajouté
664
- setTimeout(() => {
665
- if (currentElement) {
666
- container.append(currentElement);
667
- }
668
- }, elements.length * 80);
669
- }
670
-
671
- // Variables pour optimiser le scroll
672
- let isScrolling = false;
673
- let scrollTimer = null;
674
- let lastScrollTime = 0;
675
-
676
- // Fonction de scroll optimisée avec throttling
677
- function smoothScrollToBottom(force = false) {
678
- const now = Date.now();
679
-
680
- // Throttling : éviter trop d'appels de scroll
681
- if (!force && now - lastScrollTime < 100) {
682
- return;
683
- }
684
-
685
- lastScrollTime = now;
686
-
687
- // Annuler le timer précédent s'il existe
688
- if (scrollTimer) {
689
- clearTimeout(scrollTimer);
690
- }
691
-
692
- // Utiliser requestAnimationFrame pour un scroll plus fluide
693
- if (!isScrolling) {
694
- isScrolling = true;
695
-
696
- requestAnimationFrame(() => {
697
- // Scroll fluide vers le bas avec une marge
698
- const targetScrollTop = Math.max(0, document.documentElement.scrollHeight - window.innerHeight - 50);
699
-
700
- // Utiliser la méthode native pour de meilleures performances
701
- window.scrollTo({
702
- top: targetScrollTop,
703
- behavior: 'smooth'
704
- });
705
-
706
- // Marquer comme terminé après l'animation
707
- scrollTimer = setTimeout(() => {
708
- isScrolling = false;
709
- }, 200);
710
- });
711
- }
712
- }
713
-
714
- // --- Gestion de l'interface ---
715
- $('#type-select').change(function() {
716
- const type = $(this).val();
717
- // Cacher les sections de résultat lors du changement de type
718
- $('#thinking-wrapper, #response, #action-buttons, #loading-section').addClass('hidden');
719
-
720
- if (type === '3') { // Sujet Type 3 (anciennement Analyse d'image)
721
- $('#text-input-container').hide();
722
- $('#image-input-container').show().addClass('animate-fadeIn');
723
- $('#deepthink-btn').hide();
724
- $('#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');
725
- $('label[for="image-upload"]').text("Charger un document pour analyse (image, etc.)");
726
- } else { // Dissertation texte
727
- $('#text-input-container').show().addClass('animate-fadeIn');
728
- $('#image-input-container').hide();
729
- $('#deepthink-btn').show();
730
- $('#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');
731
- }
732
- }).trigger('change');
733
-
734
- $('#image-upload').change(function(e) {
735
- if (e.target.files && e.target.files[0]) {
736
- const reader = new FileReader();
737
- reader.onload = (event) => $('#image-preview').attr('src', event.target.result).removeClass('hidden').addClass('animate-fadeIn');
738
- reader.readAsDataURL(e.target.files[0]);
739
- }
740
- });
741
-
742
- // --- Logique de Génération avec Nouveau Système de Loading ---
743
- async function handleStreamedGeneration(url, options) {
744
- // Démarrer le loader élégant
745
- startElegantLoader();
746
-
747
- // Réinitialiser le contenu stocké
748
- storedThinkingContent = '';
749
- storedResponseContent = '';
750
-
751
- try {
752
- const response = await fetch(url, options);
753
- if (!response.ok) throw new Error(await response.text());
754
-
755
- const reader = response.body.getReader();
756
- const decoder = new TextDecoder();
757
- let buffer = '';
758
-
759
- while (true) {
760
- const { value, done } = await reader.read();
761
- if (done) break;
762
-
763
- buffer += decoder.decode(value, { stream: true });
764
- const lines = buffer.split('\n');
765
- buffer = lines.pop();
766
-
767
- for (const line of lines) {
768
- if (line.trim() === '') continue;
769
- try {
770
- const data = JSON.parse(line.trim());
771
-
772
- if (data.type === 'thought') {
773
- storedThinkingContent += data.content;
774
- } else if (data.type === 'answer') {
775
- storedResponseContent += data.content;
776
- } else if (data.type === 'error') {
777
- throw new Error(data.content);
778
- }
779
- } catch (e) {
780
- console.error("Erreur JSON parse:", line, e);
781
- }
782
- }
783
- }
784
-
785
- // Une fois le streaming terminé, finaliser le loader et afficher le contenu
786
- finishLoaderAndDisplay();
787
-
788
- // Sauvegarder la dissertation
789
- let title;
790
- if ($('#type-select').val() === '3') {
791
- const fileName = $('#image-upload')[0].files[0]?.name || "Analyse de document";
792
- title = `Analyse (Sujet Type 3): ${fileName}`;
793
- } else {
794
- title = $('#question').val().trim();
795
- }
796
- saveDissertation(title, storedResponseContent);
797
-
798
- } catch (error) {
799
- clearInterval(progressInterval);
800
- $('#loading-section').addClass('hidden');
801
- Swal.fire({ icon: 'error', title: 'Erreur', text: error.message || "Une erreur inconnue est survenue." });
802
- }
803
- }
804
-
805
- // --- Gestion des Clics ---
806
- $('#submit-btn, #deepthink-btn').click(function() {
807
- const type = $('#type-select').val();
808
- const isDeepThink = $(this).attr('id') === 'deepthink-btn';
809
-
810
- if (type === '3') {
811
- const imageFile = $('#image-upload')[0].files[0];
812
- if (!imageFile) { Swal.fire('Erreur', 'Veuillez sélectionner un document.', 'error'); return; }
813
- const formData = new FormData();
814
- formData.append('image', imageFile);
815
- handleStreamedGeneration('/stream_philo_image', { method: 'POST', body: formData });
816
- } else {
817
- const question = $('#question').val().trim();
818
- if (!question) { Swal.fire('Erreur', 'Veuillez saisir un sujet.', 'error'); return; }
819
- const data = { question, type, courseId: $('#course-select').val() || null };
820
- const url = isDeepThink ? '/stream_philo_deepthink' : '/stream_philo';
821
- handleStreamedGeneration(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
822
- }
823
- });
824
-
825
- // --- Fonctions de gestion de l'historique ---
826
- function loadCourses() {
827
- const courses = [
828
- { id: 1, title: "Introduction à la philosophie", author: "Martin" },
829
- { id: 2, title: "Éthique et morale", author: "Dubois" },
830
- { id: 3, title: "Métaphysique moderne", author: "Bernard" },
831
- { id: 4, title: "Philosophie politique", author: "Rousseau" },
832
- { id: 5, title: "Esthétique et art", author: "Delacroix" }
833
- ];
834
-
835
- const select = $('#course-select');
836
- courses.forEach(course => {
837
- const newOption = new Option(course.title, course.id, false, false);
838
- $(newOption).data('author', course.author);
839
- select.append(newOption);
840
- });
841
- select.trigger('change');
842
- }
843
- loadCourses();
844
-
845
- function saveDissertation(title, content) {
846
- if (!title || !content) return;
847
- let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
848
- saved.unshift({ title, content, timestamp: Date.now() });
849
- if(saved.length > 10) saved.pop();
850
- localStorage.setItem('dissertations', JSON.stringify(saved));
851
- updateSavedDissertationsList();
852
- }
853
-
854
- function deleteDissertation(index) {
855
- let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
856
- saved.splice(index, 1);
857
- localStorage.setItem('dissertations', JSON.stringify(saved));
858
- updateSavedDissertationsList();
859
- Toast.fire({ icon: 'info', title: 'Dissertation supprimée' });
860
- }
861
-
862
- function updateSavedDissertationsList() {
863
- const list = $('#dissertations-list');
864
- list.empty();
865
- let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
866
- if (saved.length === 0) {
867
- list.append('<p class="text-gray-500 text-center py-4">Aucune dissertation dans l\'historique.</p>');
868
- return;
869
- }
870
- saved.forEach((diss, index) => {
871
- const date = moment(diss.timestamp).fromNow();
872
- const title = diss.title.length > 60 ? diss.title.substring(0, 60) + '...' : diss.title;
873
- const item = $(`
874
- <div class="border border-gray-200 bg-white rounded-xl shadow-sm transition-shadow hover:shadow-md">
875
- <button class="collapsible rounded-t-xl w-full text-left">
876
- <div class="flex justify-between items-center w-full p-4">
877
- <span class="font-medium text-gray-800">${title}</span>
878
- <span class="text-gray-500 text-sm flex-shrink-0 ml-4">${date}</span>
879
- </div>
880
- </button>
881
- <div class="content prose max-w-none border-t border-gray-200">
882
- <div class="inner-content p-4 content-scrollable"></div>
883
- <div class="p-4 border-t border-gray-200 bg-gray-50 rounded-b-xl">
884
- <button class="delete-btn text-sm text-red-600 hover:text-red-800 font-medium" data-index="${index}">Supprimer</button>
885
- </div>
886
- </div>
887
- </div>
888
- `);
889
- item.find('.inner-content').html(marked.parse(diss.content));
890
- list.append(item);
891
- });
892
- }
893
-
894
- // Optimiser l'ouverture des dissertations avec une transition plus fluide
895
- $('#dissertations-list').on('click', '.collapsible', function() {
896
- const content = $(this).next('.content');
897
- const isVisible = content.is(':visible');
898
-
899
- // Animation plus fluide avec easing
900
- content.stop(true, true).slideToggle({
901
- duration: 300,
902
- easing: 'swing',
903
- start: function() {
904
- $(this).css('overflow', 'hidden');
905
- },
906
- complete: function() {
907
- $(this).css('overflow', isVisible ? 'hidden' : 'visible');
908
- }
909
- });
910
-
911
- $(this).toggleClass("active");
912
- });
913
-
914
- $('#dissertations-list').on('click', '.delete-btn', function(e) {
915
- e.stopPropagation(); // Empêcher le collapsible de se fermer
916
- const index = $(this).data('index');
917
- deleteDissertation(index);
918
- });
919
-
920
- $('#copy-btn').click(function() {
921
- const htmlToCopy = $('#response > div').html();
922
- // Pour copier le Markdown brut (plus fidèle)
923
- const textToCopy = new DOMParser().parseFromString(htmlToCopy, 'text/html').body.textContent || "";
924
- navigator.clipboard.writeText(textToCopy).then(() => {
925
- Toast.fire({ icon: 'success', title: 'Copié dans le presse-papiers!' });
926
- }).catch(() => {
927
- Toast.fire({ icon: 'error', title: 'Erreur de copie' });
928
- });
929
- });
930
-
931
- // Optimisation pour les événements de scroll sur mobile
932
- let ticking = false;
933
-
934
- function updateScrollPosition() {
935
- // Code pour gérer les changements de position de scroll si nécessaire
936
- ticking = false;
937
- }
938
-
939
- window.addEventListener('scroll', function() {
940
- if (!ticking) {
941
- requestAnimationFrame(updateScrollPosition);
942
- ticking = true;
943
- }
944
- }, { passive: true });
945
-
946
- // Optimisation du resize pour mobile
947
- let resizeTimer;
948
- window.addEventListener('resize', function() {
949
- clearTimeout(resizeTimer);
950
- resizeTimer = setTimeout(function() {
951
- // Recalculer les dimensions si nécessaire
952
- if (window.innerWidth <= 640) {
953
- // Optimisations spécifiques mobile
954
- $('body').addClass('mobile-optimized');
955
- } else {
956
- $('body').removeClass('mobile-optimized');
957
- }
958
- }, 250);
959
- }, { passive: true });
960
-
961
- // Optimisation tactile pour mobile
962
- if ('ontouchstart' in window) {
963
- $('body').addClass('touch-device');
964
-
965
- // Améliorer les interactions tactiles
966
- $(document).on('touchstart', 'button, .collapsible', function() {
967
- $(this).addClass('touch-active');
968
- });
969
-
970
- $(document).on('touchend', 'button, .collapsible', function() {
971
- const element = $(this);
972
- setTimeout(() => element.removeClass('touch-active'), 150);
973
- });
974
- }
975
-
976
- // Init
977
- updateSavedDissertationsList();
978
- });
979
- </script>
980
- </body>
981
- </html>