Docfile commited on
Commit
db0d89d
·
verified ·
1 Parent(s): a91af02

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +385 -479
templates/index.html CHANGED
@@ -1,507 +1,413 @@
1
  <!DOCTYPE html>
2
  <html lang="fr">
3
  <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Mariam AI!</title>
7
-
8
- <!-- Tailwind CSS via CDN (inclut le plugin Forms) -->
9
- <script src="https://cdn.tailwindcss.com?plugins=forms"></script>
10
-
11
- <!-- Favicon (Emoji simple) -->
12
- <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🤖</text></svg>">
13
-
14
- <style>
15
- /* Styles pour assurer la hauteur complète et le bon fonctionnement du scroll */
16
- html, body {
17
- height: 100%;
18
- margin: 0;
19
- padding: 0;
20
- overflow: hidden; /* Empêche le scroll sur le body lui-même */
21
- }
22
- body {
23
- display: flex;
24
- flex-direction: column;
25
- font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
26
- }
27
- #chat-container {
28
- display: flex;
29
- flex-direction: column;
30
- flex-grow: 1; /* Prend l'espace restant */
31
- min-height: 0; /* Essentiel pour le scroll dans un conteneur flex */
32
- }
33
- #chat-messages {
34
- flex-grow: 1;
35
- overflow-y: auto; /* Active le scroll vertical uniquement sur cette zone */
36
- min-height: 0; /* Essentiel pour le scroll dans un conteneur flex */
37
- }
38
-
39
- /* Style personnalisé pour la barre de défilement (optionnel) */
40
- ::-webkit-scrollbar {
41
- width: 8px;
42
- }
43
- ::-webkit-scrollbar-track {
44
- background: #f1f1f1;
45
- border-radius: 10px;
46
- }
47
- ::-webkit-scrollbar-thumb {
48
- background: #a8a8a8; /* Gris plus doux */
49
- border-radius: 10px;
50
- }
51
- ::-webkit-scrollbar-thumb:hover {
52
- background: #7a7a7a; /* Gris plus foncé au survol */
53
- }
54
-
55
- /* Amélioration du rendu Markdown par défaut (via classes Prose de Tailwind principalement) */
56
- /* Ciblage plus spécifique pour éviter conflits si prose est utilisé ailleurs */
57
- #chat-messages .prose code:not(pre code) { /* Code inline */
58
- background-color: #e5e7eb; /* gray-200 */
59
- padding: 0.2em 0.4em;
60
- font-size: 85%;
61
- border-radius: 4px;
62
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
63
- }
64
- #chat-messages .prose pre { /* Bloc de code */
65
- background-color: #f3f4f6; /* gray-100 */
66
- padding: 0.8em 1em;
67
- border-radius: 6px;
68
- overflow-x: auto; /* Scroll horizontal si nécessaire */
69
- font-size: 0.875rem; /* text-sm */
70
- }
71
- #chat-messages .prose pre code { /* Code dans un bloc pre */
72
- background-color: transparent;
73
- padding: 0;
74
- font-size: inherit;
75
- border-radius: 0;
76
- color: inherit;
77
- }
78
- #chat-messages .prose blockquote {
79
- border-left-color: #9ca3af; /* gray-400 */
80
- color: #4b5563; /* gray-600 */
81
- }
82
- #chat-messages .prose strong {
83
- color: #1f2937; /* gray-800 */
84
- }
85
- #chat-messages .prose a {
86
- color: #2563eb; /* blue-600 */
87
- text-decoration: underline;
88
- text-decoration-color: #93c5fd; /* blue-300 */
89
- transition: color 0.2s ease;
90
- }
91
- #chat-messages .prose a:hover {
92
- color: #1d4ed8; /* blue-700 */
93
- text-decoration-color: #60a5fa; /* blue-400 */
94
- }
95
-
96
- /* Style pour le chargement initial de l'historique */
97
- #history-loading {
98
- padding: 20px;
99
- text-align: center;
100
- color: #6b7280; /* gray-500 */
101
- font-style: italic;
102
- }
103
- </style>
104
  </head>
105
- <body class="bg-gray-100 flex flex-col h-screen">
106
-
107
- <!-- En-tête fixe -->
108
- <header class="bg-gradient-to-r from-cyan-500 to-blue-500 text-white p-3 sm:p-4 shadow-md flex justify-between items-center sticky top-0 z-10 flex-shrink-0">
109
- <h1 class="text-xl sm:text-2xl font-bold">Mariam AI!</h1>
110
- <!-- Formulaire pour le bouton "Effacer" (intercepté par JS) -->
111
- <form action="/clear" method="POST" id="clear-form">
112
- <button type="submit" title="Effacer la conversation actuelle" class="bg-red-500 hover:bg-red-600 text-white text-xs font-semibold py-1 px-3 rounded-full transition duration-200 focus:outline-none focus:ring-2 focus:ring-red-400 focus:ring-opacity-75">
113
- Effacer
114
- </button>
115
- </form>
116
- </header>
117
-
118
- <!-- Conteneur Principal du Chat -->
119
- <div id="chat-container" class="max-w-4xl w-full mx-auto bg-white shadow-xl rounded-b-lg flex flex-col flex-grow">
120
-
121
- <!-- Zone d'affichage des messages (avec scroll) -->
122
- <div id="chat-messages" class="flex-grow overflow-y-auto p-4 sm:p-6 space-y-4 scroll-smooth">
123
- <!-- Indicateur de chargement de l'historique (sera remplacé) -->
124
- <div id="history-loading">
125
- <div class="flex justify-center items-center space-x-2">
126
- <svg class="animate-spin h-5 w-5 text-blue-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
127
- <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
128
- <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
129
- </svg>
130
- <span>Chargement de l'historique...</span>
131
- </div>
132
- </div>
133
-
134
- <!-- Indicateur de chargement pour les NOUVEAUX messages (sera déplacé ici par JS) -->
135
- <div id="loading-indicator" class="text-center text-gray-500 italic py-4" style="display: none;">
136
- <div class="flex justify-center items-center space-x-2">
137
- <svg class="animate-spin h-5 w-5 text-blue-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
138
- <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
139
- <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
140
- </svg>
141
- <span>Mariam réfléchit...</span>
142
- </div>
143
- </div>
144
  </div>
