Docfile commited on
Commit
9938510
·
verified ·
1 Parent(s): 05c4f0f

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +142 -134
templates/index.html CHANGED
@@ -129,17 +129,19 @@
129
  }
130
 
131
  .backup-content {
132
- display: none;
133
- margin-top: 10px;
134
- max-height: 0;
135
- overflow: hidden;
136
- transition: max-height 0.3s ease;
137
- }
138
-
139
- .backup-content-expanded {
140
- display: block;
141
- max-height: 2000px;
142
- }
 
 
143
 
144
  /* Styles for multiple image upload */
145
  .image-preview {
@@ -611,134 +613,140 @@
611
  }
612
 
613
  function afficherSauvegardes() {
614
- const sauvegardes = JSON.parse(localStorage.getItem('mariam_ai_sauvegardes') || '[]');
615
- const backupsList = document.getElementById('backups-list');
616
- backupsList.innerHTML = '';
617
- if (sauvegardes.length === 0) {
618
- backupsList.innerHTML = `
619
- <div class="bg-blue-50 rounded-lg p-8 text-center">
620
- <div class="bg-white rounded-full w-16 h-16 flex items-center justify-center mx-auto mb-4 shadow-sm">
621
- <i class="fas fa-folder-open text-blue-300 text-2xl"></i>
622
- </div>
623
- <p class="text-gray-600">Aucune sauvegarde pour le moment.</p>
624
- <p class="text-sm text-gray-500 mt-2">Vos réponses générées apparaîtront ici.</p>
625
- </div>
626
- `;
627
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  }
 
629
 
630
- sauvegardes.forEach((sauvegarde, index) => {
631
- const date = new Date(sauvegarde.date);
632
- const formattedDate = date.toLocaleDateString('fr-FR', {
633
- day: 'numeric',
634
- month: 'short',
635
- year: 'numeric',
636
- hour: '2-digit',
637
- minute: '2-digit'
638
- });
639
-
640
- const sauvegardeDiv = document.createElement('div');
641
- sauvegardeDiv.className = 'bg-white rounded-lg shadow-md p-4 relative backup-item hover:bg-blue-50 transition-all duration-200';
642
- sauvegardeDiv.innerHTML = `
643
- <div class="flex items-start">
644
- <div class="bg-blue-100 rounded-lg p-2 mr-3">
645
- <i class="fas fa-file-alt text-blue-600"></i>
646
- </div>
647
- <div class="flex-grow">
648
- <h3 class="text-lg font-semibold text-gray-800">${sauvegarde.titre}</h3>
649
- <p class="text-sm text-gray-600 mb-2 flex items-center">
650
- <i class="fas fa-clock text-xs mr-1 text-gray-400"></i>
651
- ${formattedDate}
652
- </p>
653
- </div>
654
- <div class="flex space-x-2">
655
- <button class="text-gray-400 hover:text-blue-600 focus:outline-none copy-btn" data-index="${index}">
656
- <i class="fas fa-copy"></i>
657
- </button>
658
- <button class="text-gray-400 hover:text-red-600 focus:outline-none delete-btn" data-index="${index}">
659
- <i class="fas fa-trash-alt"></i>
660
- </button>
661
- </div>
662
- </div>
663
- <div class="text-sm text-gray-700 backup-content prose max-w-none mt-3">${marked.parse(sauvegarde.contenu)}</div>
664
- `;
665
- backupsList.appendChild(sauvegardeDiv);
666
-
667
- // Gestion de l'expansion/contraction du contenu
668
- const backupContentDiv = sauvegardeDiv.querySelector('.backup-content');
669
- sauvegardeDiv.addEventListener('click', (e) => {
670
- // Ignorer les clics sur les boutons
671
- if (e.target.tagName === "BUTTON" || e.target.closest('button')) return;
672
-
673
- const allContents = document.querySelectorAll('.backup-content');
674
- allContents.forEach(content => {
675
- if (content !== backupContentDiv) {
676
- content.classList.remove('backup-content-expanded');
677
- }
678
- });
679
-
680
- backupContentDiv.classList.toggle('backup-content-expanded');
681
-
682
- if (backupContentDiv.classList.contains('backup-content-expanded')) {
683
- setTimeout(() => {
684
- MathJax.typesetPromise([backupContentDiv]);
685
- }, 300);
686
- }
687
- });
688
-
689
- // Bouton de copie
690
- const copyButton = sauvegardeDiv.querySelector('.copy-btn');
691
- copyButton.addEventListener('click', (e) => {
692
- e.stopPropagation();
693
- navigator.clipboard.writeText(sauvegarde.contenu).then(() => {
694
- copyButton.querySelector('i').className = 'fas fa-check';
695
- setTimeout(() => {
696
- copyButton.querySelector('i').className = 'fas fa-copy';
697
- }, 2000);
698
- });
699
- });
700
 
701
- // Bouton de suppression
702
- const deleteButton = sauvegardeDiv.querySelector('.delete-btn');
703
- deleteButton.addEventListener('click', (e) => {
704
- e.stopPropagation();
705
-
706
- const confirmationModal = document.createElement('div');
707
- confirmationModal.className = 'fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-30 scale-in';
708
- confirmationModal.innerHTML = `
709
- <div class="bg-white rounded-lg p-6 max-w-sm mx-4 shadow-xl">
710
- <div class="flex items-center mb-4">
711
- <div class="bg-red-100 rounded-full p-2 mr-3">
712
- <i class="fas fa-exclamation-triangle text-red-500"></i>
713
- </div>
714
- <h3 class="text-lg font-semibold text-gray-800">Confirmation de suppression</h3>
715
- </div>
716
- <p class="text-gray-600 mb-6">Êtes-vous sûr de vouloir supprimer cette sauvegarde ? Cette action est irréversible.</p>
717
- <div class="flex justify-end space-x-3">
718
- <button class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 cancel-btn">Annuler</button>
719
- <button class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 confirm-btn">Supprimer</button>
720
- </div>
721
  </div>
722
- `;
723
- document.body.appendChild(confirmationModal);
724
-
725
- confirmationModal.querySelector('.cancel-btn').addEventListener('click', () => {
726
- confirmationModal.style.opacity = '0';
727
- setTimeout(() => {
728
- document.body.removeChild(confirmationModal);
729
- }, 300);
730
- });
731
-
732
- confirmationModal.querySelector('.confirm-btn').addEventListener('click', () => {
733
- supprimerSauvegarde(index);
734
- confirmationModal.style.opacity = '0';
735
- setTimeout(() => {
736
- document.body.removeChild(confirmationModal);
737
- }, 300);
738
- });
739
- });
740
  });
741
- }
 
 
 
 
 
 
 
 
 
 
 
