Spaces:
Sleeping
Sleeping
Upload philosophie.html
Browse files- templates/philosophie.html +112 -153
templates/philosophie.html
CHANGED
|
@@ -28,51 +28,62 @@
|
|
| 28 |
justify-content: space-between;
|
| 29 |
align-items: center;
|
| 30 |
}
|
|
|
|
| 31 |
/* Nouveaux styles pour le Markdown responsive */
|
| 32 |
.prose {
|
| 33 |
max-width: 100% !important;
|
| 34 |
}
|
|
|
|
| 35 |
.prose p {
|
| 36 |
margin-top: 1.25em;
|
| 37 |
margin-bottom: 1.25em;
|
| 38 |
line-height: 1.75;
|
| 39 |
}
|
|
|
|
| 40 |
.prose ul {
|
| 41 |
margin-top: 1.25em;
|
| 42 |
margin-bottom: 1.25em;
|
| 43 |
padding-left: 1.625em;
|
| 44 |
}
|
|
|
|
| 45 |
.prose li {
|
| 46 |
margin-top: 0.5em;
|
| 47 |
margin-bottom: 0.5em;
|
| 48 |
padding-left: 0.375em;
|
| 49 |
}
|
|
|
|
| 50 |
.prose h1, .prose h2, .prose h3 {
|
| 51 |
margin-top: 2em;
|
| 52 |
margin-bottom: 1em;
|
| 53 |
line-height: 1.3;
|
| 54 |
}
|
|
|
|
| 55 |
/* Styles spécifiques pour mobile */
|
| 56 |
@media (max-width: 640px) {
|
| 57 |
.prose {
|
| 58 |
font-size: 0.95rem;
|
| 59 |
}
|
|
|
|
| 60 |
.prose p {
|
| 61 |
margin-top: 1em;
|
| 62 |
margin-bottom: 1em;
|
| 63 |
}
|
|
|
|
| 64 |
.prose ul {
|
| 65 |
padding-left: 1.25em;
|
| 66 |
}
|
|
|
|
| 67 |
.prose li {
|
| 68 |
margin-top: 0.375em;
|
| 69 |
margin-bottom: 0.375em;
|
| 70 |
}
|
|
|
|
| 71 |
.prose h1, .prose h2, .prose h3 {
|
| 72 |
margin-top: 1.5em;
|
| 73 |
margin-bottom: 0.75em;
|
| 74 |
}
|
| 75 |
}
|
|
|
|
| 76 |
/* Styles pour améliorer la lisibilité du texte */
|
| 77 |
#response .prose {
|
| 78 |
color: #374151;
|
|
@@ -80,24 +91,29 @@
|
|
| 80 |
overflow-wrap: break-word;
|
| 81 |
hyphens: auto;
|
| 82 |
}
|
|
|
|
| 83 |
#response .prose > * + * {
|
| 84 |
margin-top: 1em;
|
| 85 |
}
|
|
|
|
| 86 |
#response .prose blockquote {
|
| 87 |
margin: 1.5em 0;
|
| 88 |
padding-left: 1em;
|
| 89 |
border-left: 4px solid #e5e7eb;
|
| 90 |
font-style: italic;
|
| 91 |
}
|
|
|
|
| 92 |
#response .prose code {
|
| 93 |
background-color: #f3f4f6;
|
| 94 |
padding: 0.2em 0.4em;
|
| 95 |
border-radius: 0.25em;
|
| 96 |
font-size: 0.875em;
|
| 97 |
}
|
|
|
|
| 98 |
.active, .collapsible:hover {
|
| 99 |
background-color: #ddd;
|
| 100 |
}
|
|
|
|
| 101 |
.content {
|
| 102 |
padding: 0 18px;
|
| 103 |
display: none;
|
|
@@ -126,7 +142,8 @@
|
|
| 126 |
25% { transform: translateX(-5px); }
|
| 127 |
75% { transform: translateX(5px); }
|
| 128 |
}
|
| 129 |
-
|
|
|
|
| 130 |
.select2-container--default .select2-selection--single {
|
| 131 |
border: 1px solid #e5e7eb;
|
| 132 |
border-radius: 0.75rem;
|
|
@@ -164,7 +181,7 @@
|
|
| 164 |
.select2-results__option {
|
| 165 |
padding: 0.5rem 0.75rem;
|
| 166 |
}
|
| 167 |
-
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable
|
| 168 |
background-color: #ede9fe;
|
| 169 |
color:#374151;
|
| 170 |
}
|
|
@@ -308,20 +325,7 @@
|
|
| 308 |
</div>
|
| 309 |
|
| 310 |
<!-- Bouton flottant DeepThink -->
|
| 311 |
-
<button id="deepthink-btn"
|
| 312 |
-
position: fixed;
|
| 313 |
-
bottom: 20px;
|
| 314 |
-
right: 20px;
|
| 315 |
-
z-index: 1000;
|
| 316 |
-
background-color: #4f46e5;
|
| 317 |
-
color: white;
|
| 318 |
-
border: none;
|
| 319 |
-
border-radius: 50px;
|
| 320 |
-
padding: 15px 20px;
|
| 321 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 322 |
-
cursor: pointer;
|
| 323 |
-
transition: background-color 0.3s;
|
| 324 |
-
">
|
| 325 |
DeepThink
|
| 326 |
</button>
|
| 327 |
|
|
@@ -342,7 +346,7 @@
|
|
| 342 |
},
|
| 343 |
templateSelection: function (course) {
|
| 344 |
return course.text;
|
| 345 |
-
}
|
| 346 |
});
|
| 347 |
|
| 348 |
// Configuration de marked
|
|
@@ -357,7 +361,7 @@
|
|
| 357 |
|
| 358 |
moment.locale('fr');
|
| 359 |
|
| 360 |
-
// Configuration des notifications
|
| 361 |
const Toast = Swal.mixin({
|
| 362 |
toast: true,
|
| 363 |
position: 'top-end',
|
|
@@ -380,13 +384,13 @@
|
|
| 380 |
addButtonAnimation('submit-btn');
|
| 381 |
addButtonAnimation('copy-btn');
|
| 382 |
|
| 383 |
-
// Gestion du changement de type
|
| 384 |
$('#type-select').change(function() {
|
| 385 |
const selectedOption = $(this).find('option:selected');
|
| 386 |
const typeLabel = selectedOption.text();
|
| 387 |
const type = $(this).val();
|
| 388 |
let labelText;
|
| 389 |
-
if(type === '3') {
|
| 390 |
labelText = 'S - Synthèse';
|
| 391 |
} else {
|
| 392 |
labelText = `Type ${type} - ${typeLabel}`;
|
|
@@ -394,7 +398,7 @@
|
|
| 394 |
$('#current-type-label').text(labelText);
|
| 395 |
});
|
| 396 |
|
| 397 |
-
// Chargement des cours
|
| 398 |
function loadCourses() {
|
| 399 |
return $.ajax({
|
| 400 |
url: '/api/philosophy/courses',
|
|
@@ -408,23 +412,23 @@
|
|
| 408 |
});
|
| 409 |
}
|
| 410 |
loadCourses()
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
});
|
| 418 |
-
})
|
| 419 |
-
.fail(function() {
|
| 420 |
-
Toast.fire({
|
| 421 |
-
icon: 'error',
|
| 422 |
-
title: 'Erreur de chargement des cours',
|
| 423 |
-
text: 'Veuillez réessayer ultérieurement'
|
| 424 |
-
});
|
| 425 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
-
// Gestion du changement de cours
|
| 428 |
$('#course-select').on('change', function() {
|
| 429 |
const courseId = $(this).val();
|
| 430 |
if (courseId) {
|
|
@@ -435,7 +439,8 @@
|
|
| 435 |
$('.course-meta').addClass('animate-pulse');
|
| 436 |
},
|
| 437 |
success: function(course) {
|
| 438 |
-
$('.course-meta').removeClass('hidden animate-pulse')
|
|
|
|
| 439 |
$('#course-author span').text(`Pr. ${course.author}`);
|
| 440 |
$('#course-date span').text(new Date(course.updated_at).toLocaleDateString('fr-FR', {
|
| 441 |
day: 'numeric',
|
|
@@ -462,7 +467,7 @@
|
|
| 462 |
}
|
| 463 |
});
|
| 464 |
|
| 465 |
-
// Gestion de la soumission
|
| 466 |
$('#submit-btn').click(function() {
|
| 467 |
const question = $('#question').val().trim();
|
| 468 |
if (!question) {
|
|
@@ -600,7 +605,8 @@
|
|
| 600 |
$(this).addClass('scale-95 bg-violet-100');
|
| 601 |
navigator.clipboard.writeText(textToCopy)
|
| 602 |
.then(() => {
|
| 603 |
-
$(this).removeClass('scale-95 bg-violet-100')
|
|
|
|
| 604 |
setTimeout(() => {
|
| 605 |
$(this).removeClass('bg-green-50 text-green-700');
|
| 606 |
}, 1000);
|
|
@@ -621,7 +627,8 @@
|
|
| 621 |
textarea.select();
|
| 622 |
document.execCommand('copy');
|
| 623 |
document.body.removeChild(textarea);
|
| 624 |
-
$(this).removeClass('scale-95 bg-violet-100')
|
|
|
|
| 625 |
setTimeout(() => {
|
| 626 |
$(this).removeClass('bg-green-50 text-green-700');
|
| 627 |
}, 1000);
|
|
@@ -631,7 +638,8 @@
|
|
| 631 |
timer: 2000
|
| 632 |
});
|
| 633 |
} catch (fallbackErr) {
|
| 634 |
-
$(this).removeClass('scale-95 bg-violet-100')
|
|
|
|
| 635 |
setTimeout(() => {
|
| 636 |
$(this).removeClass('bg-red-50 text-red-700');
|
| 637 |
}, 1000);
|
|
@@ -645,138 +653,89 @@
|
|
| 645 |
});
|
| 646 |
});
|
| 647 |
|
| 648 |
-
//
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
from { opacity: 0; transform: translateY(20px); }
|
| 657 |
-
to { opacity: 1; transform: translateY(0); }
|
| 658 |
-
}
|
| 659 |
-
@keyframes shake {
|
| 660 |
-
0%, 100% { transform: translateX(0); }
|
| 661 |
-
25% { transform: translateX(-5px); }
|
| 662 |
-
75% { transform: translateX(5px); }
|
| 663 |
-
}
|
| 664 |
-
.animate-fadeIn {
|
| 665 |
-
animation: fadeIn 0.5s ease-out forwards;
|
| 666 |
-
}
|
| 667 |
-
.animate-slideUp {
|
| 668 |
-
animation: slideUp 0.5s ease-out forwards;
|
| 669 |
-
}
|
| 670 |
-
.animate-shake {
|
| 671 |
-
animation: shake 0.5s ease-in-out;
|
| 672 |
-
}
|
| 673 |
-
`;
|
| 674 |
-
document.head.appendChild(style);
|
| 675 |
-
const initialSelectValue = $('#type-select').val();
|
| 676 |
-
const initialSelectedText = $('#type-select option:selected').text();
|
| 677 |
-
let initialLabelText;
|
| 678 |
-
if(initialSelectValue === '3') {
|
| 679 |
-
initialLabelText = 'S - Synthèse';
|
| 680 |
-
} else {
|
| 681 |
-
initialLabelText = `Type ${initialSelectValue} - ${initialSelectedText}`;
|
| 682 |
-
}
|
| 683 |
-
$('#current-type-label').text(initialLabelText);
|
| 684 |
-
|
| 685 |
-
/* --- Code pour le bouton DeepThink --- */
|
| 686 |
-
// Vérifie si DeepThink a déjà été utilisé aujourd'hui
|
| 687 |
-
function canUseDeepThink() {
|
| 688 |
-
const lastUsed = localStorage.getItem('deepthink_last_used');
|
| 689 |
-
if (!lastUsed) return true;
|
| 690 |
-
const lastDate = new Date(lastUsed);
|
| 691 |
-
const now = new Date();
|
| 692 |
-
return (now - lastDate) > (24 * 60 * 60 * 1000);
|
| 693 |
}
|
| 694 |
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
$.ajax({
|
| 708 |
url: '/submit_philo_deepthink',
|
| 709 |
method: 'POST',
|
| 710 |
contentType: 'application/json',
|
| 711 |
data: JSON.stringify(data),
|
| 712 |
-
beforeSend: function() {
|
| 713 |
-
Swal.fire({
|
| 714 |
-
title: 'Génération DeepThink en cours',
|
| 715 |
-
html: 'Veuillez patienter...',
|
| 716 |
-
allowOutsideClick: false,
|
| 717 |
-
didOpen: () => {
|
| 718 |
-
Swal.showLoading();
|
| 719 |
-
}
|
| 720 |
-
});
|
| 721 |
-
},
|
| 722 |
success: function(response) {
|
| 723 |
Swal.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 724 |
Swal.fire({
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
|
|
|
| 728 |
});
|
| 729 |
-
updateDeepThinkUsage();
|
| 730 |
},
|
| 731 |
error: function() {
|
| 732 |
-
Swal.close();
|
| 733 |
Swal.fire({
|
| 734 |
icon: 'error',
|
| 735 |
-
title: 'Erreur',
|
| 736 |
-
text: 'Une erreur est survenue lors de
|
|
|
|
|
|
|
|
|
|
| 737 |
});
|
| 738 |
}
|
| 739 |
});
|
| 740 |
-
}
|
| 741 |
-
|
| 742 |
-
// Action du clic sur le bouton DeepThink
|
| 743 |
-
$('#deepthink-btn').click(function(){
|
| 744 |
-
if (!canUseDeepThink()) {
|
| 745 |
-
Swal.fire({
|
| 746 |
-
icon: 'warning',
|
| 747 |
-
title: 'Limite atteinte',
|
| 748 |
-
text: 'Vous ne pouvez utiliser DeepThink qu\'une seule fois par jour.'
|
| 749 |
-
});
|
| 750 |
-
return;
|
| 751 |
-
}
|
| 752 |
-
Swal.fire({
|
| 753 |
-
title: 'DeepThink',
|
| 754 |
-
input: 'textarea',
|
| 755 |
-
inputLabel: 'Saisissez votre sujet pour DeepThink',
|
| 756 |
-
inputPlaceholder: 'Entrez ici votre sujet...',
|
| 757 |
-
inputAttributes: {
|
| 758 |
-
'aria-label': 'Saisissez votre sujet pour DeepThink'
|
| 759 |
-
},
|
| 760 |
-
showCancelButton: true,
|
| 761 |
-
confirmButtonText: 'Valider',
|
| 762 |
-
cancelButtonText: 'Annuler',
|
| 763 |
-
preConfirm: (question) => {
|
| 764 |
-
if (!question || question.trim() === '') {
|
| 765 |
-
Swal.showValidationMessage('Veuillez saisir un sujet');
|
| 766 |
-
}
|
| 767 |
-
return question;
|
| 768 |
-
}
|
| 769 |
-
}).then((result) => {
|
| 770 |
-
if (result.isConfirmed) {
|
| 771 |
-
const question = result.value;
|
| 772 |
-
const type = '1';
|
| 773 |
-
const courseId = $('#course-select').val() || null;
|
| 774 |
-
callDeepThink(question, type, courseId);
|
| 775 |
-
}
|
| 776 |
-
});
|
| 777 |
});
|
| 778 |
-
/* --- Fin du code DeepThink --- */
|
| 779 |
});
|
| 780 |
</script>
|
| 781 |
</body>
|
| 782 |
</html>
|
|
|
|
|
|
| 28 |
justify-content: space-between;
|
| 29 |
align-items: center;
|
| 30 |
}
|
| 31 |
+
|
| 32 |
/* Nouveaux styles pour le Markdown responsive */
|
| 33 |
.prose {
|
| 34 |
max-width: 100% !important;
|
| 35 |
}
|
| 36 |
+
|
| 37 |
.prose p {
|
| 38 |
margin-top: 1.25em;
|
| 39 |
margin-bottom: 1.25em;
|
| 40 |
line-height: 1.75;
|
| 41 |
}
|
| 42 |
+
|
| 43 |
.prose ul {
|
| 44 |
margin-top: 1.25em;
|
| 45 |
margin-bottom: 1.25em;
|
| 46 |
padding-left: 1.625em;
|
| 47 |
}
|
| 48 |
+
|
| 49 |
.prose li {
|
| 50 |
margin-top: 0.5em;
|
| 51 |
margin-bottom: 0.5em;
|
| 52 |
padding-left: 0.375em;
|
| 53 |
}
|
| 54 |
+
|
| 55 |
.prose h1, .prose h2, .prose h3 {
|
| 56 |
margin-top: 2em;
|
| 57 |
margin-bottom: 1em;
|
| 58 |
line-height: 1.3;
|
| 59 |
}
|
| 60 |
+
|
| 61 |
/* Styles spécifiques pour mobile */
|
| 62 |
@media (max-width: 640px) {
|
| 63 |
.prose {
|
| 64 |
font-size: 0.95rem;
|
| 65 |
}
|
| 66 |
+
|
| 67 |
.prose p {
|
| 68 |
margin-top: 1em;
|
| 69 |
margin-bottom: 1em;
|
| 70 |
}
|
| 71 |
+
|
| 72 |
.prose ul {
|
| 73 |
padding-left: 1.25em;
|
| 74 |
}
|
| 75 |
+
|
| 76 |
.prose li {
|
| 77 |
margin-top: 0.375em;
|
| 78 |
margin-bottom: 0.375em;
|
| 79 |
}
|
| 80 |
+
|
| 81 |
.prose h1, .prose h2, .prose h3 {
|
| 82 |
margin-top: 1.5em;
|
| 83 |
margin-bottom: 0.75em;
|
| 84 |
}
|
| 85 |
}
|
| 86 |
+
|
| 87 |
/* Styles pour améliorer la lisibilité du texte */
|
| 88 |
#response .prose {
|
| 89 |
color: #374151;
|
|
|
|
| 91 |
overflow-wrap: break-word;
|
| 92 |
hyphens: auto;
|
| 93 |
}
|
| 94 |
+
|
| 95 |
#response .prose > * + * {
|
| 96 |
margin-top: 1em;
|
| 97 |
}
|
| 98 |
+
|
| 99 |
#response .prose blockquote {
|
| 100 |
margin: 1.5em 0;
|
| 101 |
padding-left: 1em;
|
| 102 |
border-left: 4px solid #e5e7eb;
|
| 103 |
font-style: italic;
|
| 104 |
}
|
| 105 |
+
|
| 106 |
#response .prose code {
|
| 107 |
background-color: #f3f4f6;
|
| 108 |
padding: 0.2em 0.4em;
|
| 109 |
border-radius: 0.25em;
|
| 110 |
font-size: 0.875em;
|
| 111 |
}
|
| 112 |
+
|
| 113 |
.active, .collapsible:hover {
|
| 114 |
background-color: #ddd;
|
| 115 |
}
|
| 116 |
+
|
| 117 |
.content {
|
| 118 |
padding: 0 18px;
|
| 119 |
display: none;
|
|
|
|
| 142 |
25% { transform: translateX(-5px); }
|
| 143 |
75% { transform: translateX(5px); }
|
| 144 |
}
|
| 145 |
+
|
| 146 |
+
/* Ajout du style pour Select2 */
|
| 147 |
.select2-container--default .select2-selection--single {
|
| 148 |
border: 1px solid #e5e7eb;
|
| 149 |
border-radius: 0.75rem;
|
|
|
|
| 181 |
.select2-results__option {
|
| 182 |
padding: 0.5rem 0.75rem;
|
| 183 |
}
|
| 184 |
+
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable{
|
| 185 |
background-color: #ede9fe;
|
| 186 |
color:#374151;
|
| 187 |
}
|
|
|
|
| 325 |
</div>
|
| 326 |
|
| 327 |
<!-- Bouton flottant DeepThink -->
|
| 328 |
+
<button id="deepthink-btn" class="fixed bottom-6 right-6 z-50 bg-indigo-600 text-white px-4 py-2 rounded-full shadow-lg hover:bg-indigo-700 focus:outline-none">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
DeepThink
|
| 330 |
</button>
|
| 331 |
|
|
|
|
| 346 |
},
|
| 347 |
templateSelection: function (course) {
|
| 348 |
return course.text;
|
| 349 |
+
},
|
| 350 |
});
|
| 351 |
|
| 352 |
// Configuration de marked
|
|
|
|
| 361 |
|
| 362 |
moment.locale('fr');
|
| 363 |
|
| 364 |
+
// Configuration des notifications SweetAlert2
|
| 365 |
const Toast = Swal.mixin({
|
| 366 |
toast: true,
|
| 367 |
position: 'top-end',
|
|
|
|
| 384 |
addButtonAnimation('submit-btn');
|
| 385 |
addButtonAnimation('copy-btn');
|
| 386 |
|
| 387 |
+
// Gestion du changement de type
|
| 388 |
$('#type-select').change(function() {
|
| 389 |
const selectedOption = $(this).find('option:selected');
|
| 390 |
const typeLabel = selectedOption.text();
|
| 391 |
const type = $(this).val();
|
| 392 |
let labelText;
|
| 393 |
+
if (type === '3') {
|
| 394 |
labelText = 'S - Synthèse';
|
| 395 |
} else {
|
| 396 |
labelText = `Type ${type} - ${typeLabel}`;
|
|
|
|
| 398 |
$('#current-type-label').text(labelText);
|
| 399 |
});
|
| 400 |
|
| 401 |
+
// Chargement des cours
|
| 402 |
function loadCourses() {
|
| 403 |
return $.ajax({
|
| 404 |
url: '/api/philosophy/courses',
|
|
|
|
| 412 |
});
|
| 413 |
}
|
| 414 |
loadCourses()
|
| 415 |
+
.done(function(courses) {
|
| 416 |
+
const select = $('#course-select');
|
| 417 |
+
courses.forEach(course => {
|
| 418 |
+
const newOption = new Option(course.title, course.id, false, false);
|
| 419 |
+
$(newOption).data('author', course.author);
|
| 420 |
+
select.append(newOption);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
});
|
| 422 |
+
})
|
| 423 |
+
.fail(function() {
|
| 424 |
+
Toast.fire({
|
| 425 |
+
icon: 'error',
|
| 426 |
+
title: 'Erreur de chargement des cours',
|
| 427 |
+
text: 'Veuillez réessayer ultérieurement'
|
| 428 |
+
});
|
| 429 |
+
});
|
| 430 |
|
| 431 |
+
// Gestion du changement de cours
|
| 432 |
$('#course-select').on('change', function() {
|
| 433 |
const courseId = $(this).val();
|
| 434 |
if (courseId) {
|
|
|
|
| 439 |
$('.course-meta').addClass('animate-pulse');
|
| 440 |
},
|
| 441 |
success: function(course) {
|
| 442 |
+
$('.course-meta').removeClass('hidden animate-pulse')
|
| 443 |
+
.addClass('animate-fadeIn');
|
| 444 |
$('#course-author span').text(`Pr. ${course.author}`);
|
| 445 |
$('#course-date span').text(new Date(course.updated_at).toLocaleDateString('fr-FR', {
|
| 446 |
day: 'numeric',
|
|
|
|
| 467 |
}
|
| 468 |
});
|
| 469 |
|
| 470 |
+
// Gestion de la soumission standard
|
| 471 |
$('#submit-btn').click(function() {
|
| 472 |
const question = $('#question').val().trim();
|
| 473 |
if (!question) {
|
|
|
|
| 605 |
$(this).addClass('scale-95 bg-violet-100');
|
| 606 |
navigator.clipboard.writeText(textToCopy)
|
| 607 |
.then(() => {
|
| 608 |
+
$(this).removeClass('scale-95 bg-violet-100')
|
| 609 |
+
.addClass('bg-green-50 text-green-700');
|
| 610 |
setTimeout(() => {
|
| 611 |
$(this).removeClass('bg-green-50 text-green-700');
|
| 612 |
}, 1000);
|
|
|
|
| 627 |
textarea.select();
|
| 628 |
document.execCommand('copy');
|
| 629 |
document.body.removeChild(textarea);
|
| 630 |
+
$(this).removeClass('scale-95 bg-violet-100')
|
| 631 |
+
.addClass('bg-green-50 text-green-700');
|
| 632 |
setTimeout(() => {
|
| 633 |
$(this).removeClass('bg-green-50 text-green-700');
|
| 634 |
}, 1000);
|
|
|
|
| 638 |
timer: 2000
|
| 639 |
});
|
| 640 |
} catch (fallbackErr) {
|
| 641 |
+
$(this).removeClass('scale-95 bg-violet-100')
|
| 642 |
+
.addClass('bg-red-50 text-red-700');
|
| 643 |
setTimeout(() => {
|
| 644 |
$(this).removeClass('bg-red-50 text-red-700');
|
| 645 |
}, 1000);
|
|
|
|
| 653 |
});
|
| 654 |
});
|
| 655 |
|
| 656 |
+
// Bouton flottant DeepThink
|
| 657 |
+
// Vérification de la limite d'une utilisation par jour via localStorage
|
| 658 |
+
function isToday(dateStr) {
|
| 659 |
+
const today = new Date();
|
| 660 |
+
const date = new Date(dateStr);
|
| 661 |
+
return date.getFullYear() === today.getFullYear() &&
|
| 662 |
+
date.getMonth() === today.getMonth() &&
|
| 663 |
+
date.getDate() === today.getDate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
}
|
| 665 |
|
| 666 |
+
$('#deepthink-btn').click(function() {
|
| 667 |
+
const lastUsed = localStorage.getItem('deepThinkLastUsed');
|
| 668 |
+
if (lastUsed && isToday(lastUsed)) {
|
| 669 |
+
Swal.fire({
|
| 670 |
+
icon: 'warning',
|
| 671 |
+
title: "Limite quotidienne",
|
| 672 |
+
text: "Vous ne pouvez utiliser DeepThink qu'une seule fois par jour."
|
| 673 |
+
});
|
| 674 |
+
return;
|
| 675 |
+
}
|
| 676 |
+
const question = $('#question').val().trim();
|
| 677 |
+
const type = $('#type-select').val();
|
| 678 |
+
const courseId = $('#course-select').val() || null;
|
| 679 |
+
if (!question) {
|
| 680 |
+
Swal.fire({
|
| 681 |
+
icon: 'error',
|
| 682 |
+
title: "Sujet manquant",
|
| 683 |
+
text: "Veuillez saisir un sujet dans le champ principal."
|
| 684 |
+
});
|
| 685 |
+
return;
|
| 686 |
+
}
|
| 687 |
+
Swal.fire({
|
| 688 |
+
title: 'DeepThink en cours',
|
| 689 |
+
html: `
|
| 690 |
+
<div class="flex justify-center">
|
| 691 |
+
<div class="w-16 h-16 relative">
|
| 692 |
+
<div class="absolute inset-0 rounded-full border-4 border-indigo-200 animate-ping"></div>
|
| 693 |
+
<div class="absolute inset-0 rounded-full border-4 border-indigo-500 animate-pulse"></div>
|
| 694 |
+
</div>
|
| 695 |
+
</div>
|
| 696 |
+
<p class="mt-4 text-gray-600">Veuillez patienter quelques instants...</p>
|
| 697 |
+
`,
|
| 698 |
+
allowOutsideClick: false,
|
| 699 |
+
showConfirmButton: false,
|
| 700 |
+
customClass: {
|
| 701 |
+
popup: 'rounded-2xl'
|
| 702 |
+
}
|
| 703 |
+
});
|
| 704 |
+
const data = { question, type, courseId };
|
| 705 |
$.ajax({
|
| 706 |
url: '/submit_philo_deepthink',
|
| 707 |
method: 'POST',
|
| 708 |
contentType: 'application/json',
|
| 709 |
data: JSON.stringify(data),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 710 |
success: function(response) {
|
| 711 |
Swal.close();
|
| 712 |
+
const htmlContent = marked.parse(response.response);
|
| 713 |
+
$('#response > div').html(htmlContent);
|
| 714 |
+
$('#response').removeClass('hidden').addClass('animate-fadeIn');
|
| 715 |
+
$('#copy-btn').removeClass('hidden').addClass('animate-slideUp');
|
| 716 |
+
saveDissertation(question, response.response);
|
| 717 |
+
localStorage.setItem('deepThinkLastUsed', new Date().toISOString());
|
| 718 |
Swal.fire({
|
| 719 |
+
icon: 'success',
|
| 720 |
+
title: 'DeepThink généré avec succès',
|
| 721 |
+
timer: 2000,
|
| 722 |
+
showConfirmButton: false
|
| 723 |
});
|
|
|
|
| 724 |
},
|
| 725 |
error: function() {
|
|
|
|
| 726 |
Swal.fire({
|
| 727 |
icon: 'error',
|
| 728 |
+
title: 'Erreur DeepThink',
|
| 729 |
+
text: 'Une erreur est survenue lors de la génération DeepThink.',
|
| 730 |
+
customClass: {
|
| 731 |
+
popup: 'rounded-2xl'
|
| 732 |
+
}
|
| 733 |
});
|
| 734 |
}
|
| 735 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 736 |
});
|
|
|
|
| 737 |
});
|
| 738 |
</script>
|
| 739 |
</body>
|
| 740 |
</html>
|
| 741 |
+
|