diff --git a/README.mdown b/README.mdown index af5630e..9f44a43 100644 --- a/README.mdown +++ b/README.mdown @@ -31,6 +31,7 @@ Changelog --------- - 1.1.0 + - Script execution is now done via an async js request, preventing die() and exception to mess up the entire console - Added a toggle button to expand/collapse all krumo sub-trees at once - 1.0.0 - Initial Public Release diff --git a/index.php b/index.php index cf873a8..77700c8 100644 --- a/index.php +++ b/index.php @@ -48,7 +48,13 @@ if (isset($_POST['code'])) { ob_start(); eval($code); - $debugOutput = '
'.ob_get_clean().'
'; + $debugOutput = ob_get_clean(); + + if (isset($_GET['js'])) { + header('Content-Type: text/plain'); + echo $debugOutput; + die('#end-php-console-output#'); + } } ?> @@ -63,7 +69,8 @@ if (isset($_POST['code'])) { - + +
diff --git a/loader.gif b/loader.gif new file mode 100644 index 0000000..f2a1bc0 Binary files /dev/null and b/loader.gif differ diff --git a/php-console.js b/php-console.js index 94300f4..2bbcb5d 100644 --- a/php-console.js +++ b/php-console.js @@ -36,7 +36,8 @@ $(function() { } caret = $(this).getCaret(); part = $(this).val().substring(0, caret); - if (matches = part.match(/(\r?\n +)[^\r\n]*$/)) { + matches = part.match(/(\r?\n +)[^\r\n]*$/); + if (matches) { $(this).val(function(idx, val) { return val.substring(0, caret) + matches[1] + val.substring(caret); }); @@ -56,6 +57,18 @@ $(function() { } }); + $('form').submit(function(e){ + e.preventDefault(); + $('div.output').html(' Loading ...'); + $.post('?js=1', $(this).serializeArray(), function(res) { + if (res.match(/#end-php-console-output#$/)) { + $('div.output').html(res.substring(0, res.length-24)); + } else { + $('div.output').html(res + "

Script ended unexpectedly."); + } + }); + }); + // adds a toggle button to expand/collapse all krumo sub-trees at once if ($('.krumo-expand').length > 0) { $('Toggle all') diff --git a/styles.css b/styles.css index 4976889..b1d1c1b 100644 --- a/styles.css +++ b/styles.css @@ -29,6 +29,10 @@ a { margin: 10px .4%; } +.output img.loader { + margin-bottom: -4px; +} + .output, textarea { -moz-border-radius: 5px; -webkit-border-radius: 5px;