-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.js
More file actions
26 lines (23 loc) · 1.2 KB
/
chat.js
File metadata and controls
26 lines (23 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$(document).ready(function() {
$("#messageArea").on("submit", function(event) {
const date = new Date();
const hour = date.getHours();
const minute = date.getMinutes();
const str_time = hour+":"+minute;
var rawText = $("#text").val();
var userHtml = '<div class="d-flex justify-content-end mb-4"><div class="msg_cotainer_send">' + rawText + '<span class="msg_time_send">'+ str_time + '</span></div><div class="img_cont_msg"><img src="https://i.ibb.co/d5b84Xw/Untitled-design.png" class="rounded-circle user_img_msg"></div></div>';
$("#text").val("");
$("#messageFormeight").append(userHtml);
$.ajax({
data: {
msg: rawText,
},
type: "POST",
url: "/get",
}).done(function(data) {
var botHtml = '<div class="d-flex justify-content-start mb-4"><div class="img_cont_msg"><img src="chatlogo.jpeg" class="rounded-circle user_img_msg"></div><div class="msg_cotainer">' + data + '<span class="msg_time">' + str_time + '</span></div></div>';
$("#messageFormeight").append($.parseHTML(botHtml));
});
event.preventDefault();
});
});