Reputation: 117
I am trying to make a terminal-style webpage using jQuery Terminal.
I cannot figure out how to add more than one command to the terminal.
Here's my code:
$('body').terminal({
hello: function(name) {
this.echo('Hello, ' + name +
'. Welcome to the Rapocrythia command line.');
}
}, {
greetings: 'Rapocrythia Command Line[Version 0.0.1]\n(c) Copyright Rapocrythia Systems, Inc. All Rights Reserved.'
}
);
Upvotes: 1
Views: 679
Reputation: 780724
Just add more properties to the first argument.
$('body').terminal({
hello: function(name) {
this.echo('Hello, ' + name +
'. Welcome to the Rapocrythia command line.');
},
add: function(num1, num2) {
this.echo(parseInt(num1) + parseInt(num2));
},
bye: function() {
this.echo('So long');
}
}, {
greetings: 'Rapocrythia Command Line[Version 0.0.1]\n(c) Copyright Rapocrythia Systems, Inc. All Rights Reserved.'
});
<link href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.min.js"></script>
If you type add 10 15
it will print 25
.
Upvotes: 1