Jqterm

A JQuery plugin for a commandline emulator with custom interpreters and formatter

Download as .zip Download as .tar.gz View on GitHub

jqterm

A JQuery plugin for a commandline emulator with custom interpreters and formatter

Usage

In your HTML file, include the jqterm js and css files

<script type="text/javascript" src="jqterm.js"></script>
<link rel="stylesheet" type="text/css" href="jqterm.css" />

To use emulate terminal inside div with id terminal, use following code:

$('#terminal').term({

  interpreter: invokeCommand,
  welcome: 'Welcome to jqTerm. The commandline emulator written in JQuery'

});

Where invokeCommand would be a function that accepts a tokenized command and returns jquery deferred If the command entered is

$ awesome_script -s "C:\Program Files\Foo\Bar One\my.pl" -o foo

The interpreter would receive following array as argument

['awesome_script', '-s' 'C:\Program Files\Foo\Bar One\my.pl', '-o', 'foo']

So the invokeCommand function would look like

function invokeCommand(cmd)
{
  return $.ajax({

    url: '/cmd_interpreter',
    dataType:'json',
    data: {'cmd':cmd}
  });
}