mirror of
https://github.com/ivabus/www
synced 2025-06-08 14:50:25 +03:00
52 lines
1.8 KiB
HTML
52 lines
1.8 KiB
HTML
<script>
|
|
const commands4 = [
|
|
{ input: '$ tea github.com/teaxyz/hello-universe.sh<br><br>', output: `*** Interpreters ***<br><br>`},
|
|
{ input: '', output: `TypeScript: Hello, World!<br>`},
|
|
{ input: '', output: `Go: Hello, World!<br>`},
|
|
{ input: '', output: `JavaScript: Hello, World!<br>`},
|
|
{ input: '', output: `Perl: Hello, World!<br>`},
|
|
{ input: '', output: `Python: Hello, World!<br>`},
|
|
{ input: '', output: `Ruby: Hello World!<br>`},
|
|
{ input: '', output: `Lua: Hello, World!<br><br>`},
|
|
{ input: '', output: `*** Compilers ***<br><br>`},
|
|
{ input: '', output: `C: Hello, World!<br>`},
|
|
{ input: '', output: `Rust: Hello, World!<br>`},
|
|
];
|
|
|
|
let commandIndex4 = 0;
|
|
let command4 = commands4[commandIndex4];
|
|
let commandOutput4 = '';
|
|
|
|
function typeCommand4() {
|
|
if (commandIndex4 === commands4.length) {
|
|
return;
|
|
}
|
|
if (command4.input.length === 0) {
|
|
commandOutput4 += '\n' + command4.output + '\n';
|
|
document.querySelector('#terminal-output-4').innerHTML = commandOutput4;
|
|
commandIndex4++;
|
|
command4 = commands4[commandIndex4];
|
|
setTimeout(typeCommand4, 1000);
|
|
return;
|
|
}
|
|
let char = command4.input[0];
|
|
if (char === '$') {
|
|
char = '<span class="purple">$</span>';
|
|
}
|
|
commandOutput4 += char;
|
|
command4.input = command4.input.slice(1);
|
|
document.querySelector('#terminal-output-4').innerHTML = commandOutput4;
|
|
const delay = Math.floor(Math.random() * 100) + 50; // random delay between 50 and 150 ms
|
|
setTimeout(typeCommand4, delay);
|
|
}
|
|
|
|
const terminalOutput4 = document.querySelector('#terminal-output-4');
|
|
const observer4 = new IntersectionObserver((entries) => {
|
|
if (entries[0].isIntersecting) {
|
|
typeCommand4();
|
|
observer4.disconnect();
|
|
}
|
|
});
|
|
observer4.observe(terminalOutput4);
|
|
|
|
</script>
|