jQuery Command Line Interpreter Plugin - Terminal Emulator

jQuery Command Line Interpreter Plugin - Terminal Emulator
File Size: 281 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A simple jQuery based terminal emulator that make it easy to create command line interpreter for your website or web application.  Command Line Interpreter is a blanket term for a certain class of programs designed to read lines of text entered by a user, thus implementing a command-line interface.(More info about Command Line Interpreter on WIKI). 

Licensed under GNU LGPL Version 3 license.

You might also like:

Main Features:

  • Automatically call JSON-RPC service.
  • You can provide you own function in which you can parse user command.
  • Command Tree supported
  • Command line history supported
  • Tab completion supported
  • Keyboard shortcut like CTRL+A, CTRL+D, CTRL+E etc, supported
  • Authentication supported
  • Multiple Command Line Interpreters on one page supported

 Basic Usage:

1. Include jQuery library and terminal emulator plugin on your page

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.terminal-min.js"></script>

2. Include Mouse Wheel Plugin to support mouse wheel feature

<script src="js/jquery.mousewheel-min.js"></script>

3. Include jQuery Terminal Emulator CSS to style the plugin

<link href="css/jquery.terminal.css" rel="stylesheet"/>

4. The Javascript

<script>
    jQuery(document).ready(function($) {
        $('body').terminal("json-rpc-service-demo.php", {
            login: true,
            greetings: "You are authenticated",
            onBlur: function() {
                // the height of the body is only 2 lines initialy
                return false;
            }
        });
    });
</script>

5. Default options.

prompt: '> ',
history: true,
exit: true,
clear: true,
enabled: true,
historySize: 60,
maskChar: '*',
wrap: true,
checkArity: true,
raw: false,
exceptionHandler: null,
memory: false,
cancelableAjax: true,
processArguments: true,
linksNoReferrer: false,
processRPCResponse: null,
Token: true, // where this came from?
convertLinks: true,
extra: {},
historyState: false,
importHistory: false,
echoCommand: true,
scrollOnEcho: true,
login: null,
outputLimit: -1,
formatters: [],
onAjaxError: null,
scrollBottomOffset: 20,
wordAutocomplete: true,
clickTimeout: 200,
request: $.noop,
response: $.noop,
onRPCError: null,
completion: false,
historyFilter: null,
softPause: false,
onInit: $.noop,
onClear: $.noop,
onBlur: $.noop,
onFocus: $.noop,
onTerminalChange: $.noop,
onExit: $.noop,
onPush: $.noop,
onPop: $.noop,
keypress: $.noop,
keydown: $.noop,
strings: {
  comletionParameters: 'From version 1.0.0 completion function need to' +
      'have two arguments',
  wrongPasswordTryAgain: 'Wrong password try again!',
  wrongPassword: 'Wrong password!',
  ajaxAbortError: 'Error while aborting ajax call!',
  wrongArity: "Wrong number of arguments. Function '%s' expects %s got" +
      ' %s!',
  commandNotFound: "Command '%s' Not Found!",
  oneRPCWithIgnore: 'You can use only one rpc with ignoreSystemDescr' +
      'ibe or rpc without system.describe',
  oneInterpreterFunction: "You can't use more than one function (rpc " +
      'without system.describe or with option ignoreSystemDescribe cou' +
       'nts as one)',
  loginFunctionMissing: "You didn't specify a login function",
  noTokenError: 'Access denied (no token)',
  serverResponse: 'Server responded',
  wrongGreetings: 'Wrong value of greetings parameter',
  notWhileLogin: "You can't call `%s' function while in login",
  loginIsNotAFunction: 'Authenticate must be a function',
  canExitError: "You can't exit from main interpreter",
  invalidCompletion: 'Invalid completion',
  invalidSelector: 'Sorry, but terminal said that "%s" is not valid ' +
      'selector!',
  invalidTerminalId: 'Invalid Terminal ID',
  login: 'login',
  password: 'password',
  recursiveCall: 'Recursive call detected, skip'
}

More Examples:

Change logs:

