Update script.js
Browse files
script.js
CHANGED
|
@@ -261,6 +261,7 @@ function speakTextSequential(text, language, callback) {
|
|
| 261 |
|
| 262 |
|
| 263 |
|
|
|
|
| 264 |
function formatBotResponse(rawResponse) {
|
| 265 |
// Replace newlines with actual <br> for line breaks
|
| 266 |
let rawResponseList = rawResponse.split('\n');
|
|
@@ -280,8 +281,6 @@ function formatBotResponse(rawResponse) {
|
|
| 280 |
}
|
| 281 |
|
| 282 |
|
| 283 |
-
|
| 284 |
-
|
| 285 |
function sendMessage() {
|
| 286 |
const message = userInput.value.trim();
|
| 287 |
|
|
@@ -331,7 +330,7 @@ function sendMessage() {
|
|
| 331 |
let botResponses = data.response;
|
| 332 |
const language = data.language || 'en';
|
| 333 |
|
| 334 |
-
const { botResponse, category } = formatBotResponse(botResponses);
|
| 335 |
|
| 336 |
// Extract mantra if present in the response
|
| 337 |
const mantraMatch = botResponse.match(/\[\[(.*?)\]\]/s); // Use [[ and ]] for mantra
|
|
|
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
+
// Format bot response and handle categories
|
| 265 |
function formatBotResponse(rawResponse) {
|
| 266 |
// Replace newlines with actual <br> for line breaks
|
| 267 |
let rawResponseList = rawResponse.split('\n');
|
|
|
|
| 281 |
}
|
| 282 |
|
| 283 |
|
|
|
|
|
|
|
| 284 |
function sendMessage() {
|
| 285 |
const message = userInput.value.trim();
|
| 286 |
|
|
|
|
| 330 |
let botResponses = data.response;
|
| 331 |
const language = data.language || 'en';
|
| 332 |
|
| 333 |
+
const { formattedResponse: botResponse, category } = formatBotResponse(botResponses); // Destructure correctly
|
| 334 |
|
| 335 |
// Extract mantra if present in the response
|
| 336 |
const mantraMatch = botResponse.match(/\[\[(.*?)\]\]/s); // Use [[ and ]] for mantra
|