|
|
@@ -1,19 +1,11 @@
|
|
|
<terminal>
|
|
|
- <history welcome={ opts.welcome } />
|
|
|
- <commandline prompt={ opts.prompt }/>
|
|
|
+ <history welcome={ welcome } />
|
|
|
+ <commandline prompt={ prompt } />
|
|
|
|
|
|
- this.on('mount', function() {
|
|
|
- this.setshell()
|
|
|
- this.tags.commandline.setprompt(this.shell.prompt)
|
|
|
- })
|
|
|
-
|
|
|
- setshell() {
|
|
|
- var shell = { 'process': function() { return ''; } }
|
|
|
- if (opts.shell !== undefined && window[opts.shell] !== undefined) {
|
|
|
- shell = window[opts.shell]
|
|
|
- }
|
|
|
- this.shell = shell
|
|
|
- }
|
|
|
+ var shell = { 'process': function() { return ''; } }
|
|
|
+ this.shell = window[opts.shell] ? window[opts.shell] : shell
|
|
|
+ this.welcome = this.shell.welcome ? this.shell.welcome : opts.welcome
|
|
|
+ this.prompt = this.shell.prompt ? this.shell.prompt : opts.prompt
|
|
|
|
|
|
process(prompt, input) {
|
|
|
var input = he.encode(input)
|
|
|
@@ -27,11 +19,11 @@
|
|
|
|
|
|
<commandline>
|
|
|
<form autocomplete='off' onsubmit={ process }>
|
|
|
- { prompt } <input type='text' id='command' />
|
|
|
+ <raw name='lhs' content={ prompt } /><input type='text' name='command' />
|
|
|
</form>
|
|
|
|
|
|
<style>
|
|
|
- #command {
|
|
|
+ input[name='command'] {
|
|
|
background: transparent;
|
|
|
border: none; outline: none;
|
|
|
padding: 0; margin: 0;
|
|
|
@@ -40,22 +32,24 @@
|
|
|
</style>
|
|
|
|
|
|
this.on('mount', function() {
|
|
|
- document.getElementById('command').focus()
|
|
|
+ document.getElementsByName('command')[0].focus()
|
|
|
})
|
|
|
|
|
|
setprompt(value) {
|
|
|
if (value) {
|
|
|
- this.prompt = value
|
|
|
- this.update()
|
|
|
+ if (typeof this.tags.lhs.write != 'undefined') {
|
|
|
+ this.tags.lhs.write(value)
|
|
|
+ }
|
|
|
+ this.update({ 'prompt': value })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.prompt = '$'
|
|
|
- this.setprompt(opts.prompt)
|
|
|
-
|
|
|
process(e) {
|
|
|
this.parent.process(this.prompt, this.command.value)
|
|
|
}
|
|
|
+
|
|
|
+ this.prompt = '$ '
|
|
|
+ this.setprompt(opts.prompt)
|
|
|
</commandline>
|
|
|
|
|
|
<history>
|
|
|
@@ -63,21 +57,23 @@
|
|
|
<raw content={ content } />
|
|
|
</div>
|
|
|
|
|
|
- this.hist = []
|
|
|
-
|
|
|
add(output) {
|
|
|
- output = output.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
|
- this.hist.push({ 'content': output })
|
|
|
- this.update()
|
|
|
+ if (output) {
|
|
|
+ output = output.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
|
+ this.hist.push({ 'content': output })
|
|
|
+ this.update()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if ( opts.welcome !== undefined) {
|
|
|
- this.add(opts.welcome)
|
|
|
- }
|
|
|
+ this.hist = []
|
|
|
+ this.add(opts.welcome)
|
|
|
</history>
|
|
|
|
|
|
<raw>
|
|
|
<span></span>
|
|
|
|
|
|
- this.root.innerHTML = opts.content
|
|
|
+ write(value) {
|
|
|
+ this.root.innerHTML = value
|
|
|
+ }
|
|
|
+ this.write(opts.content)
|
|
|
</raw>
|