145
-
146
- <!-- Zone d'erreur (cachée par défaut) -->
147
- <div id="error-message" class="bg-red-100 border-l-4 border-red-500 text-red-700 px-4 py-2 rounded mx-4 my-2 flex-shrink-0" role="alert" style="display: none;">
148
- <p class="font-bold mr-2">Erreur:</p>
149
- <p id="error-text">Le message d'erreur détaillé ira ici.</p>
150
- </div>
151
-
152
- <!-- Barre d'options et d'upload -->
153
- <div class="bg-gray-50 border-t border-gray-200 px-4 py-2 flex-shrink-0">
154
- <div class="flex items-center justify-between text-sm">
155
- <!-- Toggle Recherche Web -->
156
- <label for="web_search_toggle" class="flex items-center space-x-2 cursor-pointer text-gray-600 hover:text-gray-800 select-none" title="Activer/Désactiver la recherche web pour le prochain message">
157
- <input type="checkbox" id="web_search_toggle" name="web_search" value="true" class="form-checkbox h-4 w-4 rounded text-blue-500 focus:ring-blue-400 focus:ring-offset-0 border-gray-300">
158
- <span class="hidden sm:inline">Recherche Web</span>
159
- <span class="sm:hidden">Web</span> <!-- Texte plus court pour mobile -->
160
- </label>
161
- <!-- Upload Fichier -->
162
- <div class="flex items-center space-x-2">
163
- <label for="file_upload" class="cursor-pointer text-blue-500 hover:text-blue-700 font-medium flex items-center" title="Joindre un fichier (txt, pdf, png, jpg)">
164
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
165
- <path stroke-linecap="round" stroke-linejoin="round" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
166
- </svg>
167
- <span class="hidden sm:inline">Fichier</span>
168
- <input type="file" id="file_upload" name="file" class="hidden" accept=".txt,.pdf,.png,.jpg,.jpeg">
169
- </label>
170
- <span id="file-name" class="text-gray-500 text-xs truncate max-w-[100px] sm:max-w-[150px]" title=""></span>
171
- <button id="clear-file" class="text-red-500 hover:text-red-700 text-xs p-0.5 rounded focus:outline-none focus:ring-1 focus:ring-red-400" title="Retirer le fichier" style="display: none;">
172
- <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
173
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
174
- </svg>
175
- </button>
176
- </div>
177
- </div>
178
  </div>
 
 
179
 
180
- <!-- Formulaire d'entrée du message -->
181
- <form id="chat-form" class="bg-gray-100 p-3 sm:p-4 border-t border-gray-200 rounded-b-lg flex-shrink-0">
182
- <div class="flex items-center space-x-2 sm:space-x-3">
183
- <input type="text" id="prompt" name="prompt" class="flex-grow form-input px-4 py-2 border border-gray-300 rounded-full focus:outline-none focus:ring-2 focus:ring-blue-400 shadow-sm text-sm sm:text-base" placeholder="Posez votre question à Mariam..." autocomplete="off">
184
- <button type="submit" id="send-button" title="Envoyer le message" class="bg-blue-500 hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed text-white font-bold p-2 rounded-full transition duration-200 flex items-center justify-center shadow-md w-10 h-10 flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-opacity-75">
185
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
186
- <path d="M10.894 2.553a1 1 0 00-1.788 0l-7 14a1 1 0 001.169 1.409l5-1.429A1 1 0 009 15.571V11a1 1 0 112 0v4.571a1 1 0 00.725.962l5 1.428a1 1 0 001.17-1.408l-7-14z" />
187
- </svg>
188
- </button>
189
- </div>
190
- </form>
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  </div>
193
 
