diff --git a/blash.css b/blash.css index 73b7ee5..8ea5f40 100644 --- a/blash.css +++ b/blash.css @@ -4,7 +4,6 @@ body color : #888; font-family : Terminus, courier, monospace, fixed; font-size : 13px; - tabindex : -1; } pre @@ -13,16 +12,7 @@ pre font-size : 13px; } -input.promptInput -{ - background-color : black; - border : 0; - color : #888; - font-family : Terminus, courier, monospace, fixed; - font-size : 13px; - width : 500px; -} - +input.promptInput, input.password { background-color : black; @@ -31,6 +21,7 @@ input.password font-family : Terminus, courier, monospace, fixed; font-size : 13px; width : 500px; + outline: none; } div#blashWindow @@ -41,7 +32,6 @@ div#blashWindow /* padding : 10px; */ /* border : 1px solid #888; */ overflow : auto; - tabindex : -1; } span.directory @@ -57,13 +47,11 @@ span.link a { color : green; - tabindex : -1; } a:visited { color : green; - tabindex : -1; } span.syntax diff --git a/commands/cat.json b/commands/cat.js similarity index 100% rename from commands/cat.json rename to commands/cat.js diff --git a/commands/cd.json b/commands/cd.js similarity index 84% rename from commands/cd.json rename to commands/cd.js index 2ecf1cc..623c3e6 100644 --- a/commands/cd.json +++ b/commands/cd.js @@ -14,17 +14,13 @@ { shell.auto_prompt_focus = false; shell.auto_prompt_refresh = false; - - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + + var users_php = './modules/users/users.php'; params = 'action=gethome'; var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); - http.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader ( "Content-length", params.length ); http.setRequestHeader ( "Connection", "close" ); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/chmod.json b/commands/chmod.js similarity index 86% rename from commands/chmod.json rename to commands/chmod.js index d6ba0cc..5c4bcf4 100644 --- a/commands/chmod.json +++ b/commands/chmod.js @@ -29,8 +29,7 @@ perms |= (( perm_string.match ( 'w' )) ? 1 : 0 ); resource = shell.expandPath ( resource ); - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=chmod&resource=' + escape ( resource ) + '&perms=' + escape ( perms.toString() ); if ( userlist ) @@ -41,9 +40,6 @@ var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader( "Content-length", params.length ); - http.setRequestHeader( "Connection", "close" ); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/clear.json b/commands/clear.js similarity index 100% rename from commands/clear.json rename to commands/clear.js diff --git a/commands/cp.json b/commands/cp.js similarity index 87% rename from commands/cp.json rename to commands/cp.js index d05b87d..e9f5718 100644 --- a/commands/cp.json +++ b/commands/cp.js @@ -45,16 +45,12 @@ shell.auto_prompt_refresh = false; - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=cp&src=' + escape ( src ) + '&dest=' + escape ( dest ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/echo.json b/commands/echo.js similarity index 100% rename from commands/echo.json rename to commands/echo.js diff --git a/commands/eval.json b/commands/eval.js similarity index 100% rename from commands/eval.json rename to commands/eval.js diff --git a/commands/find.json b/commands/find.js similarity index 100% rename from commands/find.json rename to commands/find.js diff --git a/commands/grep.json b/commands/grep.js similarity index 100% rename from commands/grep.json rename to commands/grep.js diff --git a/commands/ln.json b/commands/ln.js similarity index 88% rename from commands/ln.json rename to commands/ln.js index a6e3445..850e933 100644 --- a/commands/ln.json +++ b/commands/ln.js @@ -49,18 +49,14 @@ link_type = 'local'; } - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; shell.auto_prompt_refresh = false; link = shell.expandPath ( link ); params = 'action=link&resource=' + escape ( res ) + '&link=' + escape ( link ) + '&type=' + escape ( link_type ); - + var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader( "Content-length", params.length ); - http.setRequestHeader( "Connection", "close" ); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/logout.json b/commands/logout.js similarity index 74% rename from commands/logout.json rename to commands/logout.js index a3902f3..e96a1ef 100644 --- a/commands/logout.json +++ b/commands/logout.js @@ -24,15 +24,12 @@ shell.user = shell.json.user; document.cookie = ''; - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=logout'; var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader( "Content-length", params.length ); - http.setRequestHeader( "Connection", "close" ); http.onreadystatechange = function () { @@ -45,9 +42,7 @@ http.send ( params ); shell.path = shell.json.basepath; - var json_config = window.location.href; - json_config = json_config.replace ( /\/([a-zA-Z_\.]+)$/, '/system/blash.json' ); - + var json_config = './system/config.js'; var http2 = new XMLHttpRequest(); http2.open ( "GET", json_config, true ); diff --git a/commands/ls.json b/commands/ls.js similarity index 100% rename from commands/ls.json rename to commands/ls.js diff --git a/commands/man.json b/commands/man.js similarity index 100% rename from commands/man.json rename to commands/man.js diff --git a/commands/mkdir.json b/commands/mkdir.js similarity index 79% rename from commands/mkdir.json rename to commands/mkdir.js index 6dc7844..08a3d9c 100644 --- a/commands/mkdir.json +++ b/commands/mkdir.js @@ -17,16 +17,12 @@ shell.auto_prompt_refresh = false; arg = shell.expandPath ( arg ); - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=mkdir&dir=' + escape ( arg ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/mv.json b/commands/mv.js similarity index 87% rename from commands/mv.json rename to commands/mv.js index 8c54934..b875fc7 100644 --- a/commands/mv.json +++ b/commands/mv.js @@ -45,16 +45,12 @@ shell.auto_prompt_refresh = false; - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=mv&src=' + escape ( src ) + '&dest=' + escape ( dest ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/nano.json b/commands/nano.js similarity index 95% rename from commands/nano.json rename to commands/nano.js index 7dd1fb5..bb42cea 100644 --- a/commands/nano.json +++ b/commands/nano.js @@ -39,17 +39,13 @@ } } - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=getperms&resource=' + ( newfile ? escape ( parent_dir['path'] ) : escape ( arg )); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader ("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader ("Content-length", params.length); - http.setRequestHeader ("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) @@ -395,16 +391,12 @@ "bufferSave" : function () { - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=set_content&file=' + escape ( shell.fname ) + '&content=' + escape ( document.getElementById ( 'editor_window' ).value ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader ("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader ("Content-length", params.length); - http.setRequestHeader ("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/passwd.json b/commands/passwd.js similarity index 93% rename from commands/passwd.json rename to commands/passwd.js index d584e31..5ef9654 100644 --- a/commands/passwd.json +++ b/commands/passwd.js @@ -53,8 +53,7 @@ { shell.cmdOut.innerHTML = 'The passwords do not match'; } else { - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=changepwd&user=' + escape ( shell.newuser ) + '&newpass=' + md5 ( password.value ); if ( shell.curUser != 'root' ) @@ -65,9 +64,6 @@ var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) @@ -111,9 +107,6 @@ var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader( "Content-length", params.length ); - http.setRequestHeader( "Connection", "close" ); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/pwd.json b/commands/pwd.js similarity index 100% rename from commands/pwd.json rename to commands/pwd.js diff --git a/commands/rm.json b/commands/rm.js similarity index 79% rename from commands/rm.json rename to commands/rm.js index 3b1f307..1c892ea 100644 --- a/commands/rm.json +++ b/commands/rm.js @@ -17,16 +17,12 @@ shell.auto_prompt_refresh = false; arg = shell.expandPath ( arg ); - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=rm&file=' + escape ( arg ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/rmdir.json b/commands/rmdir.js similarity index 80% rename from commands/rmdir.json rename to commands/rmdir.js index 0101379..9c704f3 100644 --- a/commands/rmdir.json +++ b/commands/rmdir.js @@ -17,15 +17,12 @@ shell.auto_prompt_refresh = false; arg = shell.expandPath ( arg ); - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=rmdir&dir=' + escape ( arg ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); http.onreadystatechange = function () { diff --git a/commands/su.json b/commands/su.js similarity index 88% rename from commands/su.json rename to commands/su.js index 31f9103..a601720 100644 --- a/commands/su.json +++ b/commands/su.js @@ -55,15 +55,12 @@ if ( key == 13 && password.value.length > 0 ) { - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=login&user=' + escape ( shell.newuser ) + '&pass=' + md5 ( password.value ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader ( "Content-length", params.length ); - http.setRequestHeader ( "Connection", "close" ); http.onreadystatechange = function () { @@ -78,8 +75,6 @@ var xml2 = new XMLHttpRequest(); xml2.open ( "POST", users_php, true ); xml2.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" ); - xml2.setRequestHeader ( "Content-length", params.length ); - xml2.setRequestHeader ( "Connection", "close" ); params = 'action=gethome'; xml2.onreadystatechange = function () @@ -94,14 +89,9 @@ shell.user = shell.json.user; } - shell.files_json = window.location.href; - - if ( shell.has_users ) - { - shell.files_json = shell.files_json.replace ( /\/([a-zA-Z_\.]+)$/, '/modules/users/files.php' ); - } else { - shell.files_json = shell.files_json.replace ( /\/([a-zA-Z_\.]+)$/, '/system/files.json' ); - } + shell.files_json = shell.has_users ? + './modules/users/files.php' : + './system/files.json'; var http3 = new XMLHttpRequest(); http3.open ( "GET", shell.files_json, true ); diff --git a/commands/touch.json b/commands/touch.js similarity index 80% rename from commands/touch.json rename to commands/touch.js index 3098314..9ccf14a 100644 --- a/commands/touch.json +++ b/commands/touch.js @@ -17,16 +17,12 @@ shell.auto_prompt_refresh = false; arg = shell.expandPath ( arg ); - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=touch&file=' + escape ( arg ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/useradd.json b/commands/useradd.js similarity index 91% rename from commands/useradd.json rename to commands/useradd.js index 248eae6..b9f75c1 100644 --- a/commands/useradd.json +++ b/commands/useradd.js @@ -31,7 +31,6 @@ var key = ( evt.charCode ) ? evt.charCode : evt.keyCode; var password = document.getElementsByName ( "password" )[0]; var repeatPassword = document.getElementsByName ( "repeatPassword" )[0]; - var repeatPasswordText = document.getElementById ( "repeatPasswordText" ); if ( key == 13 && password.value.length > 0 ) { @@ -45,16 +44,12 @@ return false; } - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=add&user=' + escape ( shell.newuser ) + '&pass=' + md5 ( password.value ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/userdel.json b/commands/userdel.js similarity index 76% rename from commands/userdel.json rename to commands/userdel.js index 91b4a71..46c6d50 100644 --- a/commands/userdel.json +++ b/commands/userdel.js @@ -15,16 +15,12 @@ shell.auto_prompt_refresh = false; - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=del&user=' + escape ( arg ); var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", params.length); - http.setRequestHeader("Connection", "close"); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/users.json b/commands/users.js similarity index 73% rename from commands/users.json rename to commands/users.js index 9eb1dca..bc6910b 100644 --- a/commands/users.json +++ b/commands/users.js @@ -8,17 +8,13 @@ "action" : function ( arg ) { - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=list'; shell.auto_prompt_refresh = false; var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader( "Content-length", params.length ); - http.setRequestHeader( "Connection", "close" ); - http.onreadystatechange = function () { if ( http.readyState == 4 && http.status == 200 ) diff --git a/commands/wget.json b/commands/wget.js similarity index 100% rename from commands/wget.json rename to commands/wget.js diff --git a/commands/whoami.json b/commands/whoami.js similarity index 81% rename from commands/whoami.json rename to commands/whoami.js index f161e4e..fb8f08d 100644 --- a/commands/whoami.json +++ b/commands/whoami.js @@ -26,15 +26,12 @@ } else { shell.auto_prompt_refresh = false; - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; params = 'action=getuser'; var http = new XMLHttpRequest(); http.open ( "POST", users_php, true ); http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); - http.setRequestHeader( "Content-length", params.length ); - http.setRequestHeader( "Connection", "close" ); http.onreadystatechange = function () { diff --git a/index.html b/index.html index 7e56761..5b41a82 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,12 @@ - -
+ +
diff --git a/system/blash.js b/system/blash.js index b3b454f..db9ac6e 100644 --- a/system/blash.js +++ b/system/blash.js @@ -2,8 +2,9 @@ * * * blash - An AJAX CMS for browsing your web site like a shell * * * - * by BlackLight , (C) 2010 * - * Web: http://0x00.ath.cx * + * by Fabio "BlackLight" Manganiello * + * (C) 2010, 2022 * + * Web: https://blash.fabiomanganiello.com * * Released under GPL licence v.3 * * * *****************************************************************/ @@ -50,7 +51,36 @@ function blash () this.promptText = document.getElementById ( "promptText" ); /** Input field used as prompt */ - this.prompt = document.getElementsByName ( "blashPrompt" )[0]; + this.prompt = document.body.querySelector ( "[name=blashPrompt]" ); + this.getPrompt = function () { + let prompt = document.body.querySelector ( "[name=blashPrompt]" ); + if (!prompt) { + prompt = document.createElement ( 'input' ); + prompt.setAttribute ( 'name', 'blashPrompt' ); + prompt.setAttribute ( 'type', 'text' ); + prompt.setAttribute ( 'class', 'promptInput' ); + prompt.setAttribute ( 'autocomplete', 'off' ); + prompt.setAttribute ( 'onkeydown', 'shell.getKey ( event )' ); + prompt.setAttribute ( 'onkeyup', 'this.focus()' ); + prompt.setAttribute ( 'onblur', 'return false' ); + + this.cmdOut = document.createElement ( 'div' ); + this.cmdOut.setAttribute ( 'id', 'blashCmdOut' ); + this.cmdOut.setAttribute ( 'class', 'blashCmdOut' ); + this.cmdOut.innerHTML = '
'; + + this.window.appendChild ( prompt ); + this.window.appendChild ( this.cmdOut ); + this.prompt = prompt + + if ( this.auto_prompt_focus ) + { + prompt.focus(); + } + } + + return prompt; + }; /** Counter of the open tags when replacing the colours in the command prompt */ this.__open_spans = 0; @@ -73,9 +103,7 @@ function blash () this.loadCommand = function ( cmd ) { - var cmd_file = window.location.href; - cmd_file = cmd_file.replace ( /\/([a-zA-Z_\.]+)$/, '/commands/' + cmd + ".json" ); - + var cmd_file = './commands/' + cmd + '.js' var http = new XMLHttpRequest(); http.open ( "GET", cmd_file, true ); @@ -96,15 +124,11 @@ function blash () { this.user = RegExp.$1; var params = 'action=getuser'; - var users_php = window.location.href; - users_php = users_php.replace ( /\/([a-zA-Z_\.]+)$/, '/modules/users/users.php' ); + var users_php = './modules/users/users.php'; var xml = new XMLHttpRequest(); xml.open ( "POST", users_php, true ); xml.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" ); - xml.setRequestHeader ( "Content-length", params.length ); - xml.setRequestHeader ( "Connection", "close" ); - xml.onreadystatechange = function () { if ( xml.readyState == 4 && xml.status == 200 ) @@ -123,8 +147,6 @@ function blash () var xml2 = new XMLHttpRequest(); xml2.open ( "POST", users_php, true ); xml2.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" ); - xml2.setRequestHeader ( "Content-length", params.length ); - xml2.setRequestHeader ( "Connection", "close" ); params = 'action=gethome'; xml2.onreadystatechange = function () @@ -147,11 +169,9 @@ function blash () this.prompt.focus(); - var json_config = window.location.href; - json_config = json_config.replace ( /\/([a-zA-Z_\.]+)$/, '/system/blash.json' ); - + var config_url = './system/config.js'; var http = new XMLHttpRequest(); - http.open ( "GET", json_config, true ); + http.open ( "GET", config_url, true ); http.onreadystatechange = function () { @@ -193,15 +213,7 @@ function blash () } } - shell.files_json = window.location.href; - - if ( shell.has_users ) - { - shell.files_json = shell.files_json.replace ( /\/([a-zA-Z_\.]+)$/, '/modules/users/files.php' ); - } else { - shell.files_json = shell.files_json.replace ( /\/([a-zA-Z_\.]+)$/, '/system/files.json' ); - } - + shell.files_json = shell.has_users ? './modules/users/files.php' : './system/files.json'; var http2 = new XMLHttpRequest(); http2.open ( "GET", shell.files_json, true ); @@ -363,27 +375,7 @@ function blash () this.window.innerHTML += value + '
' + 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 = '
'; - - this.window.appendChild ( this.prompt ); - this.window.appendChild ( this.cmdOut ); - - if ( this.auto_prompt_focus ) - { - this.prompt.focus(); - } + this.prompt = this.getPrompt(); } } } @@ -400,7 +392,7 @@ function blash () var outDiv = document.createElement ( 'span' ); outDiv.innerHTML = text; - this.window.insertBefore ( outDiv, document.getElementsByName ( "blashPrompt" )[0] ); + this.window.insertBefore ( outDiv, this.getPrompt() ); return false; } else if ( key == 13 || key == 10 || ( key == 67 && evt.ctrlKey )) { @@ -735,14 +727,15 @@ function blash () if (( this.prompt = document.getElementById ( "promptText" ))) { - value = this.prompt.innerHTML + (( document.getElementsByName ( 'blashPrompt' )[0].value.length > 0 ) ? - ' ' + document.getElementsByName ( 'blashPrompt' )[0].value : '' ); - this.prompt.parentNode.removeChild ( document.getElementsByName ( 'blashPrompt' )[0] ); + const prompt = this.getPrompt(); + value = prompt.innerHTML + (( prompt.value.length > 0 ) ? + ' ' + prompt.value : '' ); + this.prompt.parentNode.removeChild ( prompt ); } - if ( document.getElementsByName ( 'blashPrompt' )[0] ) + if ( this.getPrompt() ) { - document.getElementsByName ( 'blashPrompt' )[0].parentNode.removeChild ( document.getElementsByName ( 'blashPrompt' )[0] ); + this.getPrompt().parentNode.removeChild ( this.getPrompt() ); } if (( this.cmdOut = document.getElementById ( "blashCmdOut" ))) @@ -963,9 +956,7 @@ function blash () */ this.refreshFiles = function () { - var files_config = window.location.href; - files_config = files_config.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/files.php' ); - + var files_config = './modules/users/files.php'; var http = new XMLHttpRequest(); http.open ( "GET", files_config, true ); diff --git a/system/blash.json b/system/config.js similarity index 86% rename from system/blash.json rename to system/config.js index 3e4881b..b59f12a 100644 --- a/system/blash.json +++ b/system/config.js @@ -4,13 +4,14 @@ { "banner" : "blash version 0.1
" + - "Copyright (C) 2010 BlackLight <blacklight@autistici.org>" + + "by Fabio \"BlackLight\" Manganiello <info@fabiomanganiello.com>>" + + "
Copyright (C) 2010, 2022" + "
Licence GPLv3+: GNU GPL version 3 or later " + "<" + "http://gnu.org/licences/gpl.html>
" + "Source code available at " + - "https://github.com/BlackLight/blash

" + + "href=\"https://git.platypush.tech/blacklight/blash\">" + + "https://git.platypush.tech/blacklight/blash

" + "This is free software; you are free to change and " + "redistribuite it.
There is NO WARRANTY, to the " + "extent permitted by law.
" +