Update templates/index.html
Browse files- templates/index.html +865 -126
templates/index.html
CHANGED
|
@@ -2,159 +2,898 @@
|
|
| 2 |
<html lang="fr">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
|
| 6 |
-
<
|
| 7 |
-
<
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
<style>
|
| 10 |
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Inter:wght@300;400;500;600;700&display=swap');
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
body {
|
| 13 |
font-family: 'Inter', sans-serif;
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
cursor: not-allowed;
|
| 24 |
-
opacity: 0.6;
|
| 25 |
-
/* Suppression des effets de hover */
|
| 26 |
-
/* Tailwind: remove hover:border-blue-500 */
|
| 27 |
-
}
|
| 28 |
-
.disabled-drop-zone .text-blue-600 {
|
| 29 |
-
color: #6b7280; /* gray-500 */
|
| 30 |
-
/* Suppression du hover sur le texte */
|
| 31 |
-
/* Tailwind: remove hover:text-blue-700 */
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
/* Styles pour le message "Coming Soon" */
|
| 35 |
-
.coming-soon-banner {
|
| 36 |
-
display: flex;
|
| 37 |
-
align-items: center;
|
| 38 |
-
gap: 0.75rem; /* space-x-3 */
|
| 39 |
-
background-color: #fef3c7; /* yellow-100 */
|
| 40 |
-
color: #92400e; /* yellow-800 */
|
| 41 |
-
padding: 0.75rem 1rem; /* p-3 sm:p-4 */
|
| 42 |
-
border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gray-800 mb-3 opacity-60">
|
| 74 |
-
1. Choisissez votre document
|
| 75 |
-
</label>
|
| 76 |
-
<!-- Ajout de classes pour désactivation visuelle -->
|
| 77 |
-
<div id="dropZone" class="disabled-drop-zone mt-2 flex flex-col items-center justify-center px-4 py-8 sm:px-6 sm:py-10 border-2 border-gray-300 border-dashed rounded-lg bg-gray-50">
|
| 78 |
-
<div class="text-center">
|
| 79 |
-
<svg class="mx-auto h-10 w-10 text-gray-400 mb-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
| 80 |
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 16.5V9.75m0 0l3 3m-3-3l-3 3M6.75 19.5a4.5 4.5 0 01-1.41-8.775 5.25 5.25 0 0110.33-2.33 4.5 4.5 0 013.75 8.775h-1.5M6.75 19.5h10.5" />
|
| 81 |
-
</svg>
|
| 82 |
-
<div class="text-sm sm:text-base text-gray-600">
|
| 83 |
-
<span class="font-medium text-blue-600">Cliquez pour choisir</span> ou glissez-déposez
|
| 84 |
-
</div>
|
| 85 |
-
<p class="text-xs sm:text-sm text-gray-500 mt-1">PNG, JPG, PDF (max 10MB)</p>
|
| 86 |
-
<!-- Input désactivé -->
|
| 87 |
-
<input id="imageInput" name="image" type="file" class="sr-only" accept="image/*,application/pdf" disabled>
|
| 88 |
-
</div>
|
| 89 |
-
<!-- Le nom du fichier ne s'affichera pas -->
|
| 90 |
-
<div id="fileName" class="mt-3 text-sm font-medium text-gray-700 hidden"></div>
|
| 91 |
</div>
|
| 92 |
</div>
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
<label for="consignesInput" class="block text-base sm:text-lg font-semibold text-gray-800 mb-3 opacity-60">
|
| 97 |
-
2. Consignes <span class="text-sm font-normal text-gray-500">(optionnel)</span>
|
| 98 |
-
</label>
|
| 99 |
-
<!-- Textarea désactivée -->
|
| 100 |
-
<textarea id="consignesInput" name="consignes" rows="3" class="w-full border border-gray-300 rounded-md p-3 text-sm placeholder-gray-400 transition duration-150 ease-in-out bg-gray-100 cursor-not-allowed" placeholder="Ex: Analyser les thèmes principaux..." disabled></textarea>
|
| 101 |
</div>
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
</
|
| 108 |
-
<
|
| 109 |
</div>
|
| 110 |
-
|
| 111 |
-
<!-- Bouton (Désactivé) -->
|
| 112 |
-
<button type="submit" class="w-full bg-gray-400 text-white rounded-lg px-4 py-3 text-base font-semibold focus:outline-none cursor-not-allowed shadow-md flex items-center justify-center space-x-2" disabled>
|
| 113 |
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-5 h-5">
|
| 114 |
-
<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.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423L16.5 15.75l.394 1.183a2.25 2.25 0 001.423 1.423L19.5 18.75l-1.183.394a2.25 2.25 0 00-1.423 1.423z" />
|
| 115 |
-
</svg>
|
| 116 |
-
<span>Lancer l'analyse</span>
|
| 117 |
-
</button>
|
| 118 |
</form>
|
|
|
|
| 119 |
|
| 120 |
-
|
| 121 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
</div> <!-- Fin #result -->
|
| 128 |
-
|
| 129 |
-
</div> <!-- Fin Carte Principale -->
|
| 130 |
-
|
| 131 |
-
<footer class="text-center mt-8 mb-4">
|
| 132 |
-
<p class="text-xs text-gray-500">© 2024 Mariam AI - Tous droits réservés.</p>
|
| 133 |
-
</footer>
|
| 134 |
-
|
| 135 |
-
</div> <!-- Fin Container Principal -->
|
| 136 |
|
| 137 |
<script>
|
| 138 |
-
//
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
-
|
| 142 |
const uploadForm = document.getElementById('uploadForm');
|
| 143 |
const imageInput = document.getElementById('imageInput');
|
| 144 |
-
const
|
| 145 |
-
const
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
</script>
|
| 160 |
|
|
|
|
| 2 |
<html lang="fr">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<!-- **Optimisation Mobile: Assure un bon affichage et désactive le zoom manuel** -->
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 7 |
+
<title>Mariam AI - Analyse Littéraire</title>
|
| 8 |
+
|
| 9 |
+
<!-- Bibliothèque marked pour l'AFFICHAGE UTILISATEUR SEULEMENT -->
|
| 10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/9.1.6/marked.min.js"></script>
|
| 11 |
+
|
| 12 |
+
<!-- Bibliothèque jsPDF pour la génération PDF directe -->
|
| 13 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
| 14 |
+
<!-- Plugin jsPDF-AutoTable pour les tableaux -->
|
| 15 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.28/jspdf.plugin.autotable.min.js"></script>
|
| 16 |
+
|
| 17 |
+
|
| 18 |
<style>
|
| 19 |
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Inter:wght@300;400;500;600;700&display=swap');
|
| 20 |
|
| 21 |
+
:root {
|
| 22 |
+
--primary: #4361ee;
|
| 23 |
+
--primary-dark: #3a56d4;
|
| 24 |
+
--secondary: #2b2d42;
|
| 25 |
+
--secondary-light: #8d99ae; /* For secondary button */
|
| 26 |
+
--accent: #ef476f;
|
| 27 |
+
--light: #f8f9fa;
|
| 28 |
+
--gray-100: #f1f3f5;
|
| 29 |
+
--gray-200: #e9ecef;
|
| 30 |
+
--gray-300: #dee2e6;
|
| 31 |
+
--gray-400: #ced4da;
|
| 32 |
+
--gray-700: #495057;
|
| 33 |
+
--shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
|
| 34 |
+
--shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
|
| 35 |
+
--shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
|
| 36 |
+
--radius-sm: 0.375rem; /* 6px */
|
| 37 |
+
--radius-md: 0.5rem; /* 8px */
|
| 38 |
+
--radius-lg: 0.75rem; /* 12px */
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 42 |
+
html { /* Améliore le défilement sur mobile */ -webkit-overflow-scrolling: touch; }
|
| 43 |
body {
|
| 44 |
font-family: 'Inter', sans-serif;
|
| 45 |
+
background: linear-gradient(135deg, #f6f8fb 0%, #f1f3f5 100%);
|
| 46 |
+
color: var(--secondary);
|
| 47 |
+
line-height: 1.6;
|
| 48 |
+
padding-bottom: 2rem;
|
| 49 |
+
min-height: 100vh; /* Assure que le dégradé couvre tout l'écran */
|
| 50 |
+
}
|
| 51 |
+
header {
|
| 52 |
+
background-color: white;
|
| 53 |
+
padding: 1.5rem 1rem; /* Padding par défaut */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
text-align: center;
|
| 55 |
+
box-shadow: var(--shadow-sm);
|
| 56 |
+
position: sticky; /* **Mobile: Rend l'en-tête collant en haut** */
|
| 57 |
+
top: 0;
|
| 58 |
+
z-index: 10;
|
| 59 |
+
width: 100%; /* Nécessaire avec sticky */
|
| 60 |
}
|
| 61 |
+
.logo {
|
| 62 |
+
font-family: 'Playfair Display', serif;
|
| 63 |
+
font-size: 2rem; /* Taille par défaut */
|
| 64 |
+
color: var(--secondary);
|
| 65 |
+
margin-bottom: 0.25rem;
|
| 66 |
+
}
|
| 67 |
+
.tagline {
|
| 68 |
+
font-size: 0.9rem; /* Taille par défaut */
|
| 69 |
+
color: var(--gray-700);
|
| 70 |
+
font-weight: 500;
|
| 71 |
+
}
|
| 72 |
+
.card {
|
| 73 |
+
background: white;
|
| 74 |
+
border-radius: var(--radius-lg);
|
| 75 |
+
box-shadow: var(--shadow-md);
|
| 76 |
+
padding: 1.5rem; /* Padding par défaut */
|
| 77 |
+
margin: 1rem; /* Marge par défaut */
|
| 78 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 79 |
+
}
|
| 80 |
+
.upload-area {
|
| 81 |
+
border: 2px dashed var(--gray-300);
|
| 82 |
+
border-radius: var(--radius-md);
|
| 83 |
+
padding: 1.5rem 1rem; /* Padding par défaut */
|
| 84 |
+
text-align: center;
|
| 85 |
+
cursor: pointer;
|
| 86 |
+
transition: all 0.2s ease;
|
| 87 |
+
margin: 1.5rem 0;
|
| 88 |
+
}
|
| 89 |
+
.upload-area:hover, .upload-area.active {
|
| 90 |
+
border-color: var(--primary);
|
| 91 |
+
background-color: rgba(67, 97, 238, 0.05);
|
| 92 |
+
}
|
| 93 |
+
.upload-icon {
|
| 94 |
+
width: 3.5rem; height: 3.5rem; /* Taille par défaut */
|
| 95 |
+
margin: 0 auto 1rem;
|
| 96 |
+
color: var(--gray-400);
|
| 97 |
+
}
|
| 98 |
+
.upload-area:hover .upload-icon, .upload-area.active .upload-icon {
|
| 99 |
+
color: var(--primary);
|
| 100 |
+
}
|
| 101 |
+
.input-group { margin-bottom: 1.5rem; }
|
| 102 |
+
.label {
|
| 103 |
+
display: block;
|
| 104 |
+
margin-bottom: 0.5rem;
|
| 105 |
+
font-weight: 600;
|
| 106 |
+
font-size: 0.9rem; /* Taille par défaut */
|
| 107 |
+
}
|
| 108 |
+
.input {
|
| 109 |
+
width: 100%;
|
| 110 |
+
padding: 0.75rem; /* Padding par défaut */
|
| 111 |
+
border: 1px solid var(--gray-300);
|
| 112 |
+
border-radius: var(--radius-md);
|
| 113 |
+
font-family: 'Inter', sans-serif;
|
| 114 |
+
font-size: 1rem; /* Taille par défaut */
|
| 115 |
+
transition: border-color 0.2s ease;
|
| 116 |
+
/* **Mobile: Assure que le zoom n'est pas activé sur focus input sous iOS** */
|
| 117 |
+
-webkit-appearance: none;
|
| 118 |
+
appearance: none;
|
| 119 |
+
}
|
| 120 |
+
.input:focus {
|
| 121 |
+
outline: none;
|
| 122 |
+
border-color: var(--primary);
|
| 123 |
+
box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
|
| 124 |
+
}
|
| 125 |
+
.preview-container { margin: 1.5rem 0; }
|
| 126 |
+
.preview-title {
|
| 127 |
+
font-weight: 600;
|
| 128 |
+
margin-bottom: 0.5rem;
|
| 129 |
+
font-size: 0.9rem; /* Taille par défaut */
|
| 130 |
+
}
|
| 131 |
+
.preview-image-container {
|
| 132 |
+
background-color: var(--gray-100);
|
| 133 |
+
border-radius: var(--radius-md);
|
| 134 |
+
overflow: hidden;
|
| 135 |
+
position: relative;
|
| 136 |
+
}
|
| 137 |
+
.preview-image {
|
| 138 |
+
max-width: 100%;
|
| 139 |
+
max-height: 15rem; /* Limite hauteur aperçu */
|
| 140 |
+
height: auto;
|
| 141 |
+
margin: 0 auto;
|
| 142 |
+
display: block;
|
| 143 |
+
}
|
| 144 |
+
.btn {
|
| 145 |
+
display: block;
|
| 146 |
+
width: 100%;
|
| 147 |
+
padding: 0.875rem; /* Padding par défaut */
|
| 148 |
+
font-weight: 600;
|
| 149 |
+
text-align: center;
|
| 150 |
+
border: none;
|
| 151 |
+
border-radius: var(--radius-md);
|
| 152 |
+
cursor: pointer;
|
| 153 |
+
transition: all 0.2s ease;
|
| 154 |
+
font-size: 1rem; /* Taille par défaut */
|
| 155 |
+
/* **Mobile: Empêche la sélection de texte sur appui long** */
|
| 156 |
+
-webkit-user-select: none; user-select: none;
|
| 157 |
+
}
|
| 158 |
+
.btn:disabled {
|
| 159 |
+
background-color: var(--gray-300) !important;
|
| 160 |
+
color: var(--gray-700) !important;
|
| 161 |
+
cursor: not-allowed;
|
| 162 |
+
opacity: 0.7;
|
| 163 |
+
transform: none !important;
|
| 164 |
+
box-shadow: none !important;
|
| 165 |
+
}
|
| 166 |
+
.btn-primary { background-color: var(--primary); color: white; }
|
| 167 |
+
.btn-primary:not(:disabled):hover, .btn-primary:not(:disabled):focus { background-color: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
|
| 168 |
+
.btn-primary:not(:disabled):active { transform: translateY(0); }
|
| 169 |
+
.btn-secondary { background-color: var(--secondary-light); color: var(--secondary); margin-top: 0.75rem; } /* Style for DeepThink */
|
| 170 |
+
.btn-secondary:not(:disabled):hover, .btn-secondary:not(:disabled):focus { background-color: var(--secondary); color: white; transform: translateY(-1px); box-shadow: var(--shadow-md); }
|
| 171 |
+
.btn-secondary:not(:disabled):active { transform: translateY(0); }
|
| 172 |
+
|
| 173 |
+
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 100; padding: 1rem; /* Ajout padding pour mobile */ }
|
| 174 |
+
.loading-card { background-color: white; padding: 2rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); text-align: center; max-width: 90%; /* Légère augmentation pour petits écrans */ }
|
| 175 |
+
.spinner { width: 3rem; height: 3rem; border: 4px solid var(--gray-200); border-radius: 50%; border-top-color: var(--primary); animation: spin 1s linear infinite; margin: 0 auto 1rem; }
|
| 176 |
+
@keyframes spin { to { transform: rotate(360deg); } }
|
| 177 |
+
|
| 178 |
+
.result-card { padding: 0; overflow: hidden; }
|
| 179 |
+
.tabs { display: flex; border-bottom: 1px solid var(--gray-200); background-color: var(--gray-100); width: 100%; /* Assure pleine largeur */ }
|
| 180 |
+
.tab {
|
| 181 |
+
flex: 1; /* Prend espace égal */
|
| 182 |
+
text-align: center;
|
| 183 |
+
padding: 1rem 0.5rem; /* Padding par défaut */
|
| 184 |
+
font-weight: 600;
|
| 185 |
+
font-size: 0.9rem; /* Taille par défaut */
|
| 186 |
+
color: var(--gray-700);
|
| 187 |
+
background-color: transparent;
|
| 188 |
+
border: none;
|
| 189 |
+
border-bottom: 3px solid transparent;
|
| 190 |
+
cursor: pointer;
|
| 191 |
+
transition: color 0.2s ease, border-color 0.2s ease;
|
| 192 |
+
margin-bottom: -1px;
|
| 193 |
+
/* **Mobile: Empêche la sélection de texte** */
|
| 194 |
+
-webkit-user-select: none; user-select: none;
|
| 195 |
+
white-space: nowrap; /* Empêche le retour à la ligne si texte long */
|
| 196 |
+
overflow: hidden; /* Cache le texte qui dépasse */
|
| 197 |
+
text-overflow: ellipsis; /* Ajoute ... si texte dépasse */
|
| 198 |
+
}
|
| 199 |
+
.tab:hover { color: var(--primary); }
|
| 200 |
+
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
|
| 201 |
+
.tab-content { padding: 1.5rem; /* Padding par défaut */ }
|
| 202 |
+
|
| 203 |
+
/* Styles pour le contenu généré (prose/texte) */
|
| 204 |
+
.custom-prose { font-size: 1rem; line-height: 1.8; } /* Taille/interligne par défaut */
|
| 205 |
+
.custom-prose h1, .custom-prose h2, .custom-prose h3 { font-family: 'Playfair Display', serif; margin-top: 1.5em; margin-bottom: 0.75em; line-height: 1.3; color: var(--primary-dark); }
|
| 206 |
+
.custom-prose h1 { font-size: 1.75rem; } .custom-prose h2 { font-size: 1.5rem; } .custom-prose h3 { font-size: 1.25rem; } /* Tailles titres par défaut */
|
| 207 |
+
.custom-prose p { margin-bottom: 1.25em; } .custom-prose ul, .custom-prose ol { margin-top: 1em; margin-bottom: 1em; padding-left: 1.5em; } .custom-prose li { margin-bottom: 0.5em; }
|
| 208 |
+
|
| 209 |
+
/* Styles pour les tableaux générés */
|
| 210 |
+
.markdown-table {
|
| 211 |
+
overflow-x: auto; /* ESSENTIEL pour mobile */
|
| 212 |
+
-webkit-overflow-scrolling: touch; /* Défilement fluide sur iOS */
|
| 213 |
+
border: 1px solid var(--gray-200);
|
| 214 |
+
border-radius: var(--radius-sm);
|
| 215 |
+
margin-top: 1em;
|
| 216 |
+
margin-left: -1.5rem; /* Compense le padding du parent pour utiliser toute la largeur */
|
| 217 |
+
margin-right: -1.5rem; /* Compense le padding du parent */
|
| 218 |
+
padding-left: 0.5rem; /* Petit padding interne pour ne pas coller au bord */
|
| 219 |
+
padding-right: 0.5rem;
|
| 220 |
+
}
|
| 221 |
+
/* Cache l'overflow quand on imprime ou génère PDF */
|
| 222 |
+
#pdfContentWrapper .markdown-table, @media print { overflow-x: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;}
|
| 223 |
+
.markdown-table table { width: 100%; border-collapse: collapse; border-spacing: 0; table-layout: auto; }
|
| 224 |
+
.markdown-table th { background: var(--primary); color: white; font-weight: 600; padding: 0.75rem 1rem; text-align: left; font-size: 0.9rem; border-bottom: 2px solid var(--primary-dark); white-space: nowrap; /* Empêche retour à la ligne des titres */ }
|
| 225 |
+
.markdown-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-200); font-size: 0.9rem; vertical-align: top; word-break: break-word; /* Permet au texte long de passer à la ligne */ }
|
| 226 |
+
.markdown-table tr:nth-child(even) td { background-color: var(--gray-100); }
|
| 227 |
+
.markdown-table tr:hover td { background-color: rgba(67, 97, 238, 0.1); }
|
| 228 |
+
|
| 229 |
+
.upload-instructions { font-size: 0.85rem; color: var(--gray-700); margin-top: 0.5rem; }
|
| 230 |
+
.file-input { display: none; }
|
| 231 |
+
.slide-up { animation: slide-up 0.4s ease forwards; }
|
| 232 |
+
@keyframes slide-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 233 |
+
.streaming-cursor { display: inline-block; width: 2px; height: 1.2em; background-color: var(--primary); margin-left: 1px; animation: blink 1s infinite; vertical-align: text-bottom; opacity: 1; }
|
| 234 |
+
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
|
| 235 |
+
.final-cursor { display: none !important; }
|
| 236 |
+
.button-container { margin-top: 1.5rem; } /* Container for buttons */
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
/* ============================================ */
|
| 240 |
+
/* == OPTIMISATIONS POUR SMARTPHONES (<= 600px) == */
|
| 241 |
+
/* ============================================ */
|
| 242 |
+
@media (max-width: 600px) {
|
| 243 |
+
body {
|
| 244 |
+
padding-bottom: 1rem; /* Moins de padding en bas */
|
| 245 |
+
-webkit-text-size-adjust: 100%; /* Empêche l'ajustement auto de la taille du texte sur iOS */
|
| 246 |
+
}
|
| 247 |
+
header {
|
| 248 |
+
padding: 1rem; /* Header plus compact */
|
| 249 |
+
}
|
| 250 |
+
.logo {
|
| 251 |
+
font-size: 1.75rem; /* Logo légèrement plus petit */
|
| 252 |
+
}
|
| 253 |
+
.tagline {
|
| 254 |
+
font-size: 0.85rem; /* Slogan légèrement plus petit */
|
| 255 |
+
}
|
| 256 |
+
.card {
|
| 257 |
+
margin: 0.75rem; /* Moins de marge horizontale */
|
| 258 |
+
padding: 1.25rem; /* Moins de padding interne */
|
| 259 |
+
border-radius: var(--radius-md); /* Coins un peu moins arrondis si désiré */
|
| 260 |
+
}
|
| 261 |
+
main .card:first-of-type {
|
| 262 |
+
margin-top: 1rem; /* Espace après le header sticky */
|
| 263 |
+
}
|
| 264 |
+
.upload-area {
|
| 265 |
+
padding: 1.25rem 1rem; /* Ajustement padding */
|
| 266 |
+
}
|
| 267 |
+
.upload-icon {
|
| 268 |
+
width: 3rem; height: 3rem; /* Icône légèrement plus petite */
|
| 269 |
+
}
|
| 270 |
+
.upload-instructions {
|
| 271 |
+
font-size: 0.8rem; /* Texte instructions plus petit */
|
| 272 |
+
}
|
| 273 |
+
.label {
|
| 274 |
+
font-size: 0.85rem; /* Label légèrement plus petit */
|
| 275 |
+
}
|
| 276 |
+
.input {
|
| 277 |
+
padding: 0.8rem; /* Padding input ajusté pour le toucher */
|
| 278 |
+
font-size: 1rem; /* Garder 1rem évite le zoom auto sur iOS */
|
| 279 |
+
}
|
| 280 |
+
.preview-title {
|
| 281 |
+
font-size: 0.85rem;
|
| 282 |
+
}
|
| 283 |
+
.btn {
|
| 284 |
+
padding: 0.9rem; /* Boutons un peu plus grands pour le toucher */
|
| 285 |
+
font-size: 0.95rem; /* Texte bouton légèrement plus petit */
|
| 286 |
+
border-radius: var(--radius-sm); /* Rayon plus petit pour boutons */
|
| 287 |
+
}
|
| 288 |
+
.btn-secondary {
|
| 289 |
+
margin-top: 1rem; /* Un peu plus d'espace entre les boutons */
|
| 290 |
+
}
|
| 291 |
+
.tab {
|
| 292 |
+
padding: 0.9rem 0.25rem; /* Padding vertical augmenté pour toucher, horizontal réduit */
|
| 293 |
+
font-size: 0.8rem; /* Texte onglet plus petit */
|
| 294 |
+
}
|
| 295 |
+
.tab-content {
|
| 296 |
+
padding: 1.25rem; /* Padding contenu onglet réduit */
|
| 297 |
+
}
|
| 298 |
+
/* Ajustements taille texte contenu généré */
|
| 299 |
+
.custom-prose {
|
| 300 |
+
font-size: 0.95rem; /* Taille texte principal légèrement réduite */
|
| 301 |
+
line-height: 1.7; /* Interligne confortable */
|
| 302 |
+
}
|
| 303 |
+
.custom-prose h1 { font-size: 1.5rem; }
|
| 304 |
+
.custom-prose h2 { font-size: 1.3rem; }
|
| 305 |
+
.custom-prose h3 { font-size: 1.1rem; }
|
| 306 |
+
|
| 307 |
+
/* Ajustements tableau pour mobile */
|
| 308 |
+
.markdown-table {
|
| 309 |
+
margin-left: -1.25rem; /* Ajuster pour le nouveau padding du parent */
|
| 310 |
+
margin-right: -1.25rem; /* Ajuster pour le nouveau padding du parent */
|
| 311 |
+
padding-left: 0.4rem;
|
| 312 |
+
padding-right: 0.4rem;
|
| 313 |
+
}
|
| 314 |
+
.markdown-table th, .markdown-table td {
|
| 315 |
+
padding: 0.6rem 0.75rem; /* Cellules tableau plus compactes */
|
| 316 |
+
font-size: 0.85rem; /* Texte tableau plus petit */
|
| 317 |
+
}
|
| 318 |
+
/* Optionnel: Rendre le texte des cellules un peu plus petit si nécessaire */
|
| 319 |
+
/* .markdown-table td { font-size: 0.8rem; } */
|
| 320 |
+
|
| 321 |
+
.loading-card {
|
| 322 |
+
padding: 1.5rem; /* Padding chargement réduit */
|
| 323 |
+
}
|
| 324 |
+
.spinner {
|
| 325 |
+
width: 2.5rem; height: 2.5rem; /* Spinner légèrement plus petit */
|
| 326 |
+
margin-bottom: 0.8rem;
|
| 327 |
+
}
|
| 328 |
+
.loading-card p {
|
| 329 |
+
font-size: 0.9rem; /* Texte chargement plus petit */
|
| 330 |
+
}
|
| 331 |
}
|
| 332 |
|
| 333 |
</style>
|
| 334 |
</head>
|
| 335 |
+
<body>
|
| 336 |
+
<header>
|
| 337 |
+
<h1 class="logo">Mariam AI</h1>
|
| 338 |
+
<p class="tagline">Assistant d'Analyse Littéraire</p>
|
| 339 |
+
</header>
|
| 340 |
+
|
| 341 |
+
<main>
|
| 342 |
+
<div class="card">
|
| 343 |
+
<form id="uploadForm">
|
| 344 |
+
<div class="input-group">
|
| 345 |
+
<label for="imageInput" class="label">Votre document</label>
|
| 346 |
+
<div id="uploadArea" class="upload-area">
|
| 347 |
+
<svg class="upload-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>
|
| 348 |
+
<p>Touchez pour télécharger</p>
|
| 349 |
+
<p class="upload-instructions">PNG, JPG jusqu'à 10MB</p>
|
| 350 |
+
<input id="imageInput" type="file" class="file-input" accept="image/*" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
</div>
|
| 352 |
</div>
|
| 353 |
+
<div class="input-group">
|
| 354 |
+
<label for="consignesInput" class="label">Consignes (optionnel)</label>
|
| 355 |
+
<input id="consignesInput" type="text" class="input" placeholder="Entrez vos consignes ici">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
</div>
|
| 357 |
+
<div id="previewContainer" class="preview-container" style="display: none;">
|
| 358 |
+
<p class="preview-title">Aperçu du document</p>
|
| 359 |
+
<div class="preview-image-container"><img id="previewImage" class="preview-image" src="#" alt="Aperçu"></div>
|
| 360 |
+
</div>
|
| 361 |
+
<div class="button-container">
|
| 362 |
+
<button type="submit" class="btn btn-primary">Lancer l'analyse standard</button>
|
| 363 |
+
<button type="button" id="deepThinkBtn" class="btn btn-secondary">DeepThink (1/jour)</button>
|
| 364 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
</form>
|
| 366 |
+
</div>
|
| 367 |
|
| 368 |
+
<div id="result" class="card result-card" style="display: none;">
|
| 369 |
+
<div class="tabs">
|
| 370 |
+
<button id="dissertationTab" class="tab active">Dissertation</button>
|
| 371 |
+
<button id="tableauTab" class="tab">Tableau</button>
|
| 372 |
+
</div>
|
| 373 |
+
<div id="displayContentWrapper">
|
| 374 |
+
<div id="dissertationContentWrapper" class="tab-content">
|
| 375 |
+
<div id="dissertationContent" class="custom-prose"></div>
|
| 376 |
</div>
|
| 377 |
+
<div id="tableauContentWrapper" class="tab-content" style="display: none;">
|
| 378 |
+
<!-- **Mobile: Conteneur spécifique pour le style 'markdown-table' qui gère l'overflow** -->
|
| 379 |
+
<div id="tableauContent" class="markdown-table">
|
| 380 |
+
<!-- Le contenu HTML du tableau sera injecté ici par Marked.js -->
|
| 381 |
+
</div>
|
| 382 |
+
</div>
|
| 383 |
+
</div>
|
| 384 |
+
<div style="padding: 0 1.25rem 1.25rem;"> <!-- Padding ajusté pour mobile -->
|
| 385 |
+
<button id="downloadPdf" class="btn btn-primary" style="margin-top: 1rem;" disabled>Télécharger en PDF</button>
|
| 386 |
+
</div>
|
| 387 |
+
</div>
|
| 388 |
+
</main>
|
| 389 |
|
| 390 |
+
<div id="loading" class="loading-overlay" style="display: none;">
|
| 391 |
+
<div class="loading-card"><div class="spinner"></div><p>Préparation de l'analyse...</p></div>
|
| 392 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
<script>
|
| 395 |
+
// Vérification bibliothèques
|
| 396 |
+
if (typeof window.jspdf === 'undefined') { console.error("Erreur: jsPDF non chargée."); }
|
| 397 |
+
else { console.log("jsPDF chargée:", window.jspdf.jsPDF.version);
|
| 398 |
+
if (typeof window.jspdf.jsPDF.API?.autoTable === 'undefined') { console.error("Erreur: Plugin jsPDF-AutoTable non chargé."); }
|
| 399 |
+
else { console.log("Plugin jsPDF-AutoTable détecté."); }
|
| 400 |
+
}
|
| 401 |
+
if (typeof window.marked === 'undefined') { console.error("Erreur: Marked.js non chargée."); }
|
| 402 |
|
| 403 |
+
// DOM Elements
|
| 404 |
const uploadForm = document.getElementById('uploadForm');
|
| 405 |
const imageInput = document.getElementById('imageInput');
|
| 406 |
+
const consignesInput = document.getElementById('consignesInput');
|
| 407 |
+
const uploadArea = document.getElementById('uploadArea');
|
| 408 |
+
const previewContainer = document.getElementById('previewContainer');
|
| 409 |
+
const previewImage = document.getElementById('previewImage');
|
| 410 |
+
const loadingIndicator = document.getElementById('loading');
|
| 411 |
+
const resultDiv = document.getElementById('result');
|
| 412 |
+
const dissertationTab = document.getElementById('dissertationTab');
|
| 413 |
+
const tableauTab = document.getElementById('tableauTab');
|
| 414 |
+
const dissertationContentWrapper = document.getElementById('dissertationContentWrapper');
|
| 415 |
+
const tableauContentWrapper = document.getElementById('tableauContentWrapper');
|
| 416 |
+
const dissertationContent = document.getElementById('dissertationContent');
|
| 417 |
+
const tableauContent = document.getElementById('tableauContent'); // Référence au conteneur du tableau
|
| 418 |
+
const downloadPdfBtn = document.getElementById('downloadPdf');
|
| 419 |
+
const deepThinkBtn = document.getElementById('deepThinkBtn'); // DeepThink Button
|
| 420 |
+
|
| 421 |
+
// Config marked
|
| 422 |
+
if (typeof window.marked !== 'undefined') {
|
| 423 |
+
marked.setOptions({ breaks: true, gfm: true, mangle: false, headerIds: false });
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
// --- Global state & Constants ---
|
| 427 |
+
let tableauMarkdownRaw = '';
|
| 428 |
+
let dissertationMarkdownRaw = '';
|
| 429 |
+
let currentlyStreaming = null;
|
| 430 |
+
let streamComplete = false;
|
| 431 |
+
const dissertationCursorId = 'dissertationCursor';
|
| 432 |
+
const tableauCursorId = 'tableauCursor';
|
| 433 |
+
const DEEPTHINK_STORAGE_KEY = 'deepThinkLastUsedDate'; // Key for Local Storage
|
| 434 |
+
|
| 435 |
+
// --- Helper Functions ---
|
| 436 |
+
function getCursorElement(type) { return document.getElementById(type === 'dissertation' ? dissertationCursorId : tableauCursorId); }
|
| 437 |
+
function removeCursor(type) { const cursor = getCursorElement(type); if (cursor) { cursor.style.display = 'none'; cursor.classList.add('final-cursor'); } }
|
| 438 |
+
function ensureCursor(type, container) {
|
| 439 |
+
let cursor = getCursorElement(type);
|
| 440 |
+
// Try to append cursor after the table if it exists, otherwise just append to the container.
|
| 441 |
+
// This helps visibility in the scrollable table container.
|
| 442 |
+
const tableElement = container.querySelector('table');
|
| 443 |
+
const targetContainer = (type === 'tableau' && tableElement) ? tableElement.parentElement : container;
|
| 444 |
+
if (!cursor) {
|
| 445 |
+
cursor = document.createElement('span');
|
| 446 |
+
cursor.id = type === 'dissertation' ? dissertationCursorId : tableauCursorId;
|
| 447 |
+
cursor.className = 'streaming-cursor';
|
| 448 |
+
targetContainer.appendChild(cursor);
|
| 449 |
+
}
|
| 450 |
+
cursor.style.display = 'inline-block';
|
| 451 |
+
cursor.classList.remove('final-cursor');
|
| 452 |
+
targetContainer.appendChild(cursor); // Ensure it's the last element in the target container
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
|
| 456 |
+
// --- UI Management ---
|
| 457 |
+
// Standard click for desktop compatibility
|
| 458 |
+
uploadArea.addEventListener('click', () => {
|
| 459 |
+
// Prevent click if triggered immediately after touch end on mobile
|
| 460 |
+
if (uploadArea.dataset.touched) {
|
| 461 |
+
delete uploadArea.dataset.touched;
|
| 462 |
+
return;
|
| 463 |
+
}
|
| 464 |
+
imageInput.click();
|
| 465 |
+
});
|
| 466 |
+
// Utilisation de touchstart/touchend pour réactivité immédiate sur mobile
|
| 467 |
+
uploadArea.addEventListener('touchstart', function(e) {
|
| 468 |
+
e.preventDefault(); // Prevent default touch behavior like scrolling or double-tap zoom
|
| 469 |
+
this.classList.add('active');
|
| 470 |
+
this.dataset.touched = true; // Flag that touch happened
|
| 471 |
+
}, { passive: false });
|
| 472 |
+
uploadArea.addEventListener('touchend', function(e) {
|
| 473 |
+
this.classList.remove('active');
|
| 474 |
+
// Only trigger click if the touch didn't move significantly (optional check, simple version here)
|
| 475 |
+
e.preventDefault(); // Prevent ghost click on some devices
|
| 476 |
+
imageInput.click();
|
| 477 |
+
// Set a flag or timeout to potentially ignore the subsequent 'click' event
|
| 478 |
+
setTimeout(() => { delete uploadArea.dataset.touched; }, 300); // Remove flag after a delay
|
| 479 |
+
});
|
| 480 |
+
|
| 481 |
+
|
| 482 |
+
imageInput.addEventListener('change', function() { const file = this.files[0]; if (file) { const reader = new FileReader(); reader.onload = function(e) { previewImage.src = e.target.result; previewContainer.style.display = 'block'; previewContainer.classList.add('slide-up'); uploadArea.classList.add('active'); }; reader.readAsDataURL(file); } else { previewContainer.style.display = 'none'; uploadArea.classList.remove('active'); } });
|
| 483 |
+
dissertationTab.addEventListener('click', () => switchTab('dissertation'));
|
| 484 |
+
tableauTab.addEventListener('click', () => switchTab('tableau'));
|
| 485 |
+
function switchTab(tabName) { const isDissertation = tabName === 'dissertation'; dissertationTab.classList.toggle('active', isDissertation); tableauTab.classList.toggle('active', !isDissertation); dissertationContentWrapper.style.display = isDissertation ? 'block' : 'none'; tableauContentWrapper.style.display = !isDissertation ? 'block' : 'none'; }
|
| 486 |
+
|
| 487 |
+
// --- DeepThink Daily Limit Logic ---
|
| 488 |
+
function checkDeepThinkLimit() {
|
| 489 |
+
const lastUsedDate = localStorage.getItem(DEEPTHINK_STORAGE_KEY);
|
| 490 |
+
const todayDate = new Date().toDateString(); // Gets "Mon Apr 15 2024" format
|
| 491 |
+
|
| 492 |
+
if (lastUsedDate === todayDate) {
|
| 493 |
+
deepThinkBtn.disabled = true;
|
| 494 |
+
deepThinkBtn.textContent = "DeepThink (Utilisé)"; // Texte plus court pour mobile
|
| 495 |
+
console.log("DeepThink limit reached for today.");
|
| 496 |
+
} else {
|
| 497 |
+
deepThinkBtn.disabled = false;
|
| 498 |
+
deepThinkBtn.textContent = "DeepThink (1/jour)";
|
| 499 |
+
console.log("DeepThink available.");
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
function recordDeepThinkUsage() {
|
| 504 |
+
const todayDate = new Date().toDateString();
|
| 505 |
+
localStorage.setItem(DEEPTHINK_STORAGE_KEY, todayDate);
|
| 506 |
+
deepThinkBtn.disabled = true;
|
| 507 |
+
deepThinkBtn.textContent = "DeepThink (Utilisé)"; // Texte plus court pour mobile
|
| 508 |
+
console.log("DeepThink usage recorded for today.");
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
// --- Streaming Logic ---
|
| 512 |
+
function updateDisplayContent(type) {
|
| 513 |
+
if (typeof window.marked === 'undefined') return;
|
| 514 |
+
if (type === 'tableau') {
|
| 515 |
+
// Injecte le HTML généré par Marked DANS le div 'tableauContent'.
|
| 516 |
+
// Le div 'tableauContent' a déjà la classe 'markdown-table' pour l'overflow.
|
| 517 |
+
tableauContent.innerHTML = marked.parse(tableauMarkdownRaw);
|
| 518 |
+
ensureCursor('tableau', tableauContent); // Place cursor within the container
|
| 519 |
+
} else if (type === 'dissertation') {
|
| 520 |
+
dissertationContent.innerHTML = marked.parse(dissertationMarkdownRaw);
|
| 521 |
+
ensureCursor('dissertation', dissertationContent);
|
| 522 |
+
}
|
| 523 |
+
}
|
| 524 |
+
function processStreamChunk(jsonData, isDeepThink) { // Pass deepthink flag
|
| 525 |
+
try {
|
| 526 |
+
const parsedData = JSON.parse(jsonData);
|
| 527 |
+
if (parsedData.error) { console.error("Erreur serveur:", parsedData.error); alert("Erreur serveur: " + parsedData.error); loadingIndicator.style.display = 'none'; downloadPdfBtn.disabled = true; if (currentlyStreaming) removeCursor(currentlyStreaming); streamComplete = true; return; }
|
| 528 |
+
|
| 529 |
+
// First chunk received successfully
|
| 530 |
+
if (resultDiv.style.display === 'none') {
|
| 531 |
+
resultDiv.style.display = 'block';
|
| 532 |
+
resultDiv.classList.add('slide-up');
|
| 533 |
+
loadingIndicator.style.display = 'none';
|
| 534 |
+
switchTab('dissertation'); // Default to dissertation tab
|
| 535 |
+
// Record usage ONLY if it was a DeepThink request and this is the first chunk
|
| 536 |
+
if (isDeepThink) {
|
| 537 |
+
recordDeepThinkUsage();
|
| 538 |
+
}
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
if (parsedData.type === 'tableau') { tableauMarkdownRaw += parsedData.chunk; }
|
| 542 |
+
else if (parsedData.type === 'dissertation') { dissertationMarkdownRaw += parsedData.chunk; }
|
| 543 |
+
else { console.warn("Type de chunk inconnu reçu:", parsedData.type); return; }
|
| 544 |
+
|
| 545 |
+
if (currentlyStreaming !== parsedData.type) { if (currentlyStreaming) { removeCursor(currentlyStreaming); } currentlyStreaming = parsedData.type; }
|
| 546 |
+
updateDisplayContent(parsedData.type);
|
| 547 |
+
|
| 548 |
+
} catch (e) { if (e instanceof SyntaxError) { console.warn("Chunk JSON invalide:", jsonData, e); } else { console.error("Erreur traitement chunk:", e, jsonData); } }
|
| 549 |
+
}
|
| 550 |
+
function handleStreamEnd() { console.log("Fin du stream."); streamComplete = true; if (currentlyStreaming) { removeCursor(currentlyStreaming); } loadingIndicator.style.display = 'none'; downloadPdfBtn.disabled = false; currentlyStreaming = null; }
|
| 551 |
+
|
| 552 |
+
// --- Analysis Request Logic (Reusable) ---
|
| 553 |
+
function startAnalysis(formData) {
|
| 554 |
+
// Reset state before starting
|
| 555 |
+
tableauMarkdownRaw = ''; dissertationMarkdownRaw = ''; currentlyStreaming = null; streamComplete = false;
|
| 556 |
+
dissertationContent.innerHTML = ''; tableauContent.innerHTML = ''; // Clear previous content
|
| 557 |
+
resultDiv.style.display = 'none'; loadingIndicator.style.display = 'flex'; downloadPdfBtn.disabled = true; switchTab('dissertation');
|
| 558 |
+
|
| 559 |
+
const isDeepThinkRequest = formData.get('use_deepthink') === 'true';
|
| 560 |
+
console.log(`Lancement de l'analyse ${isDeepThinkRequest ? 'DeepThink' : 'standard'}...`);
|
| 561 |
+
|
| 562 |
+
fetch('/analyze', { method: 'POST', body: formData })
|
| 563 |
+
.then(response => {
|
| 564 |
+
if (!response.ok) {
|
| 565 |
+
return response.text().then(text => {
|
| 566 |
+
let errorMsg = `Erreur HTTP ${response.status}: ${response.statusText}`;
|
| 567 |
+
try { const errData = JSON.parse(text); errorMsg += `. Détail: ${errData.error || text}`; } catch (e) { errorMsg += `. Détail: ${text}`; }
|
| 568 |
+
throw new Error(errorMsg);
|
| 569 |
+
});
|
| 570 |
+
}
|
| 571 |
+
if (!response.body) { throw new Error("Réponse serveur sans corps."); }
|
| 572 |
+
const reader = response.body.getReader();
|
| 573 |
+
const decoder = new TextDecoder();
|
| 574 |
+
function read() {
|
| 575 |
+
reader.read().then(({done, value}) => {
|
| 576 |
+
if (done) { handleStreamEnd(); return; }
|
| 577 |
+
const text = decoder.decode(value, {stream: true});
|
| 578 |
+
const lines = text.split('\n').filter(line => line.trim() !== '');
|
| 579 |
+
// Pass the isDeepThinkRequest flag to processStreamChunk
|
| 580 |
+
lines.forEach(line => { processStreamChunk(line, isDeepThinkRequest); });
|
| 581 |
+
read();
|
| 582 |
+
}).catch(error => { console.error('Erreur lecture stream:', error); alert('Erreur réception analyse: ' + error.message); loadingIndicator.style.display = 'none'; downloadPdfBtn.disabled = true; if (currentlyStreaming) removeCursor(currentlyStreaming); streamComplete = true; });
|
| 583 |
+
}
|
| 584 |
+
read();
|
| 585 |
+
})
|
| 586 |
+
.catch(error => { console.error('Erreur Fetch:', error); loadingIndicator.style.display = 'none'; alert(`Erreur connexion/analyse: ${error.message}`); downloadPdfBtn.disabled = true; streamComplete = true; });
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
// --- Form Submission Handlers ---
|
| 590 |
+
uploadForm.addEventListener('submit', function(e) {
|
| 591 |
+
e.preventDefault(); // Prevent default form submission
|
| 592 |
+
if (imageInput.files.length === 0) { alert("Veuillez sélectionner un fichier image."); return; }
|
| 593 |
+
|
| 594 |
+
const formData = new FormData();
|
| 595 |
+
formData.append('image', imageInput.files[0]);
|
| 596 |
+
formData.append('consignes', consignesInput.value);
|
| 597 |
+
// NO use_deepthink flag here for standard analysis
|
| 598 |
+
|
| 599 |
+
startAnalysis(formData); // Call the reusable analysis function
|
| 600 |
+
});
|
| 601 |
+
|
| 602 |
+
deepThinkBtn.addEventListener('click', function() {
|
| 603 |
+
if (this.disabled) {
|
| 604 |
+
alert("La fonctionnalité DeepThink est limitée à une utilisation par jour.");
|
| 605 |
+
return;
|
| 606 |
+
}
|
| 607 |
+
if (imageInput.files.length === 0) { alert("Veuillez sélectionner un fichier image avant de lancer DeepThink."); return; }
|
| 608 |
+
|
| 609 |
+
// Double check limit just before sending
|
| 610 |
+
const lastUsedDate = localStorage.getItem(DEEPTHINK_STORAGE_KEY);
|
| 611 |
+
const todayDate = new Date().toDateString();
|
| 612 |
+
if(lastUsedDate === todayDate) {
|
| 613 |
+
alert("DeepThink a déjà été utilisé aujourd'hui.");
|
| 614 |
+
checkDeepThinkLimit(); // Update button state if needed
|
| 615 |
+
return;
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
const formData = new FormData();
|
| 619 |
+
formData.append('image', imageInput.files[0]);
|
| 620 |
+
formData.append('consignes', consignesInput.value);
|
| 621 |
+
formData.append('use_deepthink', 'true'); // ADD THE FLAG FOR DEEPTHINK
|
| 622 |
+
|
| 623 |
+
startAnalysis(formData); // Call the reusable analysis function
|
| 624 |
+
});
|
| 625 |
+
|
| 626 |
+
|
| 627 |
+
// --- PDF Download Logic (Unchanged logic, should still work) ---
|
| 628 |
+
downloadPdfBtn.addEventListener('click', () => {
|
| 629 |
+
if (!streamComplete || (!dissertationMarkdownRaw && !tableauMarkdownRaw)) {
|
| 630 |
+
alert("Analyse non terminée ou contenu vide.");
|
| 631 |
+
return;
|
| 632 |
+
}
|
| 633 |
+
if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined' || typeof window.jspdf.jsPDF.API.autoTable === 'undefined') {
|
| 634 |
+
alert("Erreur critique : jsPDF ou le plugin AutoTable ne sont pas disponibles.");
|
| 635 |
+
return;
|
| 636 |
+
}
|
| 637 |
+
const { jsPDF } = window.jspdf;
|
| 638 |
+
|
| 639 |
+
console.log("Préparation du PDF avec détection de blocs...");
|
| 640 |
+
downloadPdfBtn.disabled = true;
|
| 641 |
+
downloadPdfBtn.textContent = "Génération PDF...";
|
| 642 |
+
|
| 643 |
+
try {
|
| 644 |
+
const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' });
|
| 645 |
+
const pageHeight = pdf.internal.pageSize.getHeight();
|
| 646 |
+
const pageWidth = pdf.internal.pageSize.getWidth();
|
| 647 |
+
const margin = 40;
|
| 648 |
+
const maxLineWidth = pageWidth - margin * 2;
|
| 649 |
+
const fontSize = 10; // Base font size for PDF
|
| 650 |
+
const lineHeightFactor = 1.3;
|
| 651 |
+
const lineHeight = fontSize * lineHeightFactor;
|
| 652 |
+
let cursorY = margin;
|
| 653 |
+
|
| 654 |
+
pdf.setFontSize(fontSize);
|
| 655 |
+
// Utiliser une police standard comme Helvetica pour une meilleure compatibilité PDF embarquée
|
| 656 |
+
pdf.setFont("Helvetica", "normal");
|
| 657 |
+
|
| 658 |
+
function addTextToPage(text) {
|
| 659 |
+
if (!text) return;
|
| 660 |
+
// Basic cleaning: remove markdown markers for simplicity in PDF text blocks
|
| 661 |
+
const simplifiedText = text.trim()
|
| 662 |
+
.replace(/^#+\s+/gm, '') // Remove heading markers
|
| 663 |
+
.replace(/^[\*\-]\s+/gm, ' '); // Replace list markers with indent
|
| 664 |
+
const lines = pdf.splitTextToSize(simplifiedText, maxLineWidth);
|
| 665 |
+
lines.forEach(line => {
|
| 666 |
+
if (cursorY + lineHeight > pageHeight - margin) { pdf.addPage(); cursorY = margin; }
|
| 667 |
+
pdf.text(line, margin, cursorY); cursorY += lineHeight;
|
| 668 |
+
});
|
| 669 |
+
cursorY += lineHeight * 0.5; // Add some space after paragraph
|
| 670 |
+
}
|
| 671 |
+
function addTitleToPage(titleText, level = 1) {
|
| 672 |
+
if (!titleText) return;
|
| 673 |
+
const titleSize = level === 1 ? 16 : (level === 2 ? 14 : 12);
|
| 674 |
+
const titleLineHeight = titleSize * lineHeightFactor;
|
| 675 |
+
if (cursorY + titleLineHeight > pageHeight - margin) { pdf.addPage(); cursorY = margin; }
|
| 676 |
+
pdf.setFontSize(titleSize); pdf.setFont("Helvetica", "bold");
|
| 677 |
+
pdf.text(titleText.trim(), margin, cursorY);
|
| 678 |
+
pdf.setFontSize(fontSize); pdf.setFont("Helvetica", "normal"); // Reset to normal
|
| 679 |
+
cursorY += titleLineHeight + 6; // Space after title
|
| 680 |
+
}
|
| 681 |
+
function parseMarkdownTable(mdTableBlock) {
|
| 682 |
+
if (!mdTableBlock || typeof mdTableBlock !== 'string') return { head: [], body: [] };
|
| 683 |
+
const lines = mdTableBlock.trim().split('\n');
|
| 684 |
+
const cleanCell = (cell) => cell ? cell.trim() : ''; // Function to trim cell content
|
| 685 |
+
|
| 686 |
+
let headerLineIndex = -1, separatorLineIndex = -1;
|
| 687 |
+
|
| 688 |
+
// Find header and separator lines more robustly
|
| 689 |
+
for(let i = 0; i < lines.length; i++) {
|
| 690 |
+
const trimmedLine = lines[i].trim();
|
| 691 |
+
if (trimmedLine.startsWith('|') && trimmedLine.endsWith('|')) {
|
| 692 |
+
// Check for separator line (allows alignment colons)
|
| 693 |
+
if (trimmedLine.includes('-') && trimmedLine.replace(/\|/g, '').replace(/-/g, '').replace(/:/g, '').trim() === '') {
|
| 694 |
+
separatorLineIndex = i;
|
| 695 |
+
// Check if the previous line looks like a header
|
| 696 |
+
if (i > 0 && lines[i-1].trim().startsWith('|') && lines[i-1].trim().endsWith('|')) {
|
| 697 |
+
headerLineIndex = i - 1;
|
| 698 |
+
break; // Found both, exit loop
|
| 699 |
+
}
|
| 700 |
+
} else if (headerLineIndex === -1 && separatorLineIndex === -1) {
|
| 701 |
+
// Potential header line if we haven't found one yet and not passed separator
|
| 702 |
+
headerLineIndex = i;
|
| 703 |
+
}
|
| 704 |
+
}
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
// Validate findings
|
| 708 |
+
if (headerLineIndex === -1 || separatorLineIndex === -1 || separatorLineIndex !== headerLineIndex + 1) {
|
| 709 |
+
console.warn("Structure de tableau Markdown non standard ou incomplète:", mdTableBlock.substring(0, 100));
|
| 710 |
+
// Fallback attempt if structure is simple (Header \n Separator \n ...)
|
| 711 |
+
if (lines.length >= 2 && lines[0].includes('|') && lines[1].includes('|') && lines[1].includes('-')) {
|
| 712 |
+
headerLineIndex = 0; separatorLineIndex = 1;
|
| 713 |
+
console.log("Fallback: Utilisation des deux premières lignes comme header/separator.");
|
| 714 |
+
} else {
|
| 715 |
+
return { head: [], body: [] }; // Cannot parse reliably
|
| 716 |
+
}
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
const headerLine = lines[headerLineIndex];
|
| 720 |
+
// Extract header cells, removing empty strings from start/end splits
|
| 721 |
+
const head = headerLine.split('|').map(cleanCell).filter((cell, i, arr) => i > 0 && i < arr.length - 1);
|
| 722 |
+
|
| 723 |
+
const body = lines.slice(separatorLineIndex + 1)
|
| 724 |
+
.map(line => {
|
| 725 |
+
const trimmedLine = line.trim();
|
| 726 |
+
// Ensure it's a valid table row line
|
| 727 |
+
if (!trimmedLine.startsWith('|') || !trimmedLine.endsWith('|')) return null;
|
| 728 |
+
// Extract row cells, removing empty strings from start/end splits
|
| 729 |
+
return trimmedLine.split('|').map(cleanCell).filter((cell, i, arr) => i > 0 && i < arr.length - 1);
|
| 730 |
+
})
|
| 731 |
+
// Keep only valid rows (not null) with the correct number of cells matching the header
|
| 732 |
+
.filter(row => row && row.length === head.length);
|
| 733 |
+
|
| 734 |
+
return { head: [head], body: body }; // Return jspdf-autotable compatible format
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
|
| 738 |
+
// Combine dissertation and table markdown for sequential processing
|
| 739 |
+
const fullMarkdownText = dissertationMarkdownRaw + "\n\n" + tableauMarkdownRaw;
|
| 740 |
+
const lines = fullMarkdownText.split('\n');
|
| 741 |
+
let currentBlock = ''; // Accumulates lines of text or a table
|
| 742 |
+
let isInsideTable = false; // Flag to track if we are processing table lines
|
| 743 |
+
|
| 744 |
+
for (let i = 0; i < lines.length; i++) {
|
| 745 |
+
const line = lines[i];
|
| 746 |
+
const trimmedLine = line.trim();
|
| 747 |
+
const isTableLine = trimmedLine.startsWith('|') && trimmedLine.endsWith('|');
|
| 748 |
+
// More robust separator check (allows for alignment colons like |:---|:--|)
|
| 749 |
+
const isSeparatorLine = isTableLine && trimmedLine.includes('-') && trimmedLine.replace(/\|/g, '').replace(/-/g, '').replace(/:/g, '').trim() === '';
|
| 750 |
+
|
| 751 |
+
if (isTableLine && !isSeparatorLine) { // Potential header or data row
|
| 752 |
+
if (!isInsideTable) {
|
| 753 |
+
// Check if the *next* line is a separator to confirm start of a table
|
| 754 |
+
const nextLineIndex = i + 1;
|
| 755 |
+
const nextLine = (nextLineIndex < lines.length) ? lines[nextLineIndex].trim() : null;
|
| 756 |
+
const nextLineIsSeparator = nextLine && nextLine.startsWith('|') && nextLine.endsWith('|') && nextLine.includes('-') && nextLine.replace(/\|/g, '').replace(/-/g, '').replace(/:/g, '').trim() === '';
|
| 757 |
+
|
| 758 |
+
if (nextLineIsSeparator) {
|
| 759 |
+
// Start of a table detected
|
| 760 |
+
if (currentBlock.trim()) { // Add any preceding text first
|
| 761 |
+
addTextToPage(currentBlock.trim());
|
| 762 |
+
}
|
| 763 |
+
currentBlock = line + '\n'; // Start accumulating table block
|
| 764 |
+
isInsideTable = true;
|
| 765 |
+
} else {
|
| 766 |
+
// Just a regular line containing pipes, treat as text
|
| 767 |
+
currentBlock += line + '\n';
|
| 768 |
+
}
|
| 769 |
+
} else {
|
| 770 |
+
// Already inside a table, accumulate the line
|
| 771 |
+
currentBlock += line + '\n';
|
| 772 |
+
}
|
| 773 |
+
} else if (isSeparatorLine) { // Separator line
|
| 774 |
+
if (isInsideTable) {
|
| 775 |
+
// Part of the current table block
|
| 776 |
+
currentBlock += line + '\n';
|
| 777 |
+
} else {
|
| 778 |
+
// Separator outside a table context? Treat as text.
|
| 779 |
+
// This might happen with badly formatted markdown.
|
| 780 |
+
currentBlock += line + '\n';
|
| 781 |
+
}
|
| 782 |
+
} else { // Not a table line (or separator)
|
| 783 |
+
if (isInsideTable) {
|
| 784 |
+
// End of the table block detected (current line is non-table)
|
| 785 |
+
console.log("Traitement bloc tableau détecté.");
|
| 786 |
+
const tableData = parseMarkdownTable(currentBlock.trim());
|
| 787 |
+
if (tableData.head.length > 0 && tableData.head[0].length > 0) {
|
| 788 |
+
if (cursorY + 30 > pageHeight - margin) { pdf.addPage(); cursorY = margin; } // Check space before adding table
|
| 789 |
+
pdf.autoTable({
|
| 790 |
+
head: tableData.head, body: tableData.body, startY: cursorY,
|
| 791 |
+
theme: 'grid', // 'striped', 'grid', 'plain'
|
| 792 |
+
styles: { fontSize: 9, cellPadding: 5, overflow: 'linebreak', font: "Helvetica" }, // Use standard font
|
| 793 |
+
headStyles: { fillColor: [67, 97, 238], textColor: [255, 255, 255], fontStyle: 'bold', halign: 'center' },
|
| 794 |
+
didParseCell: function (data) { data.cell.styles.valign = 'middle'; }, // Vertically align cell content
|
| 795 |
+
margin: { left: margin, right: margin }
|
| 796 |
+
});
|
| 797 |
+
cursorY = pdf.previousAutoTable.finalY + lineHeight; // Update cursor position
|
| 798 |
+
} else {
|
| 799 |
+
console.warn("Échec parsing bloc tableau ou tableau vide.");
|
| 800 |
+
addTextToPage("(Erreur: Bloc tableau non formaté ou vide)\n" + currentBlock.trim());
|
| 801 |
+
}
|
| 802 |
+
currentBlock = line + '\n'; // Start new text block with the current line
|
| 803 |
+
isInsideTable = false;
|
| 804 |
+
} else {
|
| 805 |
+
// Regular text line processing
|
| 806 |
+
if (trimmedLine.startsWith('#')) { // Handle headings
|
| 807 |
+
if (currentBlock.trim()) { addTextToPage(currentBlock.trim()); } // Add preceding text
|
| 808 |
+
const level = (trimmedLine.match(/^#+/) || [''])[0].length;
|
| 809 |
+
const titleText = trimmedLine.replace(/^#+\s*/, '');
|
| 810 |
+
addTitleToPage(titleText, level);
|
| 811 |
+
currentBlock = ''; // Reset block after title
|
| 812 |
+
} else {
|
| 813 |
+
// Accumulate regular text line
|
| 814 |
+
currentBlock += line + '\n';
|
| 815 |
+
}
|
| 816 |
+
}
|
| 817 |
+
}
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
// Process any remaining block after the loop finishes
|
| 821 |
+
if (currentBlock.trim()) {
|
| 822 |
+
if (isInsideTable) {
|
| 823 |
+
// The document ended while inside a table block
|
| 824 |
+
console.log("Traitement dernier bloc (tableau).");
|
| 825 |
+
const tableData = parseMarkdownTable(currentBlock.trim());
|
| 826 |
+
if (tableData.head.length > 0 && tableData.head[0].length > 0) {
|
| 827 |
+
if (cursorY + 30 > pageHeight - margin) { pdf.addPage(); cursorY = margin; }
|
| 828 |
+
pdf.autoTable({
|
| 829 |
+
head: tableData.head, body: tableData.body, startY: cursorY,
|
| 830 |
+
theme: 'grid', styles: { fontSize: 9, cellPadding: 5, overflow: 'linebreak', font: "Helvetica" },
|
| 831 |
+
headStyles: { fillColor: [67, 97, 238], textColor: [255, 255, 255], fontStyle: 'bold', halign: 'center' },
|
| 832 |
+
didParseCell: function (data) { data.cell.styles.valign = 'middle'; },
|
| 833 |
+
margin: { left: margin, right: margin }
|
| 834 |
+
});
|
| 835 |
+
} else {
|
| 836 |
+
console.warn("Échec parsing dernier bloc tableau ou tableau vide.");
|
| 837 |
+
addTextToPage("(Erreur: Dernier bloc tableau non formaté ou vide)\n" + currentBlock.trim());
|
| 838 |
+
}
|
| 839 |
+
} else {
|
| 840 |
+
// Last block was text
|
| 841 |
+
console.log("Ajout dernier bloc texte.");
|
| 842 |
+
addTextToPage(currentBlock.trim());
|
| 843 |
+
}
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
console.log("Contenu ajouté, sauvegarde du PDF...");
|
| 847 |
+
pdf.save('MariamAI-Analyse-Resultat.pdf');
|
| 848 |
+
|
| 849 |
+
} catch (error) {
|
| 850 |
+
console.error("Erreur lors de la génération du PDF mixte:", error);
|
| 851 |
+
alert("Une erreur s'est produite lors de la création du PDF mixte.");
|
| 852 |
+
} finally {
|
| 853 |
+
downloadPdfBtn.disabled = false;
|
| 854 |
+
downloadPdfBtn.textContent = "Télécharger en PDF";
|
| 855 |
+
}
|
| 856 |
+
});
|
| 857 |
+
|
| 858 |
+
// --- Initialisation ---
|
| 859 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 860 |
+
switchTab('dissertation');
|
| 861 |
+
checkDeepThinkLimit(); // Check limit on page load
|
| 862 |
+
|
| 863 |
+
// Améliorations tactiles génériques (peuvent rester pour les boutons/tabs)
|
| 864 |
+
const interactiveElements = document.querySelectorAll('.btn, .tab'); // Upload area has specific handlers now
|
| 865 |
+
interactiveElements.forEach(el => {
|
| 866 |
+
let touchMoved = false;
|
| 867 |
+
// Use passive: true where possible to improve scrolling performance
|
| 868 |
+
el.addEventListener('touchstart', function() {
|
| 869 |
+
touchMoved = false;
|
| 870 |
+
if (!this.disabled) {
|
| 871 |
+
// Apply visual feedback instantly on touch
|
| 872 |
+
this.style.transition = 'transform 0.1s ease, background-color 0.1s ease';
|
| 873 |
+
this.style.transform = 'scale(0.97)';
|
| 874 |
+
// Maybe slightly change background for immediate feedback
|
| 875 |
+
// Example: this.style.backgroundColor = 'rgba(0,0,0,0.05)';
|
| 876 |
+
}
|
| 877 |
+
}, { passive: true });
|
| 878 |
|
| 879 |
+
el.addEventListener('touchmove', function() {
|
| 880 |
+
touchMoved = true; // User is likely scrolling
|
| 881 |
+
this.style.transform = 'scale(1)'; // Reset visual feedback if touch moves
|
| 882 |
+
// Reset background if changed on touchstart
|
| 883 |
+
}, { passive: true });
|
| 884 |
|
| 885 |
+
el.addEventListener('touchend', function() {
|
| 886 |
+
// Reset transform only on touchend, giving the 'pressed' effect
|
| 887 |
+
this.style.transform = 'scale(1)';
|
| 888 |
+
// Reset background if changed on touchstart
|
| 889 |
+
}); // Not passive, might be needed for subsequent logic
|
| 890 |
|
| 891 |
+
// Keep mouse events for desktop compatibility
|
| 892 |
+
el.addEventListener('mousedown', function() { if (!this.disabled) { this.style.transform = 'scale(0.97)'; } });
|
| 893 |
+
el.addEventListener('mouseup', function() { this.style.transform = 'scale(1)'; });
|
| 894 |
+
el.addEventListener('mouseleave', function() { this.style.transform = 'scale(1)'; }); // Reset if mouse leaves while pressed
|
| 895 |
+
});
|
| 896 |
+
});
|
| 897 |
|
| 898 |
</script>
|
| 899 |
|