194
- <!-- Script JavaScript pour l'interaction -->
195
- <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  document.addEventListener('DOMContentLoaded', () => {
197
- // === Références aux éléments du DOM ===
198
- const chatForm = document.getElementById('chat-form');
199
- const promptInput = document.getElementById('prompt');
200
- const chatMessages = document.getElementById('chat-messages');
201
- const loadingIndicator = document.getElementById('loading-indicator'); // Indicateur pour NOUVEAUX messages
202
- const historyLoadingIndicator = document.getElementById('history-loading'); // Indicateur pour l'historique
203
- const errorMessageDiv = document.getElementById('error-message');
204
- const errorTextP = document.getElementById('error-text');
205
- const webSearchToggle = document.getElementById('web_search_toggle');
206
- const fileUpload = document.getElementById('file_upload');
207
- const fileNameSpan = document.getElementById('file-name');
208
- const clearFileButton = document.getElementById('clear-file');
209
- const sendButton = document.getElementById('send-button');
210
- const clearForm = document.getElementById('clear-form');
211
-
212
- // === Endpoints de l'API Backend ===
213
- // Assurez-vous que ces URLs correspondent à votre configuration Flask
214
- const API_CHAT_ENDPOINT = '/api/chat';
215
- const API_HISTORY_ENDPOINT = '/api/history';
216
- const CLEAR_ENDPOINT = '/clear';
217
-
218
- // === Fonctions Utilitaires ===
219
-
220
- /** Fait défiler la zone de chat vers le bas */
221
- function scrollToBottom() {
222
- // Utilise un léger délai pour s'assurer que le DOM est mis à jour
223
- setTimeout(() => {
224
- chatMessages.scrollTop = chatMessages.scrollHeight;
225
- }, 50);
 
 
 
 
 
226
  }
227
-
228
- /** Affiche/cache l'indicateur de chargement pour les nouveaux messages */
229
- function showLoading(show) {
230
- const currentlyLoading = loadingIndicator.style.display !== 'none';
231
- if (show && !currentlyLoading) {
232
- loadingIndicator.style.display = 'block';
233
- // S'assurer qu'il est le dernier élément pour être en bas
234
- chatMessages.appendChild(loadingIndicator);
235
- scrollToBottom();
236
- } else if (!show && currentlyLoading) {
237
- loadingIndicator.style.display = 'none';
238
- }
239
- // Désactiver/réactiver les contrôles pendant le chargement
240
- sendButton.disabled = show;
241
- promptInput.disabled = show;
242
- fileUpload.disabled = show;
243
- clearFileButton.disabled = show; // Désactiver aussi la suppression de fichier
244
- }
245
-
246
- /** Affiche un message d'erreur dans la zone dédiée */
247
- function displayError(message) {
248
- errorTextP.textContent = message || "Une erreur inconnue est survenue.";
249
- errorMessageDiv.style.display = 'flex'; // Utiliser flex pour aligner l'icône si on en ajoute une
250
- // Faire défiler pour voir l'erreur si elle est hors écran
251
- errorMessageDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
252
- // Optionnel: Cacher l'erreur après un délai (ex: 8 secondes)
253
- // setTimeout(() => { errorMessageDiv.style.display = 'none'; }, 8000);
 
 
 
 
 
 
 
 
 
254
  }
255
 
256
- /** Ajoute un message (utilisateur ou assistant) à la zone de chat */
257
- function addMessageToChat(role, text, isHtml = false) {
258
- // Cacher l'erreur si elle était affichée lors de l'ajout d'un nouveau message
259
- errorMessageDiv.style.display = 'none';
260
-
261
- const messageWrapper = document.createElement('div');
262
- messageWrapper.classList.add('flex', role === 'user' ? 'justify-end' : 'justify-start', 'mb-4');
263
-
264
- const bubbleDiv = document.createElement('div');
265
- bubbleDiv.classList.add('p-3', 'rounded-lg', 'max-w-[85%]', 'sm:max-w-[75%]', 'shadow-md', 'relative'); // Limite la largeur
266
-
267
- if (role === 'user') {
268
- bubbleDiv.classList.add('bg-blue-500', 'text-white', 'rounded-br-none');
269
- const paragraph = document.createElement('p');
270
- paragraph.classList.add('text-sm', 'sm:text-base', 'break-words'); // Permet le retour à la ligne
271
- paragraph.textContent = text; // Sécurité: toujours textContent pour l'input utilisateur
272
- bubbleDiv.appendChild(paragraph);
273
- } else { // Assistant
274
- bubbleDiv.classList.add('bg-gray-100', 'text-gray-800', 'rounded-bl-none', 'border', 'border-gray-200');
275
- const proseDiv = document.createElement('div');
276
- // Appliquer les classes Prose pour le rendu Markdown/HTML
277
- proseDiv.classList.add('prose', 'prose-sm', 'sm:prose-base', 'max-w-none', 'text-gray-800',
278
- 'prose-headings:font-semibold', 'prose-headings:text-gray-800',
279
- 'prose-a:text-blue-600', 'prose-a:no-underline', 'hover:prose-a:underline',
280
- 'prose-strong:text-gray-800', 'prose-code:text-red-600', 'prose-code:font-mono',
281
- 'prose-blockquote:text-gray-600', 'break-words');
282
- if (isHtml) {
283
- // ATTENTION : NECESSITE QUE LE HTML DU BACKEND SOIT NETTOYÉ/SÉCURISÉ
284
- proseDiv.innerHTML = text;
285
- } else {
286
- proseDiv.textContent = text;
287
- }
288
- bubbleDiv.appendChild(proseDiv);
289
- }
290
 
291
- messageWrapper.appendChild(bubbleDiv);
292
-
293
- // Insérer le nouveau message AVANT l'indicateur de chargement pour qu'il reste en bas
294
- chatMessages.insertBefore(messageWrapper, loadingIndicator);
295
-
296
- // Faire défiler seulement si on n'est pas en train de charger l'historique initial
297
- if (historyLoadingIndicator.parentNode !== chatMessages) {
298
- scrollToBottom();
299
- }
300
  }
301
-
302
- /** Charge l'historique de chat depuis le backend */
303
- async function loadChatHistory() {
304
- console.log("Tentative de chargement de l'historique...");
305
- // Garder l'indicateur visible pendant le chargement
306
- historyLoadingIndicator.style.display = 'block';
307
-
 
308
  try {
309
- const response = await fetch(API_HISTORY_ENDPOINT);
310
- if (!response.ok) {
311
- let errorMsg = `Erreur serveur (${response.status})`;
312
- try { // Tenter de lire un message d'erreur JSON du backend
313
- const errData = await response.json();
314
- errorMsg = errData.error || errorMsg;
315
- } catch (e) { /* Ignorer si pas JSON */ }
316
- throw new Error(errorMsg);
317
- }
318
- const data = await response.json();
319
-
320
- if (data.success && Array.isArray(data.history)) {
321
- console.log(`Historique reçu: ${data.history.length} message(s).`);
322
- // Vider les messages actuels (au cas où, et supprime l'indicateur de chargement d'historique)
323
- chatMessages.innerHTML = '';
324
- // Remettre l'indicateur de chargement de NOUVEAU message (caché)
325
- chatMessages.appendChild(loadingIndicator);
326
- loadingIndicator.style.display = 'none'; // S'assurer qu'il est caché
327
-
328
- if (data.history.length === 0) {
329
- addMessageToChat('assistant', "Bonjour ! Comment puis-je vous aider aujourd'hui ?");
330
- } else {
331
- data.history.forEach(message => {
332
- const isAssistantHtml = message.role === 'assistant';
333
- addMessageToChat(message.role, message.text, isAssistantHtml);
334
- });
335
- }
336
- // Faire défiler vers le bas après avoir ajouté tous les messages
337
- scrollToBottom();
338
-
339
- } else {
340
- throw new Error(data.error || "Format de réponse de l'historique invalide.");
341
- }
342
- } catch (error) {
343
- console.error("Erreur lors du chargement de l'historique:", error);
344
- // Afficher l'erreur dans la zone de chat à la place de l'indicateur
345
- chatMessages.innerHTML = ''; // Vider
346
- chatMessages.appendChild(loadingIndicator); // Remettre l'indicateur caché
347
- loadingIndicator.style.display = 'none';
348
- displayError(`Impossible de charger l'historique: ${error.message}`);
349
- } finally {
350
- // Cacher l'indicateur de chargement d'historique s'il est toujours là (en cas d'erreur avant de le vider)
351
- if (historyLoadingIndicator.parentNode === chatMessages) {
352
- historyLoadingIndicator.remove();
353
- }
354
- // Mettre le focus sur l'input à la fin
355
- promptInput.focus();
356
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  }
358
 
359
- /** Réinitialise l'input fichier */
360
- function clearFileInput() {
361
- fileUpload.value = ''; // Réinitialise la sélection
362
- fileNameSpan.textContent = '';
363
- fileNameSpan.title = '';
364
- clearFileButton.style.display = 'none'; // Cache le bouton 'X'
365
  }
 
366
 
367
- // === Gestionnaires d'événements ===
 
 
 
 
 
368
 
369
- // Changement sur l'input fichier
370
- fileUpload.addEventListener('change', () => {
371
- if (fileUpload.files.length > 0) {
372
- const file = fileUpload.files[0];
373
- const name = file.name;
374
- // Tronquer le nom si trop long pour l'affichage
375
- fileNameSpan.textContent = name.length > 20 ? name.substring(0, 17) + '...' : name;
376
- fileNameSpan.title = name; // Titre complet au survol
377
- clearFileButton.style.display = 'inline-block'; // Montre le bouton 'X'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  } else {
379
- clearFileInput(); // Appeler la fonction de nettoyage
380
- }
381
- });
382
-
383
- // Clic sur le bouton 'X' pour retirer le fichier
384
- clearFileButton.addEventListener('click', () => {
385
- clearFileInput();
386
- });
387
-
388
- // Soumission du formulaire de chat
389
- chatForm.addEventListener('submit', async (e) => {
390
- e.preventDefault(); // Empêche le rechargement de page
391
-
392
- const prompt = promptInput.value.trim();
393
- const file = fileUpload.files[0]; // Récupère le fichier s'il y en a un
394
- const useWebSearch = webSearchToggle.checked;
395
-
396
- // Vérifier si un prompt ou un fichier est présent
397
- if (!prompt && !file) {
398
- displayError("Veuillez entrer un message ou sélectionner un fichier.");
399
- promptInput.focus();
400
- return;
401
  }
 
 
 
 
 
 
 
 
 
402
 
403
- errorMessageDiv.style.display = 'none'; // Cacher les erreurs précédentes
404
-
405
- // Afficher le message utilisateur immédiatement
406
- let userMessageText = prompt;
407
- if (file) {
408
- // Préciser le fichier dans le message affiché si les deux sont présents
409
- userMessageText = prompt ? `[${file.name}] ${prompt}` : `[${file.name}]`;
410
- }
411
- addMessageToChat('user', userMessageText);
412
-
413
- // Préparer les données pour l'envoi
414
- const formData = new FormData();
415
- formData.append('prompt', prompt); // Envoyer même si vide si un fichier est présent
416
- formData.append('web_search', useWebSearch); // Envoyer 'true' ou 'false'
417
- if (file) {
418
- formData.append('file', file);
419
- }
420
-
421
- // Afficher le chargement et vider les champs
422
- showLoading(true);
423
- promptInput.value = '';
424
- clearFileInput(); // Nettoyer l'input fichier après envoi
425
-
426
- try {
427
- // Envoyer les données au backend
428
- const response = await fetch(API_CHAT_ENDPOINT, {
429
- method: 'POST',
430
- body: formData,
431
- // Pas besoin de 'Content-Type', FormData le gère
432
- });
433
-
434
- const data = await response.json(); // Tenter de lire la réponse JSON
435
-
436
- if (!response.ok) {
437
- // Utiliser le message d'erreur du JSON si dispo, sinon statut HTTP
438
- throw new Error(data.error || `Erreur serveur: ${response.status}`);
439
- }
440
-
441
- if (data.success && data.message) {
442
- // Ajouter la réponse de l'assistant (en supposant qu'elle est en HTML sûr)
443
- addMessageToChat('assistant', data.message, true);
444
- } else {
445
- // Gérer le cas où success=true mais pas de message, ou success=false
446
- throw new Error(data.error || "Réponse invalide ou vide du serveur.");
447
- }
448
-
449
- } catch (error) {
450
- console.error("Erreur lors de l'envoi du message:", error);
451
- displayError(error.message);
452
- // Optionnel : Supprimer le message utilisateur qui a causé l'erreur ? (Peut être déroutant)
453
- } finally {
454
- // Arrêter l'indicateur de chargement et réactiver les contrôles
455
- showLoading(false);
456
- promptInput.focus(); // Remettre le focus sur l'input
457
- }
458
- });
459
-
460
- // Soumission du formulaire pour effacer le chat
461
- clearForm.addEventListener('submit', async (e) => {
462
- e.preventDefault(); // Empêche la soumission classique
463
-
464
- if (confirm("Êtes-vous sûr de vouloir effacer toute la conversation ?")) {
465
- console.log("Demande d'effacement du chat...");
466
- // Ajouter un indicateur visuel temporaire si souhaité
467
- const originalButtonText = e.target.querySelector('button').textContent;
468
- e.target.querySelector('button').textContent = '...';
469
- e.target.querySelector('button').disabled = true;
470
-
471
- try {
472
- const response = await fetch(CLEAR_ENDPOINT, { method: 'POST' });
473
- const data = await response.json(); // Lire la réponse JSON
474
-
475
- if (response.ok && data.success) {
476
- console.log("Chat effacé avec succès.");
477
- // Effacer les messages affichés dans le DOM
478
- chatMessages.innerHTML = ''; // Vide complètement
479
- // Remettre l'indicateur de chargement de NOUVEAU message (caché)
480
- chatMessages.appendChild(loadingIndicator);
481
- loadingIndicator.style.display = 'none';
482
- // Ajouter le message d'accueil initial
483
- addMessageToChat('assistant', "Conversation effacée. Comment puis-je vous aider ?");
484
- errorMessageDiv.style.display = 'none'; // Cacher toute erreur précédente
485
- } else {
486
- throw new Error(data.error || "Impossible d'effacer côté serveur.");
487
- }
488
- } catch (error) {
489
- console.error("Erreur lors de l'effacement:", error);
490
- displayError(`Erreur lors de l'effacement du chat: ${error.message}`);
491
- } finally {
492
- // Restaurer le bouton
493
- e.target.querySelector('button').textContent = originalButtonText;
494
- e.target.querySelector('button').disabled = false;
495
- promptInput.focus(); // Remettre le focus
496
- }
497
- }
498
- });
499
-
500
- // === Initialisation au chargement de la page ===
501
- loadChatHistory(); // Charger l'historique dès que le DOM est prêt
502
-
503
  });
504
- </script>
505
-
506
  </body>
507
- </html>
 
1
  <!DOCTYPE html>
2
  <html lang="fr">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Mariam AI!</title>
7
+
8
+ <!-- Tailwind CSS via CDN (inclut le plugin Forms) -->
9
+ <script src="https://cdn.tailwindcss.com?plugins=forms"></script>
10
+
11
+ <!-- Favicon (Emoji simple) -->
12
+ <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🤖</text></svg>">
13
+
14
+ <style>
15
+ /* Assurer la hauteur minimale et permettre le scroll de la page sur mobile */
16
+ html, body {
17
+ min-height: 100vh;
18
+ margin: 0;
19
+ padding: 0;
20
+ }
21
+ body {
22
+ display: flex;
23
+ flex-direction: column;
24
+ font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
25
+ }
26
+ #chat-container {
27
+ display: flex;
28
+ flex-direction: column;
29
+ flex-grow: 1;
30
+ min-height: 0;
31
+ }
32
+ #chat-messages {
33
+ flex-grow: 1;
34
+ overflow-y: auto;
35
+ min-height: 0;
36
+ }
37
+ /* Styles de la scrollbar */
38
+ ::-webkit-scrollbar {
39
+ width: 8px;
40
+ }
41
+ ::-webkit-scrollbar-track {
42
+ background: #f1f1f1;
43
+ border-radius: 10px;
44
+ }
45
+ ::-webkit-scrollbar-thumb {
46
+ background: #a8a8a8;
47
+ border-radius: 10px;
48
+ }
49
+ ::-webkit-scrollbar-thumb:hover {
50
+ background: #7a7a7a;
51
+ }
52
+ /* Styles pour le rendu Markdown dans le chat */
53
+ #chat-messages .prose code:not(pre code) {
54
+ background-color: #e5e7eb;
55
+ padding: 0.2em 0.4em;
56
+ font-size: 85%;
57
+ border-radius: 4px;
58
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
59
+ }
60
+ #chat-messages .prose pre {
61
+ background-color: #f3f4f6;
62
+ padding: 0.8em 1em;
63
+ border-radius: 6px;
64
+ overflow-x: auto;
65
+ font-size: 0.875rem;
66
+ }
67
+ #chat-messages .prose pre code {
68
+ background-color: transparent;
69
+ padding: 0;
70
+ font-size: inherit;
71
+ border-radius: 0;
72
+ color: inherit;
73
+ }
74
+ #chat-messages .prose blockquote {
75
+ border-left-color: #9ca3af;
76
+ color: #4b5563;
77
+ }
78
+ #chat-messages .prose strong {
79
+ color: #1f2937;
80
+ }
81
+ #chat-messages .prose a {
82
+ color: #2563eb;
83
+ text-decoration: underline;
84
+ text-decoration-color: #93c5fd;
85
+ transition: color 0.2s ease;
86
+ }
87
+ #chat-messages .prose a:hover {
88
+ color: #1d4ed8;
89
+ text-decoration-color: #60a5fa;
90
+ }
91
+ /* Chargement initial de l'historique */
92
+ #history-loading {
93
+ padding: 20px;
94
+ text-align: center;
95
+ color: #6b7280;
96
+ font-style: italic;
97
+ }
98
+ </style>
 
 
 
 
 
