-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (66 loc) · 2.04 KB
/
script.js
File metadata and controls
76 lines (66 loc) · 2.04 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const chat = {};
chat.enableSend = function () {
const popup = document.getElementById("popup");
const audio = document.querySelector("audio");
const textarea = document.querySelector("textarea");
textarea.oninput = handleInput;
function handleInput(e) {
if (e.target.value !== "") {
button.setAttribute("style", "color: black; cursor: pointer");
} else {
button.setAttribute("style", "color: #b5bfdb; cursor: not-allowed");
button.addEventListener("click", function (e) {
e.preventDefault();
});
}
}
const button = document.querySelector("button");
button.addEventListener(
"click",
function () {
audio.play();
chat.pickAText();
popup.setAttribute("style", "visibility: visible");
},
false
);
document.addEventListener("keydown", function (e) {
if (e.code === "Escape") {
popup.setAttribute("style", "visibility: hidden");
}
});
textarea.addEventListener("keydown", function (e) {
if (e.code === "Enter") {
e.preventDefault();
button.click();
}
});
};
chat.pickAText = function () {
anxietyText = [
"Damn, you sure you want to send that?",
"Literally, what are you even trying to say here?",
"You're really bad at this",
"Can you please go outside and smell some fresh air?",
"You need some grammar lessons",
"For the love of god, enjoy your youth and get off the internet",
"That's a risky text...",
"I'm not letting you send that.",
"Whatever happened to going outside and having a life?",
"You need to stop romantacizing your life, your life is just not that interesting",
"No... that's not good dude",
];
const meanMessages = document.getElementById("meanMessages");
function append() {
randomText = anxietyText[Math.floor(Math.random() * anxietyText.length)];
meanMessages.innerHTML = randomText;
}
return append();
};
chat.init = function () {
chat.enableSend();
chat.pickAText();
};
document.addEventListener("DOMContentLoaded", function () {
chat.init();
});