generated from skills/github-pages
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
49 lines (40 loc) · 1.26 KB
/
index.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.addEventListener("DOMContentLoaded", () => {
const whoamiSpan = document.getElementById("whoami");
const cursorSpan = document.getElementById("cursor");
const jobs = [
"Malware Analyst",
"Unreal Engine Spc",
"C++ Developer",
"1 Thessalonians 5:11"
];
let i = 0;
let j = 0;
let isDeleting = false;
let speed = 100;
function type() {
const job = jobs[i % jobs.length];
if (!isDeleting) {
whoamiSpan.textContent = "$ whoami: " + job.substring(0, j);
cursorSpan.style.display = "inline-block";
} else {
whoamiSpan.textContent = "$ whoami: " + job.substring(0, j) + "_";
cursorSpan.style.display = "none";
}
if (!isDeleting && j === job.length) {
setTimeout(() => {
isDeleting = true;
speed = 25;
}, 2500); // wait for 2.5 seconds before deleting
} else if (isDeleting && j === 0) {
isDeleting = false;
i++;
speed = 100;
setTimeout(() => {
speed = 100;
}, 500); // wait for half a second before typing again
}
j += isDeleting ? -1 : 1;
setTimeout(type, speed);
}
type();
});