Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +23 -35
templates/index.html
CHANGED
@@ -1013,41 +1013,29 @@
|
|
1013 |
}
|
1014 |
|
1015 |
function displayOptions(options) {
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
backButton.className = 'option-button';
|
1040 |
-
backButton.onclick = () => {
|
1041 |
-
console.log('Back button clicked');
|
1042 |
-
// Remove last user message and reset currentStep
|
1043 |
-
conversation.pop();
|
1044 |
-
console.log('Removed last user message, conversation length:', conversation.length);
|
1045 |
-
resetToPreviousStep();
|
1046 |
-
};
|
1047 |
-
chatMessages.appendChild(backButton);
|
1048 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
1049 |
-
console.log('Back button added');
|
1050 |
-
}
|
1051 |
|
1052 |
|
1053 |
|
|
|
1013 |
}
|
1014 |
|
1015 |
function displayOptions(options) {
|
1016 |
+
const chatMessages = document.getElementById('chatMessages');
|
1017 |
+
if (!chatMessages) {
|
1018 |
+
console.error('Chat messages container not found for options!');
|
1019 |
+
return;
|
1020 |
+
}
|
1021 |
+
console.log('Displaying options:', options);
|
1022 |
+
options.forEach(opt => {
|
1023 |
+
const button = document.createElement('button');
|
1024 |
+
button.textContent = opt.text;
|
1025 |
+
button.className = `option-button ${opt.class}`;
|
1026 |
+
button.onclick = () => {
|
1027 |
+
addMessage('user', opt.text);
|
1028 |
+
conversation.push({ role: 'user', message: opt.text });
|
1029 |
+
console.log(`User selected option: ${opt.text}`);
|
1030 |
+
setTimeout(() => handleResponse(opt.text), 500);
|
1031 |
+
};
|
1032 |
+
chatMessages.appendChild(button);
|
1033 |
+
});
|
1034 |
+
chatMessages.appendChild(document.createElement('br'));
|
1035 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
1036 |
+
console.log('Options displayed');
|
1037 |
+
}
|
1038 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
|
1040 |
|
1041 |
|