Update script.js
Browse files
script.js
CHANGED
|
@@ -189,15 +189,24 @@ function startNewChat() {
|
|
| 189 |
chatBody.scrollTop = chatBody.scrollHeight;
|
| 190 |
}
|
| 191 |
|
| 192 |
-
function remove_special_chars(text)
|
| 193 |
-
|
| 194 |
-
allow = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 :,.?!"
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
|
| 203 |
// Text-to-Speech function
|
|
|
|
| 189 |
chatBody.scrollTop = chatBody.scrollHeight;
|
| 190 |
}
|
| 191 |
|
| 192 |
+
function remove_special_chars(text) {
|
| 193 |
+
// Allow only specified characters
|
| 194 |
+
const allow = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 :,.?!";
|
| 195 |
+
|
| 196 |
+
// Replace <br> with a space for better readability
|
| 197 |
+
text = text.replace(/<br>/g, " ");
|
| 198 |
+
|
| 199 |
+
let newtxt = "";
|
| 200 |
+
|
| 201 |
+
// Iterate through the text and include only allowed characters
|
| 202 |
+
for (let char of text) {
|
| 203 |
+
if (allow.includes(char)) {
|
| 204 |
+
newtxt += char;
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
return newtxt;
|
| 209 |
+
}
|
| 210 |
|
| 211 |
|
| 212 |
// Text-to-Speech function
|