-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (26 loc) · 987 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const textarea = document.querySelector('.home-textarea');
const generateButton = document.querySelector('.home-button');
const clearButton = document.querySelector('.home-button1');
const historyButton = document.querySelector('.home-button2');
const chatLog = []; // Initialize an empty chat log array
generateButton.addEventListener('click', () => {
const userMessage = textarea.value;
// Process the user's message here (for example, send it to a chatbot)
// Add the user's message to the chat log
chatLog.push(`User: ${userMessage}`);
// Clear the textarea
textarea.value = '';
});
clearButton.addEventListener('click', () => {
textarea.value = '';
});
historyButton.addEventListener('click', () => {
viewChatHistory();
});
function viewChatHistory() {
if (chatLog.length > 0) {
alert("Chat History:\n\n" + chatLog.join('\n'));
} else {
alert("No chat history available.");
}
}