Im trying to create a login command for my Jquery Terminal, here is the code:
<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>
<script>
$('body').terminal({
login: function(user, pass) {
this.read('Login: ')
if(user === 'test'&& pass === '123') {
this.echo('Logged.')
this.set_prompt('test>')
}
else {
this.echo('Inncorrect')
}
},
}, {
checkArity: false,
prompt: '$ ',
greetings: ' ',
strings: {
commandNotFound: "-Error: unknown command: %s",
echoCommand: true,
},
pasteImage: true,
});
</script>
after the this.read('Login: ') I dont know how to make the password part of it show up after, and how to make the if statement match whats put in the this.read(). Also, once you type your username, how can I make another line of text saying password using this.read() but with the mask char?
I feel like I already have pretty much the base for this command set up, but im not sure how to make this work all together.
You're mixing two things. If you want to create a command that you call like this:
Then you should use arguments to the function. But I expect that you don't want that and want to have command work like this:
If this it the case then you should use code like this:
You can also make the user and pass arguments to login optional: