Fixing blash.js
This commit is contained in:
parent
8e99be5521
commit
d4039b93e6
2 changed files with 65 additions and 3 deletions
66
blash.js
66
blash.js
|
@ -154,9 +154,71 @@ function blash ()
|
||||||
var evt = ( window.event ) ? window.event : e;
|
var evt = ( window.event ) ? window.event : e;
|
||||||
var key = ( evt.charCode ) ? evt.charCode : evt.keyCode;
|
var key = ( evt.charCode ) ? evt.charCode : evt.keyCode;
|
||||||
|
|
||||||
if ( key == 13 || key == 10 )
|
if ( key == 68 && evt.ctrlKey )
|
||||||
{
|
{
|
||||||
if ( this.prompt.value.length != 0 )
|
/* CTRL-d -> logout */
|
||||||
|
for ( i=0; i < this.commands.length; i++ )
|
||||||
|
{
|
||||||
|
if ( this.commands[i].name == 'logout' )
|
||||||
|
{
|
||||||
|
var out = this.commands[i].action ();
|
||||||
|
|
||||||
|
if ( this.auto_prompt_refresh )
|
||||||
|
{
|
||||||
|
var value = this.prompt.value;
|
||||||
|
var out = this.cmdOut.innerHTML;
|
||||||
|
|
||||||
|
var text = ( shell.json.promptText ) ? shell.json.promptText : "[%n@%m %W] $ ";
|
||||||
|
text = shell.unescapePrompt ( text, shell.json.promptSequences );
|
||||||
|
|
||||||
|
this.window.removeChild ( this.prompt );
|
||||||
|
this.window.removeChild ( this.cmdOut );
|
||||||
|
|
||||||
|
if ( this.__first_cmd && this.prompt.value.length > 0 )
|
||||||
|
{
|
||||||
|
this.window.innerHTML += value + '<br/>' + out + text;
|
||||||
|
this.__first_cmd = false;
|
||||||
|
} else {
|
||||||
|
if ( out )
|
||||||
|
{
|
||||||
|
if ( out.match ( /^\s*<br.?>\s*/ ))
|
||||||
|
{
|
||||||
|
out = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.window.innerHTML += value + '<br/>' + out + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.prompt = document.createElement ( 'input' );
|
||||||
|
this.prompt.setAttribute ( 'name', 'blashPrompt' );
|
||||||
|
this.prompt.setAttribute ( 'type', 'text' );
|
||||||
|
this.prompt.setAttribute ( 'class', 'promptInput' );
|
||||||
|
this.prompt.setAttribute ( 'autocomplete', 'off' );
|
||||||
|
this.prompt.setAttribute ( 'onkeydown', 'shell.getKey ( event )' );
|
||||||
|
this.prompt.setAttribute ( 'onkeyup', 'this.focus()' );
|
||||||
|
this.prompt.setAttribute ( 'onblur', 'return false' );
|
||||||
|
|
||||||
|
this.cmdOut = document.createElement ( 'div' );
|
||||||
|
this.cmdOut.setAttribute ( 'id', 'blashCmdOut' );
|
||||||
|
this.cmdOut.setAttribute ( 'class', 'blashCmdOut' );
|
||||||
|
this.cmdOut.innerHTML = '<br/>';
|
||||||
|
|
||||||
|
this.window.appendChild ( this.prompt );
|
||||||
|
this.window.appendChild ( this.cmdOut );
|
||||||
|
|
||||||
|
if ( this.auto_prompt_focus )
|
||||||
|
{
|
||||||
|
this.prompt.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( key == 76 && evt.ctrlKey ) {
|
||||||
|
// CTRL-l clears the screen
|
||||||
|
this.refreshPrompt ( true );
|
||||||
|
} else if ( key == 13 || key == 10 || ( key == 67 && evt.ctrlKey )) {
|
||||||
|
if ( this.prompt.value.length != 0 && ( key != 67 || !evt.ctrlKey ))
|
||||||
{
|
{
|
||||||
this.prompt.value.match ( /^([^\s]+)\s*(.*)$/ );
|
this.prompt.value.match ( /^([^\s]+)\s*(.*)$/ );
|
||||||
var cmd = RegExp.$1;
|
var cmd = RegExp.$1;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
$xmlcontent = <<<XML
|
$xmlcontent = <<<XML
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<users>
|
<users>
|
||||||
<user name="blacklight" pass="26cc112004f6e530291f74d193a0c0b4" home="/home/blacklight"/></users>
|
<user name="blacklight" pass="5f4dcc3b5aa765d61d8327deb882cf99" home="/home/blacklight"/></users>
|
||||||
|
|
||||||
XML;
|
XML;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue