Spaces:
Running
Running
Update templates/philosophie.html
Browse files- templates/philosophie.html +234 -119
templates/philosophie.html
CHANGED
|
@@ -141,150 +141,265 @@
|
|
| 141 |
</div>
|
| 142 |
</div>
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
$(document).ready(function() {
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
customClass: {
|
| 166 |
-
popup: 'rounded-lg shadow-xl border border-gray-100'
|
| 167 |
}
|
| 168 |
-
|
|
|
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
method: 'GET',
|
| 177 |
beforeSend: function() {
|
| 178 |
-
$('
|
| 179 |
},
|
| 180 |
-
|
| 181 |
-
$('
|
| 182 |
-
.addClass('animate-fadeIn');
|
| 183 |
-
$('#course-author span').text(`Pr. ${course.author}`);
|
| 184 |
-
$('#course-date span').text(new Date(course.updated_at).toLocaleDateString('fr-FR', {
|
| 185 |
-
day: 'numeric',
|
| 186 |
-
month: 'long',
|
| 187 |
-
year: 'numeric' }));
|
| 188 |
-
|
| 189 |
-
// Afficher une notification de succès
|
| 190 |
-
Toast.fire({
|
| 191 |
-
icon: 'success',
|
| 192 |
-
title: 'Cours chargé avec succès'
|
| 193 |
-
});
|
| 194 |
-
},
|
| 195 |
-
error: function() {
|
| 196 |
-
Toast.fire({
|
| 197 |
-
icon: 'error',
|
| 198 |
-
title: 'Erreur',
|
| 199 |
-
text: 'Impossible de charger les détails du cours'
|
| 200 |
-
});
|
| 201 |
}
|
| 202 |
});
|
| 203 |
-
} else {
|
| 204 |
-
$('.course-meta').addClass('animate-fadeOut').on('animationend', function() {
|
| 205 |
-
$(this).addClass('hidden').removeClass('animate-fadeOut');
|
| 206 |
-
});
|
| 207 |
}
|
| 208 |
-
});
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
text: 'Veuillez saisir votre sujet de dissertation',
|
| 224 |
-
showClass: {
|
| 225 |
-
popup: 'animate__animated animate__fadeInDown'
|
| 226 |
-
},
|
| 227 |
-
hideClass: {
|
| 228 |
-
popup: 'animate__animated animate__fadeOutUp'
|
| 229 |
-
},
|
| 230 |
-
customClass: {
|
| 231 |
-
popup: 'rounded-2xl',
|
| 232 |
-
confirmButton: 'bg-violet-600 hover:bg-violet-700 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200'
|
| 233 |
-
}
|
| 234 |
});
|
| 235 |
-
return;
|
| 236 |
-
}
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
});
|
| 244 |
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
courseId: $('#course-select').val() || null
|
| 249 |
-
};
|
| 250 |
-
|
| 251 |
-
$.ajax({
|
| 252 |
-
url: '/submit_philo',
|
| 253 |
-
method: 'POST',
|
| 254 |
-
contentType: 'application/json',
|
| 255 |
-
data: JSON.stringify(data),
|
| 256 |
-
success: function(data) {
|
| 257 |
-
Swal.close();
|
| 258 |
-
|
| 259 |
-
// Conversion et affichage en Markdown
|
| 260 |
-
const htmlContent = marked.parse(data.response);
|
| 261 |
-
$('#response > div').html(htmlContent);
|
| 262 |
-
$('#response').removeClass('hidden').addClass('animate-fadeIn');
|
| 263 |
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
});
|
| 269 |
|
| 270 |
-
// Afficher le bouton de copie
|
| 271 |
-
$('#copy-btn').removeClass('hidden').addClass('animate-slideUp');
|
| 272 |
-
},
|
| 273 |
-
error: function() {
|
| 274 |
Swal.fire({
|
| 275 |
-
icon: '
|
| 276 |
-
title: '
|
| 277 |
-
text: '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
customClass: {
|
| 279 |
popup: 'rounded-2xl',
|
| 280 |
confirmButton: 'bg-violet-600 hover:bg-violet-700 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200'
|
| 281 |
}
|
| 282 |
});
|
|
|
|
| 283 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
});
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
</body>
|
| 290 |
</html>
|
|
|
|
| 141 |
</div>
|
| 142 |
</div>
|
| 143 |
|
| 144 |
+
<script>
|
|
|
|
|
|
|
| 145 |
$(document).ready(function() {
|
| 146 |
+
// Configuration de marked avec support de la syntaxe GFM
|
| 147 |
+
marked.setOptions({
|
| 148 |
+
breaks: true,
|
| 149 |
+
gfm: true,
|
| 150 |
+
headerIds: true,
|
| 151 |
+
langPrefix: 'language-',
|
| 152 |
+
smartLists: true,
|
| 153 |
+
smartypants: true
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
+
// Configuration des notifications
|
| 157 |
+
const Toast = Swal.mixin({
|
| 158 |
+
toast: true,
|
| 159 |
+
position: 'top-end',
|
| 160 |
+
showConfirmButton: false,
|
| 161 |
+
timer: 3000,
|
| 162 |
+
timerProgressBar: true,
|
| 163 |
+
customClass: {
|
| 164 |
+
popup: 'rounded-lg shadow-xl border border-gray-100'
|
| 165 |
+
}
|
| 166 |
+
});
|
| 167 |
|
| 168 |
+
// Animation des boutons
|
| 169 |
+
function addButtonAnimation(buttonId) {
|
| 170 |
+
$(`#${buttonId}`).on('mousedown', function() {
|
| 171 |
+
$(this).addClass('scale-95');
|
| 172 |
+
}).on('mouseup mouseleave', function() {
|
| 173 |
+
$(this).removeClass('scale-95');
|
| 174 |
+
});
|
|
|
|
|
|
|
| 175 |
}
|
| 176 |
+
addButtonAnimation('submit-btn');
|
| 177 |
+
addButtonAnimation('copy-btn');
|
| 178 |
|
| 179 |
+
// Gestion du changement de type
|
| 180 |
+
$('#type-select').change(function() {
|
| 181 |
+
const type = $(this).val();
|
| 182 |
+
const labels = {
|
| 183 |
+
'1': 'Dissertation classique',
|
| 184 |
+
'2': 'Analyse comparative'
|
| 185 |
+
};
|
| 186 |
+
$('#current-type-label').text(`Type ${type} - ${labels[type]}`);
|
| 187 |
+
});
|
| 188 |
+
|
| 189 |
+
// Chargement des cours avec animation
|
| 190 |
+
function loadCourses() {
|
| 191 |
+
return $.ajax({
|
| 192 |
+
url: '/api/philosophy/courses',
|
| 193 |
method: 'GET',
|
| 194 |
beforeSend: function() {
|
| 195 |
+
$('#course-select').addClass('animate-pulse');
|
| 196 |
},
|
| 197 |
+
complete: function() {
|
| 198 |
+
$('#course-select').removeClass('animate-pulse');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
}
|
| 200 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
}
|
|
|
|
| 202 |
|
| 203 |
+
loadCourses()
|
| 204 |
+
.done(function(courses) {
|
| 205 |
+
const select = $('#course-select');
|
| 206 |
+
courses.forEach(course => {
|
| 207 |
+
select.append(`<option value="${course.id}">${course.title}</option>`);
|
| 208 |
+
});
|
| 209 |
+
})
|
| 210 |
+
.fail(function() {
|
| 211 |
+
Toast.fire({
|
| 212 |
+
icon: 'error',
|
| 213 |
+
title: 'Erreur de chargement des cours',
|
| 214 |
+
text: 'Veuillez réessayer ultérieurement'
|
| 215 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
});
|
|
|
|
|
|
|
| 217 |
|
| 218 |
+
// Gestion du changement de cours avec animations
|
| 219 |
+
$('#course-select').change(function() {
|
| 220 |
+
const courseId = $(this).val();
|
| 221 |
+
if (courseId) {
|
| 222 |
+
$.ajax({
|
| 223 |
+
url: `/api/philosophy/courses/${courseId}`,
|
| 224 |
+
method: 'GET',
|
| 225 |
+
beforeSend: function() {
|
| 226 |
+
$('.course-meta').addClass('animate-pulse');
|
| 227 |
+
},
|
| 228 |
+
success: function(course) {
|
| 229 |
+
$('.course-meta').removeClass('hidden animate-pulse')
|
| 230 |
+
.addClass('animate-fadeIn');
|
| 231 |
+
$('#course-author span').text(`Pr. ${course.author}`);
|
| 232 |
+
$('#course-date span').text(new Date(course.updated_at).toLocaleDateString('fr-FR', {
|
| 233 |
+
day: 'numeric',
|
| 234 |
+
month: 'long',
|
| 235 |
+
year: 'numeric' }));
|
| 236 |
+
|
| 237 |
+
// Afficher une notification de succès
|
| 238 |
+
Toast.fire({
|
| 239 |
+
icon: 'success',
|
| 240 |
+
title: 'Cours chargé avec succès'
|
| 241 |
+
});
|
| 242 |
+
},
|
| 243 |
+
error: function() {
|
| 244 |
+
Toast.fire({
|
| 245 |
+
icon: 'error',
|
| 246 |
+
title: 'Erreur',
|
| 247 |
+
text: 'Impossible de charger les détails du cours'
|
| 248 |
+
});
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
} else {
|
| 252 |
+
$('.course-meta').addClass('animate-fadeOut').on('animationend', function() {
|
| 253 |
+
$(this).addClass('hidden').removeClass('animate-fadeOut');
|
| 254 |
+
});
|
| 255 |
+
}
|
| 256 |
});
|
| 257 |
|
| 258 |
+
// Gestion de la soumission avec conversion en Markdown
|
| 259 |
+
$('#submit-btn').click(function() {
|
| 260 |
+
const question = $('#question').val().trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
+
if (!question) {
|
| 263 |
+
$('#question').addClass('animate-shake border-red-300');
|
| 264 |
+
setTimeout(() => {
|
| 265 |
+
$('#question').removeClass('animate-shake border-red-300');
|
| 266 |
+
}, 1000);
|
| 267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
Swal.fire({
|
| 269 |
+
icon: 'warning',
|
| 270 |
+
title: 'Champ requis',
|
| 271 |
+
text: 'Veuillez saisir votre sujet de dissertation',
|
| 272 |
+
showClass: {
|
| 273 |
+
popup: 'animate__animated animate__fadeInDown'
|
| 274 |
+
},
|
| 275 |
+
hideClass: {
|
| 276 |
+
popup: 'animate__animated animate__fadeOutUp'
|
| 277 |
+
},
|
| 278 |
customClass: {
|
| 279 |
popup: 'rounded-2xl',
|
| 280 |
confirmButton: 'bg-violet-600 hover:bg-violet-700 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200'
|
| 281 |
}
|
| 282 |
});
|
| 283 |
+
return;
|
| 284 |
}
|
| 285 |
+
|
| 286 |
+
Swal.fire({
|
| 287 |
+
title: 'Génération en cours',
|
| 288 |
+
html: `<div class="animate-pulse">Veuillez patienter quelques instants...</div>`,
|
| 289 |
+
allowOutsideClick: false,
|
| 290 |
+
showConfirmButton: false
|
| 291 |
+
});
|
| 292 |
+
|
| 293 |
+
const data = {
|
| 294 |
+
question: question,
|
| 295 |
+
type: $('#type-select').val(),
|
| 296 |
+
courseId: $('#course-select').val() || null
|
| 297 |
+
};
|
| 298 |
+
|
| 299 |
+
$.ajax({
|
| 300 |
+
url: '/submit_philo',
|
| 301 |
+
method: 'POST',
|
| 302 |
+
contentType: 'application/json',
|
| 303 |
+
data: JSON.stringify(data),
|
| 304 |
+
success: function(data) {
|
| 305 |
+
Swal.close();
|
| 306 |
+
|
| 307 |
+
// Conversion et affichage en Markdown
|
| 308 |
+
const htmlContent = marked.parse(data.response);
|
| 309 |
+
$('#response > div').html(htmlContent);
|
| 310 |
+
$('#response').removeClass('hidden').addClass('animate-fadeIn');
|
| 311 |
+
|
| 312 |
+
Toast.fire({
|
| 313 |
+
icon: 'success',
|
| 314 |
+
title: 'Dissertation générée avec succès',
|
| 315 |
+
timer: 2000
|
| 316 |
+
});
|
| 317 |
+
|
| 318 |
+
// Afficher le bouton de copie
|
| 319 |
+
$('#copy-btn').removeClass('hidden').addClass('animate-slideUp');
|
| 320 |
+
},
|
| 321 |
+
error: function() {
|
| 322 |
+
Swal.fire({
|
| 323 |
+
icon: 'error',
|
| 324 |
+
title: 'Erreur de génération',
|
| 325 |
+
text: 'Une erreur est survenue lors de la génération de votre dissertation.',
|
| 326 |
+
customClass: {
|
| 327 |
+
popup: 'rounded-2xl',
|
| 328 |
+
confirmButton: 'bg-violet-600 hover:bg-violet-700 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200'
|
| 329 |
+
}
|
| 330 |
+
});
|
| 331 |
+
}
|
| 332 |
+
});
|
| 333 |
});
|
| 334 |
+
|
| 335 |
+
// Gestion de la copie avec retour visuel amélioré
|
| 336 |
+
$('#copy-btn').click(function() {
|
| 337 |
+
const response = $('#response').text();
|
| 338 |
+
|
| 339 |
+
$(this).addClass('scale-95 bg-violet-100');
|
| 340 |
+
navigator.clipboard.writeText(response)
|
| 341 |
+
.then(() => {
|
| 342 |
+
$(this).removeClass('scale-95 bg-violet-100')
|
| 343 |
+
.addClass('bg-green-50 text-green-700');
|
| 344 |
+
|
| 345 |
+
setTimeout(() => {
|
| 346 |
+
$(this).removeClass('bg-green-50 text-green-700');
|
| 347 |
+
}, 1000);
|
| 348 |
+
|
| 349 |
+
Toast.fire({
|
| 350 |
+
icon: 'success',
|
| 351 |
+
title: 'Copié avec succès',
|
| 352 |
+
text: 'Le contenu a été copié dans votre presse-papiers',
|
| 353 |
+
timer: 2000
|
| 354 |
+
});
|
| 355 |
+
})
|
| 356 |
+
.catch(() => {
|
| 357 |
+
$(this).removeClass('scale-95 bg-violet-100')
|
| 358 |
+
.addClass('bg-red-50 text-red-700');
|
| 359 |
+
|
| 360 |
+
setTimeout(() => {
|
| 361 |
+
$(this).removeClass('bg-red-50 text-red-700');
|
| 362 |
+
}, 1000);
|
| 363 |
+
|
| 364 |
+
Toast.fire({
|
| 365 |
+
icon: 'error',
|
| 366 |
+
title: 'Erreur de copie',
|
| 367 |
+
text: 'Impossible de copier le contenu',
|
| 368 |
+
timer: 3000
|
| 369 |
+
});
|
| 370 |
+
});
|
| 371 |
+
});
|
| 372 |
+
|
| 373 |
+
// Ajout des styles d'animation personnalisés
|
| 374 |
+
const style = document.createElement('style');
|
| 375 |
+
style.textContent = `
|
| 376 |
+
@keyframes fadeIn {
|
| 377 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 378 |
+
to { opacity: 1; transform: translateY(0); }
|
| 379 |
+
}
|
| 380 |
+
@keyframes slideUp {
|
| 381 |
+
from { opacity: 0; transform: translateY(20px); }
|
| 382 |
+
to { opacity: 1; transform: translateY(0); }
|
| 383 |
+
}
|
| 384 |
+
@keyframes shake {
|
| 385 |
+
0%, 100% { transform: translateX(0); }
|
| 386 |
+
25% { transform: translateX(-5px); }
|
| 387 |
+
75% { transform: translateX(5px); }
|
| 388 |
+
}
|
| 389 |
+
.animate-fadeIn {
|
| 390 |
+
animation: fadeIn 0.5s ease-out forwards;
|
| 391 |
+
}
|
| 392 |
+
.animate-slideUp {
|
| 393 |
+
animation: slideUp 0.5s ease-out forwards;
|
| 394 |
+
}
|
| 395 |
+
.animate-shake {
|
| 396 |
+
animation: shake 0.5s ease-in-out;
|
| 397 |
+
}
|
| 398 |
+
`;
|
| 399 |
+
document.head.appendChild(style);
|
| 400 |
});
|
| 401 |
+
</script>
|
| 402 |
+
|
| 403 |
+
|
| 404 |
</body>
|
| 405 |
</html>
|