forked from will0101/www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tea-magic-terminal-animation.html
32 lines (29 loc) · 1.33 KB
/
tea-magic-terminal-animation.html
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
<script>
const arrCommands = [
{ input: "$ python --eval 'print(\"Hello World!\")'", output: `command not found: python<br><span class="dark-gray">#Python is not installed, thus command is not found :/ ...</span><br>` },
{ input: "$ sh <(curl mysite.com) --yes", output: `installing ~/.mysite...`},
{ input: "$ python --eval 'print(\"Hello World!\")'", output: `mysite: installing python.org^19<br><span class="dark-gray">#mysite magically installs needed dependencies...</span>` },
{ input: "", output: `Hello World! 😎<br><span class="dark-gray">#and tah-dah!</span>` },
];
let intCommandIndex = 0;
let objCommand = arrCommands[intCommandIndex];
let strCommandOutput = "";
function typeCommand() {
if (intCommandIndex === arrCommands.length) {
return;
}
if (objCommand.input.length === 0) {
strCommandOutput += '\n' + objCommand.output + '\n';
document.querySelector("#terminal-display").innerHTML = strCommandOutput;
intCommandIndex++;
objCommand = arrCommands[intCommandIndex];
setTimeout(typeCommand, 1000);
return;
}
strCommandOutput += objCommand.input[0];
objCommand.input = objCommand.input.slice(1);
document.querySelector("#terminal-display").innerHTML = strCommandOutput;
setTimeout(typeCommand, 100);
}
typeCommand();
</script>