-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
49 lines (43 loc) · 1.36 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$(document).ready(() => {
function addMessage(input, className){
var message = $("<div>")
console.log(input)
message.text(input)
message.addClass(className)
$("#chatlogPackage").append(message)
}
function roboMessage(){
var randomNumber = Math.floor(Math.random()*(10-1+1))+1
var cuteMessages = {
1: "How are you doing today?",
2: "Im starving how about you are you hungry?",
3: "do you think theres life beyond planet earth?",
4: "are you right or left handed?",
5: "how many best friends do you have?",
6: "what country are you from?",
7: "do you live in a house or apartment?",
8: "do you have any pets?",
9: "whats your favorite food?",
10: "whats your favorite color?"
}
function randomGenerator(){
return cuteMessages[randomNumber];
}
addMessage(randomGenerator(), "left")
}
var firstMessage = $("<div>")
firstMessage.text("Hi there whats your name")
firstMessage.addClass("left")
$("#chatlogPackage").append(firstMessage)
submitmessage.onclick = function() {
event.preventDefault()
var div = $("#chatlogPackage");
var chatting = $('#usermessage').val();
addMessage(chatting, "right");
div.scrollTop(div.prop("scrollHeight"))
setTimeout(function(){
roboMessage() },2000
);
$('#usermessage').val('');
}
})