Download the terminal.js file and include it in your HTML head:
Now in your script, it´s time to create an instance of a terminal object. You can create as many terminal instances as you like and they will behave independently:
To insert the terminal element into a HTML element, call the ".html()" method of the terminal instance:
A terminal.js instance offers the following properties and methods:
This is the top DOM element of the terminal instance. If you want to modify styling via CSS, all instances belong to a .Terminal class. The element will also get the ID from the constructor argument.
Prints the message on a new line.
Prints the message, and shows a prompt where the user can write. When the user presses enter, the callback function fires. The callback takes one argument, which is the user input.
The same as input but the input of the user will be hidden just like an old-fashioned terminal.
Displays a confirm message, with a " (y/n)" automatically appended at the end. The callback receives the yes/no value as a boolean.
Clears the screen.
Plays a retro digital tone.
All the ".set" methods accepts any CSS-compliant value.
Set to true by default.
Style your terminal:
Asking for user input and acting upon it:
Using the timer: