JQuery Terminal Emulator is a plugin for creating command line interpreters in your applications. It can automatically call JSON-RPC service when user type commands or you can provide an object with methods, each method will be invoke on user command. Object can have nested objects which will create nested interpreter. You can also use a function in which you can parse user command by your own. It′s ideal if you want to provide additional functionality for power users. It can also be used as debuging tool.
This is simple demo using javascript interpreter. (If cursor is not blinking - click on terminal to activate it) You can type any javascript expression, there are two debug function dir (like in python).
You can use JQuery ‘$’ function to manipulate the page. You also have access to this terminal in ‘term’ variable. Try ‘dir(term)’ or ‘term.signature()’.
Javascript code:
jQuery(function($, undefined) {
$('#term_demo').terminal(function(command, term) {
if (command !== '') {
try {
var result = window.eval(command);
if (result !== undefined) {
term.echo(new String(result));
}
} catch(e) {
term.error(new String(e));
}
} else {
term.echo('');
}
}, {
greetings: 'Javascript Interpreter',
name: 'js_demo',
height: 200,
prompt: 'js> '});
});