I am trying to create a Linux terminal themed website which has multiple commands. The user has liberty to use whichever commands he/she wants just like a normal terminal. I've created a sample HTML file and included a simple function which displays a "cat" when the user displays a cat. However, I am having a problem creating multiple functions. I am not familiar with javascript and HTML that much, so it maybe a stupid question. My code is:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css"/>
</head>
<body>
<script>
$('body').terminal({
cat: function() {
this.echo($('<img src="https://placekitten.com/408/287">'));
}
});
</script>
</body>
</html>
The output website looks something like this:
Now, If I add one more function. I get the error function_name not found
. My sample code for multiple function is,
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css"/>
</head>
<body>
<script>
$('body').terminal({
cat: function() {
this.echo($('<img src="https://placekitten.com/408/287">'));
}
dog: function(v){
this.echo('hello ' + v);
}
});
</script>
</body>
</html>
So, I would like a terminal where I could interact with multiple commands (functions). Also, it would be great to be directed to other resources which could have helpful info on this topic. Thanks in advance. (also, I have referred to https://itnext.io/how-to-create-interactive-terminal-like-website-888bb0972288).