742
 
743
  async function submitFrancaisForm() {
744
  const form = document.getElementById('francais-form');
 
129
  }
130
 
131
  .backup-content {
132
+ display: none;
133
+ margin-top: 10px;
134
+ max-height: 0;
135
+ overflow: hidden;
136
+ transition: max-height 0.3s ease, opacity 0.3s ease;
137
+ opacity: 0;
138
+ }
139
+
140
+ .backup-content-expanded {
141
+ display: block;
142
+ max-height: 2000px;
143
+ opacity: 1;
144
+ }
145
 
146
  /* Styles for multiple image upload */
147
  .image-preview {
 
613
  }
614
 
615
  function afficherSauvegardes() {
616
+ const sauvegardes = JSON.parse(localStorage.getItem('mariam_ai_sauvegardes') || '[]');
617
+ const backupsList = document.getElementById('backups-list');
618
+ backupsList.innerHTML = '';
619
+ if (sauvegardes.length === 0) {
620
+ backupsList.innerHTML = `
621
+ <div class="bg-blue-50 rounded-lg p-8 text-center">
622
+ <div class="bg-white rounded-full w-16 h-16 flex items-center justify-center mx-auto mb-4 shadow-sm">
623
+ <i class="fas fa-folder-open text-blue-300 text-2xl"></i>
624
+ </div>
625
+ <p class="text-gray-600">Aucune sauvegarde pour le moment.</p>
626
+ <p class="text-sm text-gray-500 mt-2">Vos réponses générées apparaîtront ici.</p>
627
+ </div>
628
+ `;
629
+ return;
630
+ }
631
+
632
+ sauvegardes.forEach((sauvegarde, index) => {
633
+ const date = new Date(sauvegarde.date);
634
+ const formattedDate = date.toLocaleDateString('fr-FR', {
635
+ day: 'numeric',
636
+ month: 'short',
637
+ year: 'numeric',
638
+ hour: '2-digit',
639
+ minute: '2-digit'
640
+ });
641
+
642
+ const sauvegardeDiv = document.createElement('div');
643
+ sauvegardeDiv.className = 'bg-white rounded-lg shadow-md p-4 relative backup-item hover:bg-blue-50 transition-all duration-200';
644
+ sauvegardeDiv.innerHTML = `
645
+ <div class="flex items-start">
646
+ <div class="bg-blue-100 rounded-lg p-2 mr-3">
647
+ <i class="fas fa-file-alt text-blue-600"></i>
648
+ </div>
649
+ <div class="flex-grow">
650
+ <h3 class="text-lg font-semibold text-gray-800">${sauvegarde.titre}</h3>
651
+ <p class="text-sm text-gray-600 mb-2 flex items-center">
652
+ <i class="fas fa-clock text-xs mr-1 text-gray-400"></i>
653
+ ${formattedDate}
654
+ </p>
655
+ </div>
656
+ <div class="flex space-x-2">
657
+ <button class="text-gray-400 hover:text-blue-600 focus:outline-none copy-btn" data-index="${index}">
658
+ <i class="fas fa-copy"></i>
659
+ </button>
660
+ <button class="text-gray-400 hover:text-red-600 focus:outline-none delete-btn" data-index="${index}">
661
+ <i class="fas fa-trash-alt"></i>
662
+ </button>
663
+ </div>
664
+ </div>
665
+ <div class="text-sm text-gray-700 backup-content prose max-w-none mt-3" style="display: none;">${marked.parse(sauvegarde.contenu)}</div>
666
+ `;
667
+ backupsList.appendChild(sauvegardeDiv);
668
+
669
+ // Gestion de l'expansion/contraction du contenu
670
+ const backupContentDiv = sauvegardeDiv.querySelector('.backup-content');
671
+ sauvegardeDiv.addEventListener('click', (e) => {
672
+ // Ignorer les clics sur les boutons
673
+ if (e.target.tagName === "BUTTON" || e.target.closest('button')) return;
674
+
675
+ const allContents = document.querySelectorAll('.backup-content');
676
+ allContents.forEach(content => {
677
+ if (content !== backupContentDiv) {
678
+ content.classList.remove('backup-content-expanded');
679
+ content.style.display = 'none'; // Masquer les autres contenus
680
+ }
681
+ });
682
+
683
+ backupContentDiv.classList.toggle('backup-content-expanded');
684
+
685
+ // Basculer l'affichage (display) en fonction de l'état
686
+ if (backupContentDiv.classList.contains('backup-content-expanded')) {
687
+ backupContentDiv.style.display = 'block'; // Afficher le contenu
688
+ setTimeout(() => {
689
+ MathJax.typesetPromise([backupContentDiv]);
690
+ }, 300);
691
+ } else {
692
+ backupContentDiv.style.display = 'none'; // Masquer le contenu
693
  }
694
+ });
695
 
696
+ // Bouton de copie
697
+ const copyButton = sauvegardeDiv.querySelector('.copy-btn');
698
+ copyButton.addEventListener('click', (e) => {
699
+ e.stopPropagation();
700
+ navigator.clipboard.writeText(sauvegarde.contenu).then(() => {
701
+ copyButton.querySelector('i').className = 'fas fa-check';
702
+ setTimeout(() => {
703
+ copyButton.querySelector('i').className = 'fas fa-copy';
704
+ }, 2000);
705
+ });
706
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
 
708
+ // Bouton de suppression
709
+ const deleteButton = sauvegardeDiv.querySelector('.delete-btn');
710
+ deleteButton.addEventListener('click', (e) => {
711
+ e.stopPropagation();
712
+
713
+ const confirmationModal = document.createElement('div');
714
+ confirmationModal.className = 'fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-30 scale-in';
715
+ confirmationModal.innerHTML = `
716
+ <div class="bg-white rounded-lg p-6 max-w-sm mx-4 shadow-xl">
717
+ <div class="flex items-center mb-4">
718
+ <div class="bg-red-100 rounded-full p-2 mr-3">
719
+ <i class="fas fa-exclamation-triangle text-red-500"></i>
 
 
 
 
 
 
 
 
720
  </div>
721
+ <h3 class="text-lg font-semibold text-gray-800">Confirmation de suppression</h3>
722
+ </div>
723
+ <p class="text-gray-600 mb-6">Êtes-vous sûr de vouloir supprimer cette sauvegarde ? Cette action est irréversible.</p>
724
+ <div class="flex justify-end space-x-3">
725
+ <button class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 cancel-btn">Annuler</button>
726
+ <button class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 confirm-btn">Supprimer</button>
727
+ </div>
728
+ </div>
729
+ `;
730
+ document.body.appendChild(confirmationModal);
731
+
732
+ confirmationModal.querySelector('.cancel-btn').addEventListener('click', () => {
733
+ confirmationModal.style.opacity = '0';
734
+ setTimeout(() => {
735
+ document.body.removeChild(confirmationModal);
736
+ }, 300);
 
 
737
  });
738
+
739
+ confirmationModal.querySelector('.confirm-btn').addEventListener('click', () => {
740
+ supprimerSauvegarde(index);
741
+ confirmationModal.style.opacity = '0';
742
+ setTimeout(() => {
743
+ document.body.removeChild(confirmationModal);
744
+ }, 300);
745
+ });
746
+ });
747
+ });
748
+ }
749
+
750
 
751
  async function submitFrancaisForm() {
752
  const form = document.getElementById('francais-form');