99
  </head>
100
+ <body class="bg-gray-100 flex flex-col min-h-screen">
101
+ <!-- En-tête fixe -->
102
+ <header class="bg-gradient-to-r from-cyan-500 to-blue-500 text-white p-3 sm:p-4 shadow-md flex justify-between items-center sticky top-0 z-10 flex-shrink-0">
103
+ <h1 class="text-xl sm:text-2xl font-bold">Mariam AI!</h1>
104
+ <form action="/clear" method="POST" id="clear-form">
105
+ <button type="submit" title="Effacer la conversation actuelle" class="bg-red-500 hover:bg-red-600 text-white text-xs font-semibold py-1 px-3 rounded-full transition duration-200 focus:outline-none focus:ring-2 focus:ring-red-400 focus:ring-opacity-75">
106
+ Effacer
107
+ </button>
108
+ </form>
109
+ </header>
110
+
111
+ <!-- Conteneur Principal du Chat -->
112
+ <div id="chat-container" class="max-w-4xl w-full mx-auto bg-white shadow-xl rounded-b-lg flex flex-col flex-grow">
113
+ <!-- Zone d'affichage des messages -->
114
+ <div id="chat-messages" class="flex-grow overflow-y-auto p-4 sm:p-6 space-y-4 scroll-smooth">
115
+ <div id="history-loading">
116
+ <div class="flex justify-center items-center space-x-2">
117
+ <svg class="animate-spin h-5 w-5 text-blue-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
118
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
119
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
120
+ </svg>
121
+ <span>Chargement de l'historique...</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  </div>
123
+ </div>
124
+ <div id="loading-indicator" class="text-center text-gray-500 italic py-4" style="display: none;">
125
+ <div class="flex justify-center items-center space-x-2">
126
+ <svg class="animate-spin h-5 w-5 text-blue-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
127
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
128
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
129
+ </svg>
130
+ <span>Mariam réfléchit...</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  </div>
132
+ </div>
133
+ </div>
134
 
