-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (24 loc) · 897 Bytes
/
script.js
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
27
28
29
30
31
var divtag = document.getElementById("contain");
var list = [];
var autoreply = ["hey", "hello", "i am good", "where are you", "OH ,WOW"];
console.log(autoreply[num]);
function btn() {
var input = document.getElementById("input");
if (input.value != "") {
divtag.innerHTML = "";
list.push({ text: input.value , admin :false });
handletime();
input.value = "";
var num = Math.floor(Math.random() * autoreply.length);
setTimeout(() => {
list.push({ text: autoreply[num] ,admin :true});
handletime();
}, 1000);
function handletime() {
divtag.innerHTML = ""
for (i = 0; i < list.length; i++) {
divtag.innerHTML += `<h1 id="msg" class="h-[5vh] px-20 py-5 bg-white flex items-center ml-2 md:ml-20 mr-2 md:mr-20 ${list[i].admin? "self-start bubble right" :"self-end bubble left"} ">${list[i].text}</h1>`;
}
}
}
}