Spaces:
Running
Running
Update index.html
Browse files11234125 unmodified lines1301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621633 unmodified lines16716816914217017114414514617217317417517617717817918018118215015115218318418518612 unmodified lines1992002012022032042052062072082091 unmodified line2112122132142152161792172181821831841852192202211871881891902222232242252262272281921931942292302312322332342352362372382391971982402412422432442452462472482492502512522532542552562572582592602612032042622632642651 unmodified line26726826921221327027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430522630630730830912 unmodified lines32232332424532532632732854 unmodified lines383384385306307308309386387388389390391392393394395396397398399400401402403404405311406<html><head><base href="https://WhatsApp/ai.com"><!DOCTYPE html><html><head><base href="https://WhatsApp/ai.com"><meta charset="UTF-8"><title>AI-Powered WhatsApp Chat with Image Upload</title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">125 unmodified lines max-width: 600px; } } /* New styles for appointments and history */ .appointment-card { background: #fff; border-radius: 10px; padding: 15px; margin: 10px 0; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .history-button { display: none; /* Hide the history button */ } .history-panel { position: fixed; right: -300px; /* Keep it offscreen by default */ top: 0; width: 300px; height: 100%; background: white; box-shadow: -2px 0 5px rgba(0,0,0,0.2); transition: right 0.3s ease; z-index: 1000; padding: 20px; display: none; /* Hide it completely */ } .history-panel.active { right: 0; display: block; /* Show only when active */ } /* Ajout de styles pour le support des emojis */ .emoji { font-family: "Segoe UI Emoji", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Symbol", sans-serif;3 unmodified lines<body><div id="chat-container"> <div id="chat-header"> <img src="https://cdn-icons-png.flaticon.com/512/4712/4712109.png" alt="Clipart of a customer assistant with headset"> <img src="https://cdn-icons-png.flaticon.com/512/4712/4712109.png" alt="Logo zone - corporate stylized icon with square background" style="width: 40px; height: 40px; object-fit: cover; border-radius: 5px;"> <h1> AI Assistant <span style="display: inline-block; margin-left: 5px; background-color: #0099ff; color: white; font-size: 0.6em; padding: 2px 5px; border-radius: 50%; vertical-align: middle;" title="Assistant IA Vérifié">✓</span> </h1> ASSISTANT AI +226 56888879 <span style="display: inline-block; margin-left: 5px; background-color: #0099ff; color: white; font-size: 0.6em; padding: 2px 5px; border-radius: 50%; vertical-align: middle; transform: translateY(-0.5mm);" title="Assistant IA Vérifié">✓</span></h1> <button class="history-button" id="history-button"> <svg width="24" height="24" viewBox="0 0 24 24" fill="white"> <path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.25 2.52.77-1.28-3.52-2.09V8z"></path> </svg> </button> </div> <div id="chat-messages"> <div class="typing-indicator" id="typing-indicator"> <span></span> <span></span> <span></span> <span></span><span></span><span></span> </div> </div> <div id="chat-input">12 unmodified lines </div></div>
<div class="history-panel" id="history-panel"> <h2>Historique des conversations</h2> <div id="conversation-history"></div></div>
<script>const chatMessages = document.getElementById('chat-messages');const userInput = document.getElementById('user-input');1 unmodified lineconst fileButton = document.getElementById('file-button');const fileInput = document.getElementById('file-input');const typingIndicator = document.getElementById('typing-indicator');const historyButton = document.getElementById('history-button');const historyPanel = document.getElementById('history-panel');
// URL du backend Pythonconst BACKEND_URL = 'http://your-backend-url/api';
// Fonction pour encoder correctement les caractères spéciauxfunction encodeMessage(message) { return encodeURIComponent(message);}// Store conversation historylet conversationHistory = [];
// Fonction pour décoder les caractères spéciauxfunction decodeMessage(message) { return decodeURIComponent(message);}// Welcome messagesconst welcomeMessages = [ "Bonjour! 👋 Je suis votre assistant virtuel. Comment puis-je vous aider aujourd'hui?", "Je peux vous aider à prendre des rendez-vous, répondre à vos questions, et plus encore!", "N'hésitez pas à partager des images ou à me poser des questions."];
function showTypingIndicator() { typingIndicator.style.display = 'block'; chatMessages.scrollTop = chatMessages.scrollHeight;function saveToHistory(message, isUser) { const timestamp = new Date().toISOString(); conversationHistory.push({ message, isUser, timestamp }); localStorage.setItem('chatHistory', JSON.stringify(conversationHistory)); updateHistoryPanel();}
function hideTypingIndicator() { typingIndicator.style.display = 'none';function updateHistoryPanel() { const historyContainer = document.getElementById('conversation-history'); historyContainer.innerHTML = ''; conversationHistory.forEach(item => { const messageDiv = document.createElement('div'); messageDiv.classList.add('history-message'); const date = new Date(item.timestamp).toLocaleString(); messageDiv.innerHTML = ` <small>${date}</small><br> <strong>${item.isUser ? 'Vous' : 'Assistant'}</strong>: ${item.message} `; historyContainer.appendChild(messageDiv); });}
historyButton.addEventListener('click', () => { historyPanel.classList.toggle('active');});
function addMessage(content, isUser, imageData = null) { const messageDiv = document.createElement('div'); messageDiv.classList.add('message'); messageDiv.classList.add(isUser ? 'user-message' : 'ai-message'); messageDiv.classList.add('message', isUser ? 'user-message' : 'ai-message');
if (imageData) { const img = document.createElement('img');1 unmodified line img.alt = 'Image envoyée'; messageDiv.appendChild(img); } else { // Décode le contenu pour afficher correctement les caractères spéciaux messageDiv.textContent = decodeMessage(content); messageDiv.textContent = content; }
chatMessages.appendChild(messageDiv); chatMessages.scrollTop = chatMessages.scrollHeight; // Save to history saveToHistory(imageData ? '[Image]' : content, isUser);}
// Load history from localStoragefunction loadHistory() { const savedHistory = localStorage.getItem('chatHistory'); if (savedHistory) { conversationHistory = JSON.parse(savedHistory); updateHistoryPanel(); }}
// Initializewindow.onload = () => { loadHistory(); // Display welcome messages with delay welcomeMessages.forEach((message, index) => { setTimeout(() => { addMessage(message, false); }, index * 1000); });};
async function sendMessageToBackend(message, imageData = null) { try { showTypingIndicator();
const formData = new FormData(); // Encode le message avant l'envoi formData.append('message', encodeMessage(message)); formData.append('message', encodeURIComponent(message)); if (imageData) { formData.append('image', imageData); }12 unmodified lines if (data.response) { // Décode la réponse du serveur addMessage(decodeMessage(data.response), false); addMessage(decodeURIComponent(data.response), false); } } catch (error) { console.error('Erreur:', error);54 unmodified lines }});
// Initialisationwindow.onload = () => { addMessage("Bonjour ! 👋 Je suis votre assistant virtuel. Comment puis-je vous aider aujourd'hui ?", false);};// Fonction pour encoder correctement les caractères spéciauxfunction encodeMessage(message) { return encodeURIComponent(message);}
// Fonction pour décoder les caractères spéciauxfunction decodeMessage(message) { return decodeURIComponent(message);}
function showTypingIndicator() { typingIndicator.style.display = 'block'; chatMessages.scrollTop = chatMessages.scrollHeight;}
function hideTypingIndicator() { typingIndicator.style.display = 'none';}
</script></body></html></body></html>index.html+128-33