v1.0.8 (2017-02-28)

  • fix paste in IE and Edge

v1.0.7 (2017-02-27)

  • fix exec when pause called in onInit
  • fix reverse search
  • fix 3 argument in completion error
  • fix login from hash for async JSON-RPC
  • fix focus(false)/disable in exec from hash
  • fix regression of pasting in MacOS
  • scroll to bottom in insert method
  • remove default extra property from interpreter (all properties are saved in interperter)
  • and make main options extra pass to intepterer not using extra property
  • fix completion when text have spaces (escaped or inside quotes)
  • fix dead keys on MacOSX (testing shortcuts now require keydown and keypress events)

v1.0.6 (2017-02-17)

  • fix AltGr on non US keyboard layouts

v1.0.5 (2017-02-11)

  • fix CTRL+D to delete forward one character
  • don't use user agent sniffing to get scroll element if terminal attached to body
  • fix & on French layout

v1.0.4 (2017-02-09)

  • fix keypress with key polyfill
  • fix CTRL+V in Firefox and IE
  • fix issue in jQuery >= 3.0
  • fix space, backspace, resize and arrows in IE
  • fix middle mouse paste on GNU/Linux
  • fix signature

v1.0.0 (2017-02-06)

  • simplify changing of terminal colors using css variables
  • always export history and import when importHistory option is true
  • add bar and underline cursor animations and a way to enable it with single css variable
  • recalcualate cols and rows on terminal resize (not only window)
  • request/response and onPush/onPop callbacks
  • all callbacks have terminal as `this` (terminal in parameter stay the same)
  • add option softPause to control pause visible option - it don't hide the prompt when set to true
  • add wordAutocomplete option (default true)
  • add complete and before_cursor api methods and use it for autocomplete
  • formatting for command line (you can't type formatting but you can use $.terminal.formatters to
  • format command you're writing)
  • new option formatters for echo (error method by default disable formatters)
  • interpeter and terminal accept extra option that can be use in onPop or onPush
  • add keymap option to cmd, terminal and interpreter where you can add shortcuts
  • clicking on character, in cmd plugin, move cursor to that character
  • BUGS fixed
  • completion function now have two arguments string and callback and terminal is in this
  • removed setInterpreter, parseArguments, splitArguments, parseCommand and splitCommand
  • if you execute keydown event manualy to trigger terminal/cmd shortcuts you need to pass key property with key name
  • see spec/terminalSpec.js file

v0.11.23 (2017-01-08)

  • add scrollBottomOffset option

v0.11.22 (2016-12-10)

  • scroll to bottom of the terminal when option scrollOnEcho is set to false but the terminal is at the bottom, add new api methods is_bottom and scroll_to_bottom.

v0.11.21 (2016-11-29)

  • don't scroll to terminal (using caret plugin) when it's disabled
  • don't convert links to formatting when raw option is true
  • fix getting data from local storage
  • remove spell check and auto capitalize from textarea

v0.11.18 (2016-11-22)

  • fix getting data from local storage
  • remove spell check and auto capitalize from textarea

v0.11.18 (2016-11-19)

  • fix input method

v0.11.17 (2016-11-15)

  • fix echo when line is short and have newlines
  • add global and echo option wrap to disable long line wrapping
  • don't send warning when mime for JSON-RPC is text/json

v0.11.15 (2016-11-12)

  • replace json_stringify with JSON.stringify
  • fix focus on desktop and mobile
  • allow only memory storage with memory option set to true

v0.11.12 (2016-11-05)

  • Add memory option that allow to not use localStorage nor Cookies

v0.11.12 (2016-11-03)

  • Fix focus on mobile

v0.11.11 (2016-10-08)

  • fix do not enable the terminal on click if it's frozen

v0.11.10 (2016-09-29)

  • fix focus on click

v0.11.9 (2016-09-23)

  • fix outputLimit option

v0.11.8 (2016-09-22)

  • add scrollOnEcho option

v0.11.7 (2016-09-18)

  • fix History::last

v0.11.6 (2016-09-16)

  • fix flush new API method $.terminal.last_id
  • fix focus on Android

v0.11.4 (2016-09-11)

  • allow to change completion using option API method

v0.11.3 (2016-09-06)

  • Add echoCommand option

v0.11.2 (2016-09-05)

  • allow to select text using double click

v0.10.11 (2016-06-06)

  • More fixes.

v0.10.10 (2016-06-02)

  • Escape brackets while echo completion strings

v0.10.9 (2016-05-12)

  • fix issue with jQuery Timers when page included another jQuery after initialization

v0.10.7 (2016-05-12)

  • fix if interpreter is an array and have function

v0.10.6 (2016-05-11)

  • Fix exit build in command and make all builtin case sensitive

v0.10.5 (2016-05-06)

  • Prevent infinite loop in terminal::active when no terminal

v0.10.3 (2016-05-03)

  • keepWords option to echo and words parameter in split_equal
  • Fix login for nested intepreters
  • Fix destroy of cmd plugin
  • Fix url regex for formatting
  • Fix saving commands in hash
  • Allow to disable completion in nested interpreter
  • Change position of cursor in reverse history search
  • Fix pasting in Firefox
  • Exec is adding command to history
  • Fix execHash in FireFox
  • Testsing terminal and cmd plugin + call from command line
  • Fix exec for nested login rpc command
  • Fix exec from hash if commands use pause/resume
  • Fix exec for build in commands
  • Fix other various exec from hash issues
  • Fix local logout and login command
  • mousewheel and resize options for interpreter
  • use MIT license
  • onExport and onImport events

v0.9.3 (2015-12-25)

  • Change settings to method
  • Fix process_commands and escape_regex
  • Fix login from hash
  • Fix raw echo
  • Don't print empty string after removing extended commands strings
  • Fix history_state method

v0.9.2 (2015-12-17)

  • Don't change command line history if ctrl key is pressed
  • Fix middle mouse copy on linux
  • fix resize issue

v0.9.1 (2015-12-13)

  • Add freeze and frozen API methods

v0.8.8 (2014-07-11)

  • Fix 2 json rpc bugs

v0.8.7 (2014-03-22)

  • Space after fully completed command

v0.8.6 (2014-03-13)

  • Space after fully completed command

v0.8.5 (2014-03-11)

  • Fix colors regex and names (from css), use case insensitive regex in formatting

v0.8.4 (2014-03-09)

  • Fix redraw lines on import_view, fix calculating rows

v0.8.3 (2014-03-07)

v0.8.2 (2014-02-26)

  • update

v0.8.1 (2014-02-24)

  • update

v0.8.0 (2014-02-24)

  • CTRL+L Clear terminal
  • Shift+Enter insert newline
  • Remove tabcompletion option (now completion can be true, array or function)
  • Add onRPCError callback
  • Interpreter can be an array
  • ignoreSystemDescribe option
  • Handle invalid JSON-RPC
  • CSS style for standalone cmd plugin
  • using CSS3 Animation for blinking if supported
  • Fix [0m
  • Better error handling (all messages are in $.terminal.defaults.strings)
  • Named colors for terminal formatting
  • expose settings and login function
  • more tools in $.terminal
  • paste kill text with CTRL+Y
  • paste text from selection using middle mouse button
  • Fix login, history and exec
  • Disable few things when in login function
  • All Strings are in $.terminal.defaults.strings
  • more functions in $.terminal object

v0.7.12 (2013-12-13)

  • Don't calcualte num of chars when terminal is not visible
  • Add rest property to parseCommand

v0.7.11 (2013-12-13)

  • Fix last history command

v0.7.10 (2013-11-30)

  • Fix reverse search

v0.7.9 (2013-11-29)

  • Don't show version when calling terminal from source file, allow for terminal without interpreter

v0.7.5 (2013-08-13)

  • Fix flush, add option linksNoReferer

v0.7.4 (2013-08-11)

  • Fix interpreter when there is not system.describe in JSON-RPC
  • Add method flush and fix refresh

 


This awesome jQuery plugin is developed by jcubic. For more Advanced Usages, please check the demo page or visit the official website.