From f54dc1291198df9e90ce6d6882b4cb130c1fbb04 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 31 Aug 2010 20:46:42 +0200 Subject: [PATCH] Script execution is now done via an async js request, preventing die() and exception to mess up the entire console --- README.mdown | 1 + index.php | 11 +++++++++-- loader.gif | Bin 0 -> 673 bytes php-console.js | 15 ++++++++++++++- styles.css | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 loader.gif 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 0000000000000000000000000000000000000000..f2a1bc0c6f545e20e631a96e8e92f9822e75d046 GIT binary patch literal 673 zcmZ?wbhEHb6krfw_{6~Q|Nnmm28Kh24mmkF0U1e2Nli^nlO|14{3qpHl$uzQnxasi zS(2fUn3Y(Olb@KPmzkHA&!G5|g@FsGT=74*pKD04vtxj(k)8oFBTz^Oh=E26FfcG1 zbL_hF&)}42ws10s6^G;;cE1^EoUR)U5A70}d2pLv!jVIT7j&Z~EblI3x0K*v_sV|m z0W=b9G$XP(CLnYCdK49;TX=SFc-G}o=oA=|U?{1O;Nu!CwW3C5Yw7*Bi4yD$3fCnb zwK+>}QdQ9sf*QnxY>*kpE+b{_Q;sJloS71)&(@kO!}mqf@1v(v;*8Y=G9S3kY~Cw# zY=t&c z;3~JK4HxB^lY(MD+sYeQ=t%XSSW;x^1M?dTvN=W^yNcAcy`HCte31C;)5xP%b~qs> zDP&4(%TBqBNGHwnryK;BdMI$fEg xd0mc!C@j^ZpLxYv4HmnPfI0THYuv<%+6iSmMn&w3dPGDfL1|=LY008wP(boU~ literal 0 HcmV?d00001 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;