Updated console

This commit is contained in:
Zakary Timson 2022-05-03 17:03:42 -04:00
parent ce0e7dcc98
commit cf05d96812
3 changed files with 26 additions and 19 deletions

View File

@ -3,13 +3,13 @@ import {sleep} from '../../misc/utils';
import {TypewriterComponent} from '../typewriter/typewriter.component';
@Component({
selector: 'console',
templateUrl: './console.component.html',
selector: 'console',
templateUrl: './console.component.html',
styleUrls: ['./console.component.scss']
})
export class ConsoleComponent {
done = () => {};
input = '';
input = '';
output: string[] = [];
prompt = '>'
@ -20,13 +20,16 @@ export class ConsoleComponent {
clear() { this.output = []; }
exec(input: string, output: () => any, pause = 1000) {
this.done = async () => {
await sleep(pause);
this.input = '';
this.output.push(`${this.prompt} ${input}`);
const out = output();
if(typeof out == 'string') this.output.push(out);
};
this.input = input;
return new Promise<void>(res => {
this.done = async () => {
await sleep(pause);
this.input = '';
this.output.push(`${this.prompt} ${input}`);
const out = output();
if(typeof out == 'string') this.output.push(out);
res();
};
this.input = input;
});
}
}

View File

@ -7,7 +7,13 @@ export class QuoteService {
'Some one at Google was like "Yea, just have someone drive down every road on earth!"',
'Anxiety is like when video game combat music is playing but you can\'t find the enemy',
'Why do kamikaze pilots wear helmets?',
'The cake is a lie!'
'The cake is a lie!',
'How are unicorns fake but giraffes real?',
'The number of people older than you never goes up',
'When you brush your teeth you are cleaning your skeleton',
'Pregenancy is like a group project where one person get\'s stuck with all the work',
'If the universe wasn\'t inifinate it would be even scarier',
'Either we are alone in the universe or we are not. both are terrifying'
];
random() {

View File

@ -4,8 +4,8 @@ import {QuoteService} from '../../services/quote.service';
import {sleep} from '../../misc/utils';
@Component({
selector: 'home',
templateUrl: './home.component.html'
selector: 'home',
templateUrl: './home.component.html'
})
export class HomeComponent implements AfterViewInit {
@ViewChild(ConsoleComponent) console!: ConsoleComponent;
@ -16,12 +16,10 @@ export class HomeComponent implements AfterViewInit {
animateConsole() {
setTimeout(async () => {
this.console.exec('bash ./random-thought.sh', () => this.quotes.random());
await this.console.exec('bash ./random-thought.sh', () => this.quotes.random());
await sleep(10000);
this.console.exec('clear', async () => {
this.console.clear();
this.animateConsole();
});
await this.console.exec('clear', async () => this.console.clear());
this.animateConsole();
}, 1000);
}
}