135
+ <!-- Zone d'erreur -->
136
+ <div id="error-message" class="bg-red-100 border-l-4 border-red-500 text-red-700 px-4 py-2 rounded mx-4 my-2 flex-shrink-0" role="alert" style="display: none;">
137
+ <p class="font-bold mr-2">Erreur:</p>
138
+ <p id="error-text">Le message d'erreur détaillé ira ici.</p>
139
+ </div>
 
 
 
 
 
 
140
 
141
+ <!-- Barre d'options et d'upload -->
142
+ <div class="bg-gray-50 border-t border-gray-200 px-4 py-2 flex-shrink-0">
143
+ <div class="flex items-center justify-between text-sm">
144
+ <label for="web_search_toggle" class="flex items-center space-x-2 cursor-pointer text-gray-600 hover:text-gray-800 select-none" title="Activer/Désactiver la recherche web pour le prochain message">
145
+ <input type="checkbox" id="web_search_toggle" name="web_search" value="true" class="form-checkbox h-4 w-4 rounded text-blue-500 focus:ring-blue-400 focus:ring-offset-0 border-gray-300">
146
+ <span class="hidden sm:inline">Recherche Web</span>
147
+ <span class="sm:hidden">Web</span>
148
+ </label>
149
+ <div class="flex items-center space-x-2">
150
+ <label for="file_upload" class="cursor-pointer text-blue-500 hover:text-blue-700 font-medium flex items-center" title="Joindre un fichier (txt, pdf, png, jpg)">
151
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
152
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
153
+ </svg>
154
+ <span class="hidden sm:inline">Fichier</span>
155
+ <input type="file" id="file_upload" name="file" class="hidden" accept=".txt,.pdf,.png,.jpg,.jpeg">
156
+ </label>
157
+ <span id="file-name" class="text-gray-500 text-xs truncate max-w-[150px]" title=""></span>
158
+ <button id="clear-file" class="text-red-500 hover:text-red-700 text-xs p-0.5 rounded focus:outline-none focus:ring-1 focus:ring-red-400" title="Retirer le fichier" style="display: none;">
159
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
160
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
161
+ </svg>
162
+ </button>
163
+ </div>
164
+ </div>
165
  </div>
