Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +8 -12
static/script.js
CHANGED
@@ -75,29 +75,25 @@ function handleResponse(userInput) {
|
|
75 |
|
76 |
function displayOptions(options) {
|
77 |
// Function to display options on the UI
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
options.forEach(option => {
|
79 |
const button = document.createElement('button');
|
80 |
button.classList.add(option.class);
|
81 |
button.textContent = option.text;
|
82 |
button.onclick = () => handleResponse(option.text);
|
83 |
-
|
84 |
});
|
85 |
}
|
86 |
|
87 |
-
function addMessage(role, message) {
|
88 |
-
// Function to add the bot or user message to the chat window
|
89 |
-
const messageContainer = document.createElement('div');
|
90 |
-
messageContainer.classList.add(role);
|
91 |
-
messageContainer.textContent = message;
|
92 |
-
document.getElementById('chat').appendChild(messageContainer);
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
document.getElementById('userInput').addEventListener('keypress', function(e) {
|
97 |
if (e.key === 'Enter') {
|
98 |
sendMessage();
|
99 |
}
|
100 |
});
|
101 |
|
102 |
-
|
103 |
-
console.log('Script loaded successfully');
|
|
|
75 |
|
76 |
function displayOptions(options) {
|
77 |
// Function to display options on the UI
|
78 |
+
const optionsContainer = document.getElementById('options-container');
|
79 |
+
if (!optionsContainer) {
|
80 |
+
console.error('Options container not found!');
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
options.forEach(option => {
|
85 |
const button = document.createElement('button');
|
86 |
button.classList.add(option.class);
|
87 |
button.textContent = option.text;
|
88 |
button.onclick = () => handleResponse(option.text);
|
89 |
+
optionsContainer.appendChild(button);
|
90 |
});
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
document.getElementById('userInput').addEventListener('keypress', function(e) {
|
94 |
if (e.key === 'Enter') {
|
95 |
sendMessage();
|
96 |
}
|
97 |
});
|
98 |
|
99 |
+
console.log('Script loaded successfully');
|
|