jquery.terminal 0,0,0,2,0,7 Bower npm

jQuery Terminal Emulator

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

http://terminal.jcubic.pl

npm bower Gitter chat travis Known Vulnerabilities Coverage Status downloads package quality

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 jQuery library, you can use cdn from http://jquery.com/download/

Then include js/jquery.terminal-1.4.2.min.js and css/jquery.terminal-1.4.2.css

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

NOTE: From version 1.0.0 if you want to support old browsers or Safari then you'll need to use key event property polyfill

You can also grab the files from CDN:

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

or

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

And you're good to go.

Example of usage

This is code that uses low level function, 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) {
        if (command !== '') {
            var result = window.eval(command);
            if (result != undefined) {
                this.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.

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> '
    });
});

Command foo will execute json-rpc from foo.php file.

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.

Contributors


Jakub Jankiewicz

commits

Zuo Qiyang

commits

Sébastien Warin

commits

Christopher John Ryan

commits

Johan

commits

Florian Schäfer

commits

Ishan Ratnapala

commits

Tomasz Ducin

commits

finlob

commits

Hasan

commits

Hraban Luyat

commits

Martin v. Löwis

commits

Mateusz Paprocki

commits

exit1

commits

Robert Wikman

commits

Steve Phillips

commits

Yutong Luo

commits

coderaiser

commits

mrkaiser

commits

stereobooster

commits

Juraj Vitko

commits

License

Licensed under MIT license

Copyright (c) 2011-2017 Jakub Jankiewicz

Related Repositories

jquery-console

jquery-console

A simple JQuery console emulator ...

jq-console

jq-console

Feature complete web terminal ...

atom-terminal-panel

atom-terminal-panel

Advanced terminal interface for Atom editor ...

terminal.js

terminal.js

DOM-driven fake terminal output jQuery plugin ...

angular-jquery-mobile

angular-jquery-mobile

A todo example with angular, jquery mobile, and tested with karma & travis. Expl ...


Top Contributors

jcubic ChrisJohnRyan fschaefer johanjordaan ducin mattpap hraban loewis finlob exit1 rbw0 elimisteve yutongluo coderaiser mrkaiser youurayy

Dependencies

package version
jquery ~3
dev coveralls ^2.11.15
cssnano-cli ^1.0.5
eslint ^3.14.1
istanbul ^0.4.3
jasmine ^2.4.1
jasmine-node ^1.14.5
jsdom ^9.9.1
jsonlint ^1.6.2
optimist ^0.6.1
uglify-js ^3.0.7

Releases

-   0.11.10 zip tar
-   0.11.9 zip tar
-   0.11.8 zip tar
-   0.11.7 zip tar
-   0.11.6 zip tar
-   0.11.5 zip tar
-   0.11.4 zip tar
-   0.11.3 zip tar
-   0.11.2 zip tar
-   0.11.1 zip tar
-   0.11.0 zip tar
-   0.10.12 zip tar
-   0.10.11 zip tar
-   0.10.10 zip tar
-   0.10.9 zip tar
-   0.10.8 zip tar
-   0.10.7 zip tar
-   0.10.6 zip tar
-   0.10.5 zip tar
-   0.10.4 zip tar
-   0.10.3 zip tar
-   0.10.2 zip tar
-   0.10.1 zip tar
-   0.10.0 zip tar
-   0.9.3 zip tar
-   0.9.2 zip tar
-   0.9.1 zip tar
-   0.9.0 zip tar
-   0.8.8 zip tar
-   0.8.7 zip tar