|
@@ -2,7 +2,8 @@
|
|
|
* # Terminal Riot Tag
|
|
* # Terminal Riot Tag
|
|
|
*
|
|
*
|
|
|
* Provides a pretend commandline interface, capable of displaying output from a
|
|
* Provides a pretend commandline interface, capable of displaying output from a
|
|
|
- * "Shell" javascript object.
|
|
|
|
|
|
|
+ * "Shell" javascript class. Multiple terminal tags can be used on a page,
|
|
|
|
|
+ * acting independently of one another.
|
|
|
*
|
|
*
|
|
|
* ## Defaults
|
|
* ## Defaults
|
|
|
*
|
|
*
|
|
@@ -11,7 +12,7 @@
|
|
|
*
|
|
*
|
|
|
* ## Usage
|
|
* ## Usage
|
|
|
*
|
|
*
|
|
|
- * <terminal shell='jsobject' welcome='text' prompt='text'></terminal>
|
|
|
|
|
|
|
+ * <terminal shell='jsclass' welcome='text' prompt='text'></terminal>
|
|
|
*
|
|
*
|
|
|
* <script src='riot+compiler.min.js'></script>
|
|
* <script src='riot+compiler.min.js'></script>
|
|
|
* <script src='he.js'></script>
|
|
* <script src='he.js'></script>
|
|
@@ -24,23 +25,22 @@
|
|
|
* - riot.js (http://riotjs.com/)
|
|
* - riot.js (http://riotjs.com/)
|
|
|
* - he.js (https://github.com/mathiasbynens/he) for HTML Entity conversion.
|
|
* - he.js (https://github.com/mathiasbynens/he) for HTML Entity conversion.
|
|
|
*
|
|
*
|
|
|
- * ## Making a Shell javascript object
|
|
|
|
|
|
|
+ * ## Making a Shell javascript class
|
|
|
*
|
|
*
|
|
|
- * Shell objects must be defined before the tag is mounted. Shells can keep
|
|
|
|
|
|
|
+ * Shell class must be defined before the tag is mounted. Shells can keep
|
|
|
* prompt character and welcome message settings, and must define a `process()`
|
|
* prompt character and welcome message settings, and must define a `process()`
|
|
|
* function. Here is the structure of a minimumal shell that does nothing:
|
|
* function. Here is the structure of a minimumal shell that does nothing:
|
|
|
*
|
|
*
|
|
|
- * // Contents of shell.js
|
|
|
|
|
- * function() shell() {
|
|
|
|
|
|
|
+ * // Contents of myshell.js
|
|
|
|
|
+ * function() myshell() {
|
|
|
* this.prompt = ''
|
|
* this.prompt = ''
|
|
|
* this.welcome = ''
|
|
* this.welcome = ''
|
|
|
* this.process = function(input) {
|
|
* this.process = function(input) {
|
|
|
* return ''
|
|
* return ''
|
|
|
* }
|
|
* }
|
|
|
* }
|
|
* }
|
|
|
- * var myshell = new shell()
|
|
|
|
|
*
|
|
*
|
|
|
- * // Shell object used by Terminal Riot Tag
|
|
|
|
|
|
|
+ * // Shell class used by Terminal Riot Tag in index.html
|
|
|
* <terminal shell='myshell'></terminal>
|
|
* <terminal shell='myshell'></terminal>
|
|
|
*
|
|
*
|
|
|
* ## Special Return Values
|
|
* ## Special Return Values
|
|
@@ -57,7 +57,7 @@
|
|
|
|
|
|
|
|
// Take defaults from shell, otherwise take from `<terminal>` options.
|
|
// Take defaults from shell, otherwise take from `<terminal>` options.
|
|
|
var shell = { 'process': function() { return ''; } }
|
|
var shell = { 'process': function() { return ''; } }
|
|
|
- this.shell = window[opts.shell] ? window[opts.shell] : shell
|
|
|
|
|
|
|
+ this.shell = window[opts.shell] ? new window[opts.shell] : shell
|
|
|
this.welcome = this.shell.welcome ? this.shell.welcome : opts.welcome
|
|
this.welcome = this.shell.welcome ? this.shell.welcome : opts.welcome
|
|
|
this.prompt = this.shell.prompt ? this.shell.prompt : opts.prompt
|
|
this.prompt = this.shell.prompt ? this.shell.prompt : opts.prompt
|
|
|
|
|
|