My Current Project
I am trying to make a terminal-style webpage using jQuery Terminal.
My Problem
I cannot figure out how to add more than one command to the terminal.
Here’s my code:
JavaScript
x
10
10
1
$('body').terminal({
2
hello: function(name) {
3
this.echo('Hello, ' + name +
4
'. Welcome to the Rapocrythia command line.');
5
}
6
}, {
7
greetings: 'Rapocrythia Command Line[Version 0.0.1]n(c) Copyright Rapocrythia Systems, Inc. All Rights Reserved.'
8
}
9
);
10
Advertisement
Answer
Just add more properties to the first argument.
JavaScript
1
14
14
1
$('body').terminal({
2
hello: function(name) {
3
this.echo('Hello, ' + name +
4
'. Welcome to the Rapocrythia command line.');
5
},
6
add: function(num1, num2) {
7
this.echo(parseInt(num1) + parseInt(num2));
8
},
9
bye: function() {
10
this.echo('So long');
11
}
12
}, {
13
greetings: 'Rapocrythia Command Line[Version 0.0.1]n(c) Copyright Rapocrythia Systems, Inc. All Rights Reserved.'
14
});
JavaScript
1
3
1
<link href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet" />
2
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
3
<script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.min.js"></script>
If you type add 10 15
it will print 25
.