Extensible jQuery Based Command Line Emulator - Ptty
| File Size: | 14.4 KB |
|---|---|
| Views Total: | 10238 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
Ptty is another jQuery based terminal emulator to create customizable and nice-looking command line interpreters on your webpage/application. You can easily add your own commands via $.register_command() method. Fully stylable via CSS.
Basic usage:
1. Include the jQuery Ptty plugin's script and stylesheet in the document. Make sure the Ptty.jquery.js file is loaded after the jQuery JavaScript library.
<link rel="stylesheet" href="css/Ptty.css"> <script src="//code.jquery.com/jquery.min.js"></script> <script src="js/Ptty.jquery.js"></script>
2. Create a container element where you wish to embed the terminal emulator.
<div id="terminal"></div>
3. Call the plugin on the container element and register your commands.
// initialize
$('#terminal').Ptty();
// register a command
$.register_command(
// command name
'jqueryscript',
// command description
'jQueryscript.net',
// command usage
'jqueryscript',
// command dispatch
''
);
4. Available options to customize the terminal emulator.
$('#terminal').Ptty({
// The HTTP Method that will be used for Ajax Requests
ajax_options : {
url : window.location.pathname,
type : 'POST'
},
// The GET/POST parameter that should be used to make requests
param : 'cmd',
// The Primary Prompt (it's better to edit this using css)
ps : '$',
// Caret (the cursor)
caret : '\u25ae', // Black Vertical Rectangle ▮
caret_blink : 800,
// use native css and default theme name.
native_css : true,
theme : 'boring',
// Register help, clear and history commands
native_cmds : true,
// Is Autocomplete feature Enabled
autocomplete : true,
// Number of entries to be stored in history (0 = off)
history_max : 800,
// Autofocus on input on load
autofocus : true,
// Run this function before every command
before_cmd : false,
// Run this function after every command
after_cmd : false,
// Language
i18n : {
// Message to be shown when the terminal is first
welcome : 'Ptty ('+version+').<br> Type <b>help</b> to list the available commands.',
// When command is not found: "CMD" will be replaced
error_not_found : 'Command not found.',
// If command method is not valid
error_bad_method : 'Invalid command method.',
// Ajax response failed
error_ajax : 'Server error.'
}
});
Changelog:
2018-08-01
- JS updated
2016-04-28
- Temp-fixed the loading element.
2016-04-27
- autofocus on multiple instances
2016-04-25
- Scroll bug reappeared, and was fixed again. CSS fixes, method adition.
2016-04-24
- v0.0.5
2015-09-18
- v0.0.4
2015-02-14
- Fixed a bug
2015-01-27
- Fixed a bug previenting subroutine ps to work.
2015-01-15
- Fixed css overflow in PS
2015-01-13
- minor css change
This awesome jQuery plugin is developed by pachanka. For more Advanced Usages, please check the demo page or visit the official website.









