Updated console
This commit is contained in:
		@@ -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;
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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() {
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user