-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
const chatMessages = document.getElementById('chat-messages'); | ||
const userInput = document.getElementById('user-input'); | ||
const sendButton = document.getElementById('send-button'); | ||
|
||
function addUserMessage(message) { | ||
const messageDiv = document.createElement('div'); | ||
messageDiv.classList.add('message', 'user-message'); | ||
messageDiv.textContent = message; | ||
chatMessages.appendChild(messageDiv); | ||
} | ||
|
||
function addBotMessage(message) { | ||
const messageDiv = document.createElement('div'); | ||
messageDiv.classList.add('message', 'bot-message'); | ||
messageDiv.textContent = message; | ||
chatMessages.appendChild(messageDiv); | ||
} | ||
|
||
sendButton.addEventListener('click', () => { | ||
const userMessage = userInput.value; | ||
if (userMessage.trim() !== '') { | ||
addUserMessage(userMessage); | ||
// Aquí puedes agregar lógica para responder como un bot | ||
// Por ejemplo: addBotMessage("Respuesta del bot..."); | ||
userInput.value = ''; | ||
} | ||
}); | ||
|
||
|
||
const chatContainer = document.getElementById('chat-container'); | ||
const chatButton = document.getElementById('chat-button'); | ||
|
||
chatButton.addEventListener('click', () => { | ||
if (chatContainer.style.display === 'none') { | ||
chatContainer.style.display = 'block'; | ||
} else { | ||
chatContainer.style.display = 'none'; | ||
} | ||
}); |