-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminal.js
89 lines (84 loc) · 2.93 KB
/
terminal.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
const email = document.querySelector("#email");
const emailResponse = document.querySelector("#emailResponse");
const terminal = document.querySelector(".terminal");
email.addEventListener("keydown", (e) => {
// e.preventDefault();
if (e.key == "Enter") {
emailResponse.innerHTML = `
<div class="terminal-row">
<div class="terminal-response">
<i class="fa-solid fa-circle-check text-green"></i>
<p class="text">${email.value}</p>
</div>
</div>
`;
const askName = document.querySelector("#askName");
askName.innerHTML = `
<p class="text px-1">
Awesome! What's <span class="text-green">your name?</span>
</p>
`;
const nameBox = document.querySelector("#nameBox");
nameBox.innerHTML = `
<div class="terminal-row">
<div class="zsh-icons">
<i class="fa-solid fa-arrow-right text-green"></i>
</div>
<div class="terminal-user-input">
<p class="text">Enter name :</p>
<input
class="terminal-input text-green"
id="name"
type="text"
name="name"
/>
</div>
</div>
`;
// Add event listener to the dynamically created name input field
const nameInput = document.querySelector("#name");
nameInput.addEventListener("keydown", (e) => {
if (e.key == "Enter") {
// console.log(true); // Placeholder for what you want to do with the name
const nameResponse = document.querySelector("#nameResponse");
nameResponse.innerHTML = `
<div class="terminal-row">
<div class="terminal-response">
<i class="fa-solid fa-circle-check text-green"></i>
<p class="text">${nameInput.value}</p>
</div>
</div>
`;
const askMessage = document.querySelector("#askMessage");
askMessage.innerHTML = `
<p class="text px-1">
Perfect! How can I
<span class="text-green">help you?</span>
</p>
`;
const messageBox = document.querySelector("#messageBox");
messageBox.innerHTML = `
<div class="message">
<div class="zsh-icons">
<i class="fa-solid fa-arrow-right text-green"></i>
</div>
<div class="terminal-user-input">
<p class="text">Enter description :</p>
<textarea
class="messageInput text-green"
name="message"
id="message"
cols="50"
rows="10"
></textarea>
</div>
</div>
`;
// const sendBtn = document.createElement("button");
// sendBtn.textContent = "sendi it";
// sendBtn.classList.add("btn-send", "bg-green");
// terminal.append(sendBtn);
}
});
}
});