Spaces:
Sleeping
Sleeping
Update templates/chat.html
Browse files- templates/chat.html +32 -12
templates/chat.html
CHANGED
@@ -220,9 +220,6 @@
|
|
220 |
currentIndex = 0;
|
221 |
});
|
222 |
});
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
|
227 |
// Send the message to the server via AJAX
|
228 |
$.ajax({
|
@@ -232,18 +229,41 @@
|
|
232 |
type: "POST",
|
233 |
url: "/get",
|
234 |
}).done(function(data) {
|
|
|
235 |
var lines = data.split("**");
|
236 |
-
var
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
-
|
241 |
-
|
242 |
-
// Smooth scroll to the bottom of the chat
|
243 |
-
var container = $("#messageFormeight");
|
244 |
-
container.animate({ scrollTop: container.prop("scrollHeight") }, 500);
|
245 |
});
|
246 |
-
event.preventDefault();
|
247 |
});
|
248 |
});
|
249 |
</script>
|
|
|
220 |
currentIndex = 0;
|
221 |
});
|
222 |
});
|
|
|
|
|
|
|
223 |
|
224 |
// Send the message to the server via AJAX
|
225 |
$.ajax({
|
|
|
229 |
type: "POST",
|
230 |
url: "/get",
|
231 |
}).done(function(data) {
|
232 |
+
// --- Typewriter effect for bot response START ---
|
233 |
var lines = data.split("**");
|
234 |
+
var fullText = lines.join(' ');
|
235 |
+
|
236 |
+
// Create the container for the bot message
|
237 |
+
var botContainer = $('<div class="d-flex justify-content-start mb-4"></div>');
|
238 |
+
var imgDiv = $('<div class="img_cont_msg"><img src="/static/images/juitlogo.png" class="rounded-circle user_img_msg"></div>');
|
239 |
+
var msgDiv = $('<div class="msg_container"></div>');
|
240 |
+
botContainer.append(imgDiv);
|
241 |
+
botContainer.append(msgDiv);
|
242 |
+
$("#messageFormeight").append(botContainer);
|
243 |
+
|
244 |
+
var i = 0;
|
245 |
+
|
246 |
+
function typeWriter() {
|
247 |
+
if (i < fullText.length) {
|
248 |
+
var charSpan = $('<span style="opacity: 0;">' + fullText.charAt(i) + '</span>');
|
249 |
+
msgDiv.append(charSpan); // Append the character
|
250 |
+
|
251 |
+
charSpan.animate({ opacity: 1 }, 150); // Fade-in effect
|
252 |
+
|
253 |
+
i++;
|
254 |
+
setTimeout(typeWriter, 15); // Adjust delay as needed
|
255 |
+
} else {
|
256 |
+
msgDiv.append('<span class="msg_time">' + str_time + '</span>');
|
257 |
+
|
258 |
+
// Smooth scroll to the bottom of the chat
|
259 |
+
var container = $("#messageFormeight");
|
260 |
+
container.animate({ scrollTop: container.prop("scrollHeight") }, 500);
|
261 |
+
}
|
262 |
}
|
263 |
+
typeWriter();
|
264 |
+
// --- Typewriter effect for bot response END ---
|
|
|
|
|
|
|
265 |
});
|
266 |
+
event.preventDefault();
|
267 |
});
|
268 |
});
|
269 |
</script>
|