Abmacode12 commited on
Commit
cb74981
·
verified ·
1 Parent(s): 48693cf

il dit micro non implanté peux tu l'implanter pour qu'il fonctionne et que la trombone soit cliquable pour importer des fichier ou autre

Browse files
Files changed (2) hide show
  1. script.js +67 -15
  2. style.css +8 -0
script.js CHANGED
@@ -80,30 +80,82 @@ document.addEventListener('DOMContentLoaded', () => {
80
  });
81
 
82
  sendBtn.addEventListener('click', handleSend);
83
-
84
- // Microphone functionality
85
  if (micBtn) {
86
- micBtn.addEventListener('click', () => {
87
- alert("Fonctionnalité microphone activée. Parle maintenant !");
88
- // In a real implementation, we would use the Web Speech API here
89
- });
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- // Plus button functionality
93
- if (plusBtn) {
94
- plusBtn.addEventListener('click', () => {
95
- window.location.href = "baleine.html";
 
 
 
 
 
 
 
 
 
96
  });
97
  }
98
 
99
- // Paperclip button functionality
100
  if (paperclipBtn) {
 
 
 
 
 
 
101
  paperclipBtn.addEventListener('click', () => {
102
- alert("Fonctionnalité d'ajout de fichier activée");
103
- // In a real implementation, we would use a file input here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  });
105
  }
106
- };
107
 
108
  // Initialize all functionality
109
  const init = () => {
 
80
  });
81
 
82
  sendBtn.addEventListener('click', handleSend);
83
+ // Microphone functionality using Web Speech API
 
84
  if (micBtn) {
85
+ micBtn.addEventListener('click', async () => {
86
+ try {
87
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
88
+ if (!SpeechRecognition) {
89
+ alert("La reconnaissance vocale n'est pas supportée sur votre navigateur");
90
+ return;
91
+ }
92
+
93
+ const recognition = new SpeechRecognition();
94
+ recognition.lang = 'fr-FR';
95
+ recognition.interimResults = false;
96
+
97
+ recognition.onresult = (event) => {
98
+ const transcript = event.results[0][0].transcript;
99
+ input.value = transcript;
100
+ handleSend();
101
+ };
102
+
103
+ recognition.onerror = (event) => {
104
+ console.error('Erreur de reconnaissance vocale:', event.error);
105
+ alert(`Erreur de reconnaissance: ${event.error}`);
106
+ };
107
 
108
+ await navigator.mediaDevices.getUserMedia({ audio: true });
109
+ recognition.start();
110
+ micBtn.innerHTML = '<i data-feather="mic-off" class="w-5 h-5"></i>';
111
+ feather.replace();
112
+
113
+ recognition.onend = () => {
114
+ micBtn.innerHTML = '<i data-feather="mic" class="w-5 h-5"></i>';
115
+ feather.replace();
116
+ };
117
+ } catch (err) {
118
+ console.error('Erreur microphone:', err);
119
+ alert('Permission microphone refusée');
120
+ }
121
  });
122
  }
123
 
124
+ // File attachment functionality
125
  if (paperclipBtn) {
126
+ // Create hidden file input
127
+ const fileInput = document.createElement('input');
128
+ fileInput.type = 'file';
129
+ fileInput.style.display = 'none';
130
+ document.body.appendChild(fileInput);
131
+
132
  paperclipBtn.addEventListener('click', () => {
133
+ fileInput.click();
134
+ });
135
+
136
+ fileInput.addEventListener('change', (e) => {
137
+ const file = e.target.files[0];
138
+ if (!file) return;
139
+
140
+ // Handle different file types
141
+ if (file.type.startsWith('image/')) {
142
+ const reader = new FileReader();
143
+ reader.onload = (event) => {
144
+ const img = document.createElement('img');
145
+ img.src = event.target.result;
146
+ img.classList.add('max-w-xs', 'max-h-40', 'rounded-lg', 'mt-2');
147
+
148
+ const message = `Fichier image: ${file.name}`;
149
+ displayMessage(`${message}<br>`);
150
+ messageContainer.appendChild(img);
151
+ };
152
+ reader.readAsDataURL(file);
153
+ } else {
154
+ displayMessage(`Fichier joint: ${file.name} (${(file.size / 1024).toFixed(1)} KB)`);
155
+ }
156
  });
157
  }
158
+ };
159
 
160
  // Initialize all functionality
161
  const init = () => {
style.css CHANGED
@@ -123,6 +123,14 @@ input:focus, button:focus {
123
  border-color: rgba(239, 68, 68, 0.5) !important;
124
  }
125
 
 
 
 
 
 
 
 
 
126
  #chatAttachBtn:hover {
127
  color: #10b981;
128
  }
 
123
  border-color: rgba(239, 68, 68, 0.5) !important;
124
  }
125
 
126
+ /* File upload preview */
127
+ .file-preview {
128
+ max-width: 100%;
129
+ max-height: 200px;
130
+ border-radius: 0.5rem;
131
+ margin-top: 0.5rem;
132
+ border: 1px solid rgba(255, 255, 255, 0.1);
133
+ }
134
  #chatAttachBtn:hover {
135
  color: #10b981;
136
  }