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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/[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 |
+
/* 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 Select2 */
|
113 |
+
.select2-container--default .select2-selection--single {
|
114 |
+
border: 1px solid #d1d5db;
|
115 |
+
border-radius: 0.75rem;
|
116 |
+
height: auto;
|
117 |
+
padding: 0.75rem 1rem;
|
118 |
+
background-color: white;
|
119 |
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
120 |
+
}
|
121 |
+
|
122 |
+
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
123 |
+
color: #111827;
|
124 |
+
line-height: inherit;
|
125 |
+
padding-right: 1.5rem;
|
126 |
+
}
|
127 |
+
|
128 |
+
.select2-results__option .course-author {
|
129 |
+
font-size: 0.875rem;
|
130 |
+
color: #6b7280;
|
131 |
+
display: block;
|
132 |
+
margin-top: 0.1rem;
|
133 |
+
}
|
134 |
+
|
135 |
+
.select2-dropdown {
|
136 |
+
border-radius: 0.75rem;
|
137 |
+
border: 1px solid #d1d5db;
|
138 |
+
box-shadow: 0 4px 6px -1px rgba(0,0,0,.1);
|
139 |
+
}
|
140 |
+
|
141 |
+
/* Styles pour l'aperçu de l'image */
|
142 |
+
#image-preview {
|
143 |
+
max-height: 200px;
|
144 |
+
border-radius: 0.75rem;
|
145 |
+
box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
|
146 |
+
}
|
147 |
+
|
148 |
+
/* Cacher le marqueur par défaut de <details> */
|
149 |
+
summary {
|
150 |
+
list-style: none;
|
151 |
+
}
|
152 |
+
|
153 |
+
summary::-webkit-details-marker {
|
154 |
+
display: none;
|
155 |
+
}
|
156 |
+
|
157 |
+
/* Optimisations mobiles */
|
158 |
+
@media (max-width: 640px) {
|
159 |
+
/* Réduire les marges sur mobile pour plus d'espace */
|
160 |
+
.max-w-3xl {
|
161 |
+
max-width: 100%;
|
162 |
+
margin-left: 0.5rem;
|
163 |
+
margin-right: 0.5rem;
|
164 |
+
}
|
165 |
+
|
166 |
+
/* Optimiser l'affichage des sections de contenu */
|
167 |
+
#response, #thinking-wrapper {
|
168 |
+
/* Éviter les débordements horizontaux */
|
169 |
+
overflow-x: hidden;
|
170 |
+
}
|
171 |
+
|
172 |
+
/* Améliorer la lisibilité du texte généré */
|
173 |
+
.prose {
|
174 |
+
font-size: 0.95rem;
|
175 |
+
line-height: 1.6;
|
176 |
+
}
|
177 |
+
|
178 |
+
/* Réduire l'animation pour économiser la batterie */
|
179 |
+
.animate-fadeIn {
|
180 |
+
animation-duration: 0.2s;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
/* Conteneur de génération avec scroll optimisé */
|
185 |
+
.generation-container {
|
186 |
+
/* Conteneur stable pour éviter les recalculs de layout */
|
187 |
+
contain: layout style;
|
188 |
+
/* Optimiser les performances de scroll */
|
189 |
+
transform: translateZ(0);
|
190 |
+
}
|
191 |
+
|
192 |
+
/* Améliorer les performances du textarea */
|
193 |
+
textarea {
|
194 |
+
/* Éviter les reflows pendant la saisie */
|
195 |
+
resize: none;
|
196 |
+
/* Optimiser sur mobile */
|
197 |
+
-webkit-appearance: none;
|
198 |
+
}
|
199 |
+
|
200 |
+
/* Optimiser les boutons pour le tactile */
|
201 |
+
button {
|
202 |
+
touch-action: manipulation;
|
203 |
+
-webkit-tap-highlight-color: transparent;
|
204 |
+
transition: var(--transition-fast);
|
205 |
+
}
|
206 |
+
|
207 |
+
/* Scroll fluide pour les éléments avec beaucoup de contenu */
|
208 |
+
.content-scrollable {
|
209 |
+
-webkit-overflow-scrolling: touch;
|
210 |
+
scroll-behavior: smooth;
|
211 |
+
}
|
212 |
+
</style>
|
213 |
+
</head>
|
214 |
+
<body class="bg-gray-50 text-gray-900">
|
215 |
+
<!-- Navbar -->
|
216 |
+
<nav class="bg-white/90 backdrop-blur-lg border-b border-gray-200 fixed w-full z-50">
|
217 |
+
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
|
218 |
+
<div class="flex justify-between items-center h-16">
|
219 |
+
<div class="flex items-center space-x-3">
|
220 |
+
<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">
|
221 |
+
<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" />
|
222 |
+
</svg>
|
223 |
+
<div class="text-xl font-bold text-gray-800">Mariam AI</div>
|
224 |
+
</div>
|
225 |
+
<div class="flex items-center">
|
226 |
+
<span class="inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-violet-100 text-violet-800">
|
227 |
+
Assistant Philosophique
|
228 |
+
</span>
|
229 |
+
</div>
|
230 |
+
</div>
|
231 |
+
</div>
|
232 |
+
</nav>
|
233 |
+
|
234 |
+
<!-- Main Content -->
|
235 |
+
<main class="pt-24 pb-16 px-4 sm:px-6 lg:px-8">
|
236 |
+
<div class="max-w-3xl mx-auto">
|
237 |
+
<div class="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden">
|
238 |
+
<div class="p-6 sm:p-8">
|
239 |
+
<div class="text-center">
|
240 |
+
<h1 class="text-3xl font-bold text-gray-900">Gen'Dissertation</h1>
|
241 |
+
<p class="mt-2 text-md text-gray-600">Créez des dissertations et analyses pertinentes et structurées.</p>
|
242 |
+
</div>
|
243 |
+
</div>
|
244 |
+
|
245 |
+
<div class="p-6 sm:p-8 border-t border-gray-200 space-y-6">
|
246 |
+
<!-- Type Selection -->
|
247 |
+
<div class="space-y-2">
|
248 |
+
<label for="type-select" class="block text-sm font-medium text-gray-700">Type de travail</label>
|
249 |
+
<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">
|
250 |
+
<option value="1">Sujet Type 1</option>
|
251 |
+
<option value="2">Sujet Type 2 (Citation)</option>
|
252 |
+
<option value="3">Sujet Type 3</option>
|
253 |
+
</select>
|
254 |
+
</div>
|
255 |
+
|
256 |
+
<!-- Conteneur pour les champs texte (visible par défaut) -->
|
257 |
+
<div id="text-input-container">
|
258 |
+
<!-- Course Selection -->
|
259 |
+
<div class="space-y-2">
|
260 |
+
<label for="course-select" class="block text-sm font-medium text-gray-700">Utiliser un cours comme contexte</label>
|
261 |
+
<select id="course-select" class="w-full">
|
262 |
+
<option value="">Choisir un cours...</option>
|
263 |
+
</select>
|
264 |
+
</div>
|
265 |
+
<!-- Question Input -->
|
266 |
+
<div class="space-y-2 mt-4">
|
267 |
+
<label for="question" class="block text-sm font-medium text-gray-700">Sujet de dissertation</label>
|
268 |
+
<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>
|
269 |
+
</div>
|
270 |
+
</div>
|
271 |
+
|
272 |
+
<!-- Conteneur pour l'upload d'image (caché par défaut) -->
|
273 |
+
<div id="image-input-container" class="hidden">
|
274 |
+
<div class="space-y-2">
|
275 |
+
<label for="image-upload" class="block text-sm font-medium text-gray-700">Charger un document pour analyse</label>
|
276 |
+
<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"/>
|
277 |
+
<div class="mt-4 flex justify-center"><img id="image-preview" src="" alt="Aperçu de l'image" class="hidden"/></div>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
+
|
281 |
+
<!-- Submit Button -->
|
282 |
+
<div class="pt-4">
|
283 |
+
<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">
|
284 |
+
<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>
|
285 |
+
Générer la dissertation
|
286 |
+
</button>
|
287 |
+
</div>
|
288 |
+
</div>
|
289 |
+
</div>
|
290 |
+
|
291 |
+
<!-- Thinking Process Section (Collapsible) -->
|
292 |
+
<div id="thinking-wrapper" class="hidden mt-8 generation-container">
|
293 |
+
<details id="thinking-container" class="bg-white border border-gray-200 rounded-xl shadow-sm">
|
294 |
+
<summary class="flex justify-between items-center p-4 cursor-pointer">
|
295 |
+
<h3 class="text-md font-semibold text-gray-700">Processus de pensée de l'IA</h3>
|
296 |
+
<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">
|
297 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
298 |
+
</svg>
|
299 |
+
</summary>
|
300 |
+
<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">
|
301 |
+
<!-- Le contenu du processus de pensée sera injecté ici -->
|
302 |
+
</div>
|
303 |
+
</details>
|
304 |
+
</div>
|
305 |
+
|
306 |
+
<!-- Response Section -->
|
307 |
+
<div id="response" class="hidden mt-6 generation-container">
|
308 |
+
<div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 sm:p-8 prose prose-violet max-w-none">
|
309 |
+
<!-- Le contenu de la réponse sera injecté ici -->
|
310 |
+
</div>
|
311 |
+
</div>
|
312 |
+
|
313 |
+
<!-- Action Buttons after generation -->
|
314 |
+
<div id="action-buttons" class="hidden mt-6 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
315 |
+
<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">
|
316 |
+
<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>
|
317 |
+
Copier le texte
|
318 |
+
</button>
|
319 |
+
</div>
|
320 |
+
|
321 |
+
<!-- Saved Dissertations Section -->
|
322 |
+
<div class="mt-12">
|
323 |
+
<h3 class="text-xl font-bold text-gray-800 mb-4">Historique</h3>
|
324 |
+
<div id="dissertations-list" class="space-y-3">
|
325 |
+
<!-- La liste des dissertations sauvegardées sera injectée ici -->
|
326 |
+
</div>
|
327 |
+
</div>
|
328 |
+
</div>
|
329 |
+
</main>
|
330 |
+
|
331 |
+
<!-- Bouton flottant DeepThink -->
|
332 |
+
<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">
|
333 |
+
<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>
|
334 |
+
DeepThink
|
335 |
+
</button>
|
336 |
+
|
337 |
+
<script>
|
338 |
+
$(document).ready(function() {
|
339 |
+
// --- Initialisations ---
|
340 |
+
$('#course-select').select2({
|
341 |
+
placeholder: 'Optionnel : choisir un cours...',
|
342 |
+
allowClear: true,
|
343 |
+
templateResult: function (course) { if (!course.id) { return course.text; } return $(`<span>${course.text}</span><span class="course-author">Pr. ${$(course.element).data('author')}</span>`); },
|
344 |
+
templateSelection: function (course) { return course.text; },
|
345 |
+
});
|
346 |
+
marked.setOptions({ breaks: true, gfm: true, headerIds: false, mangle: false });
|
347 |
+
moment.locale('fr');
|
348 |
+
const Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 3000, timerProgressBar: true });
|
349 |
+
|
350 |
+
// Variables pour optimiser le scroll
|
351 |
+
let isScrolling = false;
|
352 |
+
let scrollTimer = null;
|
353 |
+
let lastScrollTime = 0;
|
354 |
+
|
355 |
+
// Fonction de scroll optimisée avec throttling
|
356 |
+
function smoothScrollToBottom(force = false) {
|
357 |
+
const now = Date.now();
|
358 |
+
|
359 |
+
// Throttling : éviter trop d'appels de scroll
|
360 |
+
if (!force && now - lastScrollTime < 100) {
|
361 |
+
return;
|
362 |
+
}
|
363 |
+
|
364 |
+
lastScrollTime = now;
|
365 |
+
|
366 |
+
// Annuler le timer précédent s'il existe
|
367 |
+
if (scrollTimer) {
|
368 |
+
clearTimeout(scrollTimer);
|
369 |
+
}
|
370 |
+
|
371 |
+
// Utiliser requestAnimationFrame pour un scroll plus fluide
|
372 |
+
if (!isScrolling) {
|
373 |
+
isScrolling = true;
|
374 |
+
|
375 |
+
requestAnimationFrame(() => {
|
376 |
+
// Scroll fluide vers le bas avec une marge
|
377 |
+
const targetScrollTop = Math.max(0, document.documentElement.scrollHeight - window.innerHeight - 50);
|
378 |
+
|
379 |
+
// Utiliser la méthode native pour de meilleures performances
|
380 |
+
window.scrollTo({
|
381 |
+
top: targetScrollTop,
|
382 |
+
behavior: 'smooth'
|
383 |
+
});
|
384 |
+
|
385 |
+
// Marquer comme terminé après l'animation
|
386 |
+
scrollTimer = setTimeout(() => {
|
387 |
+
isScrolling = false;
|
388 |
+
}, 200);
|
389 |
+
});
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
// --- Gestion de l'interface ---
|
394 |
+
$('#type-select').change(function() {
|
395 |
+
const type = $(this).val();
|
396 |
+
// Cacher les sections de résultat lors du changement de type
|
397 |
+
$('#thinking-wrapper, #response, #action-buttons').addClass('hidden');
|
398 |
+
|
399 |
+
if (type === '3') { // Sujet Type 3 (anciennement Analyse d'image)
|
400 |
+
$('#text-input-container').hide();
|
401 |
+
$('#image-input-container').show().addClass('animate-fadeIn');
|
402 |
+
$('#deepthink-btn').hide();
|
403 |
+
$('#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');
|
404 |
+
$('label[for="image-upload"]').text("Charger un document pour analyse (image, etc.)");
|
405 |
+
} else { // Dissertation texte
|
406 |
+
$('#text-input-container').show().addClass('animate-fadeIn');
|
407 |
+
$('#image-input-container').hide();
|
408 |
+
$('#deepthink-btn').show();
|
409 |
+
$('#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');
|
410 |
+
}
|
411 |
+
}).trigger('change');
|
412 |
+
|
413 |
+
$('#image-upload').change(function(e) {
|
414 |
+
if (e.target.files && e.target.files[0]) {
|
415 |
+
const reader = new FileReader();
|
416 |
+
reader.onload = (event) => $('#image-preview').attr('src', event.target.result).removeClass('hidden').addClass('animate-fadeIn');
|
417 |
+
reader.readAsDataURL(e.target.files[0]);
|
418 |
+
}
|
419 |
+
});
|
420 |
+
|
421 |
+
// --- Logique de Génération en Streaming Optimisée ---
|
422 |
+
async function handleStreamedGeneration(url, options) {
|
423 |
+
Swal.fire({ title: 'Génération en cours...', html: 'Connexion au service IA...', allowOutsideClick: false, showConfirmButton: false, didOpen: () => Swal.showLoading() });
|
424 |
+
|
425 |
+
$('#thinking-wrapper, #response, #action-buttons').addClass('hidden');
|
426 |
+
$('#thinking-container').prop('open', false);
|
427 |
+
const thinkingDiv = $('#thinking-process');
|
428 |
+
const responseDiv = $('#response > div');
|
429 |
+
thinkingDiv.html('');
|
430 |
+
responseDiv.html('');
|
431 |
+
let fullResponseText = '', fullThinkingText = '', firstChunkReceived = false;
|
432 |
+
|
433 |
+
// Compteur pour optimiser les updates
|
434 |
+
let chunkCount = 0;
|
435 |
+
const updateFrequency = 3; // Mettre à jour tous les 3 chunks pour réduire les recalculs
|
436 |
+
|
437 |
+
try {
|
438 |
+
const response = await fetch(url, options);
|
439 |
+
if (!response.ok) throw new Error(await response.text());
|
440 |
+
|
441 |
+
const reader = response.body.getReader();
|
442 |
+
const decoder = new TextDecoder();
|
443 |
+
let buffer = '';
|
444 |
+
|
445 |
+
while (true) {
|
446 |
+
const { value, done } = await reader.read();
|
447 |
+
if (!firstChunkReceived && (value || done)) {
|
448 |
+
Swal.close();
|
449 |
+
firstChunkReceived = true;
|
450 |
+
}
|
451 |
+
if (done) break;
|
452 |
+
|
453 |
+
buffer += decoder.decode(value, { stream: true });
|
454 |
+
const lines = buffer.split('\n');
|
455 |
+
buffer = lines.pop();
|
456 |
+
|
457 |
+
let shouldUpdate = false;
|
458 |
+
|
459 |
+
for (const line of lines) {
|
460 |
+
if (line.trim() === '') continue;
|
461 |
+
try {
|
462 |
+
const data = JSON.parse(line.trim());
|
463 |
+
chunkCount++;
|
464 |
+
|
465 |
+
if (data.type === 'thought') {
|
466 |
+
if (!$('#thinking-wrapper').is(':visible')) {
|
467 |
+
$('#thinking-wrapper').removeClass('hidden').addClass('animate-fadeIn');
|
468 |
+
}
|
469 |
+
fullThinkingText += data.content;
|
470 |
+
shouldUpdate = true;
|
471 |
+
} else if (data.type === 'answer') {
|
472 |
+
if (!$('#response').is(':visible')) {
|
473 |
+
$('#response').removeClass('hidden').addClass('animate-fadeIn');
|
474 |
+
}
|
475 |
+
fullResponseText += data.content;
|
476 |
+
shouldUpdate = true;
|
477 |
+
} else if (data.type === 'error') {
|
478 |
+
throw new Error(data.content);
|
479 |
+
}
|
480 |
+
} catch (e) {
|
481 |
+
console.error("Erreur JSON parse:", line, e);
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
// Mettre à jour le DOM moins fréquemment pour de meilleures performances
|
486 |
+
if (shouldUpdate && (chunkCount % updateFrequency === 0 || done)) {
|
487 |
+
if (fullThinkingText) {
|
488 |
+
thinkingDiv.html(marked.parse(fullThinkingText));
|
489 |
+
}
|
490 |
+
if (fullResponseText) {
|
491 |
+
responseDiv.html(marked.parse(fullResponseText));
|
492 |
+
}
|
493 |
+
|
494 |
+
// Scroll optimisé vers le bas
|
495 |
+
smoothScrollToBottom();
|
496 |
+
}
|
497 |
+
}
|
498 |
+
|
499 |
+
// Mise à jour finale
|
500 |
+
if (fullThinkingText) {
|
501 |
+
thinkingDiv.html(marked.parse(fullThinkingText));
|
502 |
+
}
|
503 |
+
if (fullResponseText) {
|
504 |
+
responseDiv.html(marked.parse(fullResponseText));
|
505 |
+
}
|
506 |
+
|
507 |
+
$('#action-buttons').removeClass('hidden').addClass('animate-fadeIn');
|
508 |
+
Toast.fire({ icon: 'success', title: 'Génération terminée !' });
|
509 |
+
|
510 |
+
let title;
|
511 |
+
if ($('#type-select').val() === '3') {
|
512 |
+
const fileName = $('#image-upload')[0].files[0]?.name || "Analyse de document";
|
513 |
+
title = `Analyse (Sujet Type 3): ${fileName}`;
|
514 |
+
} else {
|
515 |
+
title = $('#question').val().trim();
|
516 |
+
}
|
517 |
+
saveDissertation(title, fullResponseText);
|
518 |
+
|
519 |
+
// Scroll final pour s'assurer que tout est visible
|
520 |
+
smoothScrollToBottom(true);
|
521 |
+
|
522 |
+
} catch (error) {
|
523 |
+
Swal.fire({ icon: 'error', title: 'Erreur', text: error.message || "Une erreur inconnue est survenue." });
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
// --- Gestion des Clics ---
|
528 |
+
$('#submit-btn, #deepthink-btn').click(function() {
|
529 |
+
const type = $('#type-select').val();
|
530 |
+
const isDeepThink = $(this).attr('id') === 'deepthink-btn';
|
531 |
+
|
532 |
+
if (type === '3') {
|
533 |
+
const imageFile = $('#image-upload')[0].files[0];
|
534 |
+
if (!imageFile) { Swal.fire('Erreur', 'Veuillez sélectionner un document.', 'error'); return; }
|
535 |
+
const formData = new FormData();
|
536 |
+
formData.append('image', imageFile);
|
537 |
+
handleStreamedGeneration('/stream_philo_image', { method: 'POST', body: formData });
|
538 |
+
} else {
|
539 |
+
const question = $('#question').val().trim();
|
540 |
+
if (!question) { Swal.fire('Erreur', 'Veuillez saisir un sujet.', 'error'); return; }
|
541 |
+
const data = { question, type, courseId: $('#course-select').val() || null };
|
542 |
+
const url = isDeepThink ? '/stream_philo_deepthink' : '/stream_philo';
|
543 |
+
handleStreamedGeneration(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
|
544 |
+
}
|
545 |
+
});
|
546 |
+
|
547 |
+
// --- Fonctions de gestion de l'historique ---
|
548 |
+
function loadCourses() {
|
549 |
+
$.ajax({
|
550 |
+
url: '/api/philosophy/courses',
|
551 |
+
method: 'GET',
|
552 |
+
}).done(function(courses) {
|
553 |
+
const select = $('#course-select');
|
554 |
+
courses.forEach(course => {
|
555 |
+
const newOption = new Option(course.title, course.id, false, false);
|
556 |
+
$(newOption).data('author', course.author);
|
557 |
+
select.append(newOption);
|
558 |
+
});
|
559 |
+
select.trigger('change');
|
560 |
+
}).fail(function() {
|
561 |
+
Toast.fire({ icon: 'error', title: 'Erreur de chargement des cours' });
|
562 |
+
});
|
563 |
+
}
|
564 |
+
loadCourses();
|
565 |
+
|
566 |
+
function saveDissertation(title, content) {
|
567 |
+
if (!title || !content) return;
|
568 |
+
let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
|
569 |
+
saved.unshift({ title, content, timestamp: Date.now() });
|
570 |
+
if(saved.length > 10) saved.pop();
|
571 |
+
localStorage.setItem('dissertations', JSON.stringify(saved));
|
572 |
+
updateSavedDissertationsList();
|
573 |
+
}
|
574 |
+
|
575 |
+
function deleteDissertation(index) {
|
576 |
+
let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
|
577 |
+
saved.splice(index, 1);
|
578 |
+
localStorage.setItem('dissertations', JSON.stringify(saved));
|
579 |
+
updateSavedDissertationsList();
|
580 |
+
Toast.fire({ icon: 'info', title: 'Dissertation supprimée' });
|
581 |
+
}
|
582 |
+
|
583 |
+
function updateSavedDissertationsList() {
|
584 |
+
const list = $('#dissertations-list');
|
585 |
+
list.empty();
|
586 |
+
let saved = JSON.parse(localStorage.getItem('dissertations')) || [];
|
587 |
+
if (saved.length === 0) {
|
588 |
+
list.append('<p class="text-gray-500 text-center py-4">Aucune dissertation dans l\'historique.</p>');
|
589 |
+
return;
|
590 |
+
}
|
591 |
+
saved.forEach((diss, index) => {
|
592 |
+
const date = moment(diss.timestamp).fromNow();
|
593 |
+
const title = diss.title.length > 60 ? diss.title.substring(0, 60) + '...' : diss.title;
|
594 |
+
const item = $(`
|
595 |
+
<div class="border border-gray-200 bg-white rounded-xl shadow-sm transition-shadow hover:shadow-md">
|
596 |
+
<button class="collapsible rounded-t-xl w-full text-left">
|
597 |
+
<div class="flex justify-between items-center w-full p-4">
|
598 |
+
<span class="font-medium text-gray-800">${title}</span>
|
599 |
+
<span class="text-gray-500 text-sm flex-shrink-0 ml-4">${date}</span>
|
600 |
+
</div>
|
601 |
+
</button>
|
602 |
+
<div class="content prose max-w-none border-t border-gray-200">
|
603 |
+
<div class="inner-content p-4 content-scrollable"></div>
|
604 |
+
<div class="p-4 border-t border-gray-200 bg-gray-50 rounded-b-xl">
|
605 |
+
<button class="delete-btn text-sm text-red-600 hover:text-red-800 font-medium" data-index="${index}">Supprimer</button>
|
606 |
+
</div>
|
607 |
+
</div>
|
608 |
+
</div>
|
609 |
+
`);
|
610 |
+
item.find('.inner-content').html(marked.parse(diss.content));
|
611 |
+
list.append(item);
|
612 |
+
});
|
613 |
+
}
|
614 |
+
|
615 |
+
// Optimiser l'ouverture des dissertations avec une transition plus fluide
|
616 |
+
$('#dissertations-list').on('click', '.collapsible', function() {
|
617 |
+
const content = $(this).next('.content');
|
618 |
+
const isVisible = content.is(':visible');
|
619 |
+
|
620 |
+
// Animation plus fluide avec easing
|
621 |
+
content.stop(true, true).slideToggle({
|
622 |
+
duration: 300,
|
623 |
+
easing: 'swing',
|
624 |
+
start: function() {
|
625 |
+
$(this).css('overflow', 'hidden');
|
626 |
+
},
|
627 |
+
complete: function() {
|
628 |
+
$(this).css('overflow', isVisible ? 'hidden' : 'visible');
|
629 |
+
}
|
630 |
+
});
|
631 |
+
|
632 |
+
$(this).toggleClass("active");
|
633 |
+
});
|
634 |
+
|
635 |
+
$('#dissertations-list').on('click', '.delete-btn', function(e) {
|
636 |
+
e.stopPropagation(); // Empêcher le collapsible de se fermer
|
637 |
+
const index = $(this).data('index');
|
638 |
+
deleteDissertation(index);
|
639 |
+
});
|
640 |
+
|
641 |
+
$('#copy-btn').click(function() {
|
642 |
+
const htmlToCopy = $('#response > div').html();
|
643 |
+
// Pour copier le Markdown brut (plus fidèle)
|
644 |
+
const textToCopy = new DOMParser().parseFromString(htmlToCopy, 'text/html').body.textContent || "";
|
645 |
+
navigator.clipboard.writeText(textToCopy).then(() => {
|
646 |
+
Toast.fire({ icon: 'success', title: 'Copié dans le presse-papiers!' });
|
647 |
+
}).catch(() => {
|
648 |
+
Toast.fire({ icon: 'error', title: 'Erreur de copie' });
|
649 |
+
});
|
650 |
+
});
|
651 |
+
|
652 |
+
// Optimisation pour les événements de scroll sur mobile
|
653 |
+
let ticking = false;
|
654 |
+
|
655 |
+
function updateScrollPosition() {
|
656 |
+
// Code pour gérer les changements de position de scroll si nécessaire
|
657 |
+
ticking = false;
|
658 |
+
}
|
659 |
+
|
660 |
+
window.addEventListener('scroll', function() {
|
661 |
+
if (!ticking) {
|
662 |
+
requestAnimationFrame(updateScrollPosition);
|
663 |
+
ticking = true;
|
664 |
+
}
|
665 |
+
}, { passive: true });
|
666 |
+
|
667 |
+
// Optimisation du resize pour mobile
|
668 |
+
let resizeTimer;
|
669 |
+
window.addEventListener('resize', function() {
|
670 |
+
clearTimeout(resizeTimer);
|
671 |
+
resizeTimer = setTimeout(function() {
|
672 |
+
// Recalculer les dimensions si nécessaire
|
673 |
+
if (window.innerWidth <= 640) {
|
674 |
+
// Optimisations spécifiques mobile
|
675 |
+
$('body').addClass('mobile-optimized');
|
676 |
+
} else {
|
677 |
+
$('body').removeClass('mobile-optimized');
|
678 |
+
}
|
679 |
+
}, 250);
|
680 |
+
}, { passive: true });
|
681 |
+
|
682 |
+
// Optimisation tactile pour mobile
|
683 |
+
if ('ontouchstart' in window) {
|
684 |
+
$('body').addClass('touch-device');
|
685 |
+
|
686 |
+
// Améliorer les interactions tactiles
|
687 |
+
$(document).on('touchstart', 'button, .collapsible', function() {
|
688 |
+
$(this).addClass('touch-active');
|
689 |
+
});
|
690 |
+
|
691 |
+
$(document).on('touchend', 'button, .collapsible', function() {
|
692 |
+
const element = $(this);
|
693 |
+
setTimeout(() => element.removeClass('touch-active'), 150);
|
694 |
+
});
|
695 |
+
}
|
696 |
+
|
697 |
+
// Init
|
698 |
+
updateSavedDissertationsList();
|
699 |
+
});
|
700 |
+
</script>
|
701 |
+
</body>
|
702 |
+
</html>
|