jQuery Terminal Emulator
JavaScript CSS Other
Latest commit f38ab7f Dec 2, 2016 @jcubic committed on GitHub Create ISSUE_TEMPLATE
Permalink
Failed to load latest commit information.
.github Create ISSUE_TEMPLATE Dec 2, 2016
bin Add minified css file and fix file versions May 2, 2016
css don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
examples Add main and echo option wrap - close #261 Nov 14, 2016
js don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
spec Fix tests Oct 7, 2016
.gitignore Ignore coverage and reports Jun 18, 2016
.npmignore don't give warning on text/json mime in rpc and remove versioned file… Nov 14, 2016
CHANGELOG don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
LICENSE Add MIT license Jan 27, 2016
Makefile don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
Makefile.in Fix Cycle::rotate and remove global window.terminals Jun 19, 2016
README.in Add --dev to bower install Aug 7, 2016
README.md don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
SpecRunner.html Remove window focus and window blur on destroy Dec 25, 2015
bower.in Use jQuery ~2 in bower (jasmine don't work correctly in version 3) Aug 7, 2016
bower.json don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
manifest Use MIT license - #204 Jan 27, 2016
package.in Update package.json Nov 19, 2016
package.json don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
terminal.jquery.json don't scroll to terminal (using caret plugin) when it's disabled Nov 29, 2016
version Update version + version update script May 3, 2016

README.md

       __ _____                     ________                              __
      / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /
  __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /
 /  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__
 \___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
           \/              /____/                              version 0.11.21

http://terminal.jcubic.pl

Summary

jQuery Terminal Emulator is a plugin for creating command line interpreters in your applications. It can automatically call JSON-RPC service when a user types commands or you can provide you own function in which you can parse user commands. It's ideal if you want to provide additional functionality for power users. It can also be used to debug your application.

Features:

  • You can create an interpreter for your JSON-RPC service with one line of code (just use url as first argument).

  • Support for authentication (you can provide functions when users enter login and password or if you use JSON-RPC it can automatically call login function on the server and pass token to all functions)

  • Stack of interpreters - you can create commands that trigger additional interpreters (eg. you can use couple of JSON-RPC service and run them when user type command)

  • Command Tree - you can use nested objects. Each command will invoke a function, if the value is an object it will create a new interpreter and use the function from that object as commands. You can use as many nested object/commands as you like. If the value is a string it will create JSON-RPC service.

  • Support for command line history, it uses Local Storage if possible

  • Support for tab completion

  • Includes keyboard shortcut from bash like CTRL+A, CTRL+D, CTRL+E etc.

  • Multiply terminals on one page (every terminal can have different command, it's own authentication function and it's own command history)

  • It catches all exceptions and displays error messages in the terminal (you can see errors in your javascript and php code in terminal if they are in the interpreter function)

Installation

You can install jQuery Terminal from bower:

bower install jquery.terminal

or npm:

npm install --save jquery.terminal

Include js/jquery.terminal-0.11.21.min.js and css/jquery.terminal-0.11.21.css You can also include js/jquery.mousewheel-min.js

<script src="js/jquery.terminal-0.11.21.min.js"></script>
<script src="js/jquery.mousewheel-min.js"></script>
<link href="css/jquery.terminal-0.11.21.css" rel="stylesheet"/>

You can also grab the files from CDN:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/0.11.21/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/0.11.21/css/jquery.terminal.min.css" rel="stylesheet"/>

or

<script src="https://cdn.jsdelivr.net/jquery.terminal/0.11.21/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.terminal/0.11.21/jquery.terminal.min.css">

And you're good to go.

Example of usage (javascript interpreter)

This is code that uses low level, that gives you full control of the commands, just pass anything that the user types into a function.

jQuery(function($, undefined) {
    $('#term_demo').terminal(function(command, term) {
        if (command !== '') {
            var result = window.eval(command);
            if (result != undefined) {
                term.echo(String(result));
            }
        }
    }, {
        greetings: 'Javascript Interpreter',
        name: 'js_demo',
        height: 200,
        width: 450,
        prompt: 'js> '
    });
});

Here is a higher level call, using an object as an interpreter, By default the terminal will parse commands that a user types and replace number like strings with real numbers regex with regexes and process escape characters in double quoted strings. Command foo will execute json-rpc from foo.php file.

jQuery(function($, undefined) {
    $('#term_demo').terminal({
        add: function(a, b) {
            this.echo(a + b);
        },
        foo: 'foo.php',
        bar: {
            sub: function(a, b) {
                this.echo(a - b);
            }
        }
    }, {
        height: 200,
        width: 450,
        prompt: 'demo> '
    });
});

You can create JSON-RPC interpreter with authentication in just one line:

$('#term_demo').terminal('service.php', {login: true});

More examples here. You can also check full documentation.

Test

If you want to run tests from browser you need to run

bower install --dev

and open SpecRunner.html file in the browser

To run tests from command line you need to run this commands:

npm install
make test

you can also run test covarage using

make cover

Live Chat

Gitter chat

Licensed under MIT license

Copyright (c) 2011-2016 Jakub Jankiewicz