166
 
167
+ <!-- Formulaire d'entrée du message -->
168
+ <form id="chat-form" class="bg-gray-100 p-3 sm:p-4 border-t border-gray-200 rounded-b-lg flex-shrink-0">
169
+ <div class="flex items-center space-x-2 sm:space-x-3">
170
+ <input type="text" id="prompt" name="prompt" class="flex-grow form-input px-4 py-2 border border-gray-300 rounded-full focus:outline-none focus:ring-2 focus:ring-blue-400 shadow-sm text-sm sm:text-base" placeholder="Posez votre question à Mariam..." autocomplete="off">
171
+ <button type="submit" id="send-button" title="Envoyer le message" class="bg-blue-500 hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed text-white font-bold p-2 rounded-full transition duration-200 flex items-center justify-center shadow-md w-10 h-10 flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-opacity-75">
172
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
173
+ <path d="M10.894 2.553a1 1 0 00-1.788 0l-7 14a1 1 0 001.169 1.409l5-1.429A1 1 0 009 15.571V11a1 1 0 112 0v4.571a1 1 0 00.725.962l5 1.428a1 1 0 001.17-1.408l-7-14z" />
174
+ </svg>
175
+ </button>
176
+ </div>
177
+ </form>
178
+ </div>
179
+
180
+ <!-- Script JavaScript pour l'interaction -->
181
+ <script>
182
  document.addEventListener('DOMContentLoaded', () => {
183
+ // Références aux éléments du DOM
184
+ const chatForm = document.getElementById('chat-form');
185
+ const promptInput = document.getElementById('prompt');
186
+ const chatMessages = document.getElementById('chat-messages');
187
+ const loadingIndicator = document.getElementById('loading-indicator');
188
+ const historyLoadingIndicator = document.getElementById('history-loading');
189
+ const errorMessageDiv = document.getElementById('error-message');
190
+ const errorTextP = document.getElementById('error-text');
191
+ const webSearchToggle = document.getElementById('web_search_toggle');
192
+ const fileUpload = document.getElementById('file_upload');
193
+ const fileNameSpan = document.getElementById('file-name');
194
+ const clearFileButton = document.getElementById('clear-file');
195
+ const sendButton = document.getElementById('send-button');
196
+ const clearForm = document.getElementById('clear-form');
197
+
198
+ // Endpoints de l'API Backend
199
+ const API_CHAT_ENDPOINT = '/api/chat';
200
+ const API_HISTORY_ENDPOINT = '/api/history';
201
+ const CLEAR_ENDPOINT = '/clear';
202
+
203
+ function scrollToBottom() {
204
+ setTimeout(() => {
205
+ chatMessages.scrollTop = chatMessages.scrollHeight;
206
+ }, 50);
207
+ }
208
+
209
+ function showLoading(show) {
210
+ const currentlyLoading = loadingIndicator.style.display !== 'none';
211
+ if (show && !currentlyLoading) {
212
+ loadingIndicator.style.display = 'block';
213
+ chatMessages.appendChild(loadingIndicator);
214
+ scrollToBottom();
215
+ } else if (!show && currentlyLoading) {
216
+ loadingIndicator.style.display = 'none';
217
  }
218
+ sendButton.disabled = show;
219
+ promptInput.disabled = show;
220
+ fileUpload.disabled = show;
221
+ clearFileButton.disabled = show;
222
+ }
223
+
224
+ function displayError(message) {
225
+ errorTextP.textContent = message || "Une erreur inconnue est survenue.";
226
+ errorMessageDiv.style.display = 'flex';
227
+ errorMessageDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
228
+ }
229
+
230
+ function addMessageToChat(role, text, isHtml = false) {
231
+ errorMessageDiv.style.display = 'none';
232
+ const messageWrapper = document.createElement('div');
233
+ messageWrapper.classList.add('flex', role === 'user' ? 'justify-end' : 'justify-start', 'mb-4');
234
+
235
+ const bubbleDiv = document.createElement('div');
236
+ bubbleDiv.classList.add('p-3', 'rounded-lg', 'max-w-[85%]', 'sm:max-w-[75%]', 'shadow-md', 'relative');
237
+
238
+ if (role === 'user') {
239
+ bubbleDiv.classList.add('bg-blue-500', 'text-white', 'rounded-br-none');
240
+ const paragraph = document.createElement('p');
241
+ paragraph.classList.add('text-sm', 'sm:text-base', 'break-words');
242
+ paragraph.textContent = text;
243
+ bubbleDiv.appendChild(paragraph);
244
+ } else {
245
+ bubbleDiv.classList.add('bg-gray-100', 'text-gray-800', 'rounded-bl-none', 'border', 'border-gray-200');
246
+ const proseDiv = document.createElement('div');
247
+ proseDiv.classList.add('prose', 'prose-sm', 'sm:prose-base', 'max-w-none', 'text-gray-800', 'prose-headings:font-semibold', 'prose-headings:text-gray-800', 'prose-a:text-blue-600', 'prose-a:no-underline', 'hover:prose-a:underline', 'prose-strong:text-gray-800', 'prose-code:text-red-600', 'prose-code:font-mono', 'prose-blockquote:text-gray-600', 'break-words');
248
+ if (isHtml) {
249
+ proseDiv.innerHTML = text;
250
+ } else {
251
+ proseDiv.textContent = text;
252
+ }
253
+ bubbleDiv.appendChild(proseDiv);
254
  }
255
 
256
+ messageWrapper.appendChild(bubbleDiv);
257
+ chatMessages.insertBefore(messageWrapper, loadingIndicator);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
+ if (historyLoadingIndicator.parentNode !== chatMessages) {
260
+ scrollToBottom();
 
 
 
 
 
 
 
261
  }
262
+ }
263
+
264
+ async function loadChatHistory() {
265
+ historyLoadingIndicator.style.display = 'block';
266
+ try {
267
+ const response = await fetch(API_HISTORY_ENDPOINT);
268
+ if (!response.ok) {
269
+ let errorMsg = `Erreur serveur (${response.status})`;
270
  try {
271
+ const errData = await response.json();
272
+ errorMsg = errData.error || errorMsg;
273
+ } catch (e) { }
274
+ throw new Error(errorMsg);
275
+ }
276
+ const data = await response.json();
277
+ if (data.success && Array.isArray(data.history)) {
278
+ chatMessages.innerHTML = '';
279
+ chatMessages.appendChild(loadingIndicator);
280
+ loadingIndicator.style.display = 'none';
281
+ if (data.history.length === 0) {
282
+ addMessageToChat('assistant', "Bonjour ! Comment puis-je vous aider aujourd'hui ?");
283
+ } else {
284
+ data.history.forEach(message => {
285
+ const isAssistantHtml = message.role === 'assistant';
286
+ addMessageToChat(message.role, message.text, isAssistantHtml);
287
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  }
289
+ scrollToBottom();
290
+ } else {
291
+ throw new Error(data.error || "Format de réponse de l'historique invalide.");
292
+ }
293
+ } catch (error) {
294
+ chatMessages.innerHTML = '';
295
+ chatMessages.appendChild(loadingIndicator);
296
+ loadingIndicator.style.display = 'none';
297
+ displayError(`Impossible de charger l'historique: ${error.message}`);
298
+ } finally {
299
+ if (historyLoadingIndicator.parentNode === chatMessages) {
300
+ historyLoadingIndicator.remove();
301
+ }
302
+ promptInput.focus();
303
+ }
304
+ }
305
+
306
+ function clearFileInput() {
307
+ fileUpload.value = '';
308
+ fileNameSpan.textContent = '';
309
+ fileNameSpan.title = '';
310
+ clearFileButton.style.display = 'none';
311
+ }
312
+
313
+ fileUpload.addEventListener('change', () => {
314
+ if (fileUpload.files.length > 0) {
315
+ const file = fileUpload.files[0];
316
+ const name = file.name;
317
+ fileNameSpan.textContent = name.length > 20 ? name.substring(0, 17) + '...' : name;
318
+ fileNameSpan.title = name;
319
+ clearFileButton.style.display = 'inline-block';
320
+ } else {
321
+ clearFileInput();
322
+ }
323
+ });
324
+
325
+ clearFileButton.addEventListener('click', () => {
326
+ clearFileInput();
327
+ });
328
+
329
+ chatForm.addEventListener('submit', async (e) => {
330
+ e.preventDefault();
331
+ const prompt = promptInput.value.trim();
332
+ const file = fileUpload.files[0];
333
+ const useWebSearch = webSearchToggle.checked;
334
+
335
+ if (!prompt && !file) {
336
+ displayError("Veuillez entrer un message ou sélectionner un fichier.");
337
+ promptInput.focus();
338
+ return;
339
  }
340
 
341
+ errorMessageDiv.style.display = 'none';
342
+ let userMessageText = prompt;
343
+ if (file) {
344
+ userMessageText = prompt ? `[${file.name}] ${prompt}` : `[${file.name}]`;
 
 
345
  }
346
+ addMessageToChat('user', userMessageText);
347
 
348
+ const formData = new FormData();
349
+ formData.append('prompt', prompt);
350
+ formData.append('web_search', useWebSearch);
351
+ if (file) {
352
+ formData.append('file', file);
353
+ }
354
 
355
+ showLoading(true);
356
+ promptInput.value = '';
357
+ clearFileInput();
358
+
359
+ try {
360
+ const response = await fetch(API_CHAT_ENDPOINT, {
361
+ method: 'POST',
362
+ body: formData,
363
+ });
364
+ const data = await response.json();
365
+ if (!response.ok) {
366
+ throw new Error(data.error || `Erreur serveur: ${response.status}`);
367
+ }
368
+ if (data.success && data.message) {
369
+ addMessageToChat('assistant', data.message, true);
370
+ } else {
371
+ throw new Error(data.error || "Réponse invalide ou vide du serveur.");
372
+ }
373
+ } catch (error) {
374
+ displayError(error.message);
375
+ } finally {
376
+ showLoading(false);
377
+ promptInput.focus();
378
+ }
379
+ });
380
+
381
+ clearForm.addEventListener('submit', async (e) => {
382
+ e.preventDefault();
383
+ if (confirm("Êtes-vous sûr de vouloir effacer toute la conversation ?")) {
384
+ const originalButtonText = e.target.querySelector('button').textContent;
385
+ e.target.querySelector('button').textContent = '...';
386
+ e.target.querySelector('button').disabled = true;
387
+ try {
388
+ const response = await fetch(CLEAR_ENDPOINT, { method: 'POST' });
389
+ const data = await response.json();
390
+ if (response.ok && data.success) {
391
+ chatMessages.innerHTML = '';
392
+ chatMessages.appendChild(loadingIndicator);
393
+ loadingIndicator.style.display = 'none';
394
+ addMessageToChat('assistant', "Conversation effacée. Comment puis-je vous aider ?");
395
+ errorMessageDiv.style.display = 'none';
396
  } else {
397
+ throw new Error(data.error || "Impossible d'effacer côté serveur.");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  }
399
+ } catch (error) {
400
+ displayError(`Erreur lors de l'effacement du chat: ${error.message}`);
401
+ } finally {
402
+ e.target.querySelector('button').textContent = originalButtonText;
403
+ e.target.querySelector('button').disabled = false;
404
+ promptInput.focus();
405
+ }
406
+ }
407
+ });
408
 
409
+ loadChatHistory();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  });
411
+ </script>
 
412
  </body>
413
+ </html>