Permalink
Browse files

Script execution is now done via an async js request, preventing die(…

…) and exception to mess up the entire console
  • Loading branch information...
1 parent 300372e commit f54dc1291198df9e90ce6d6882b4cb130c1fbb04 @Seldaek committed Aug 31, 2010
Showing with 28 additions and 3 deletions.
  1. +1 −0 README.mdown
  2. +9 −2 index.php
  3. BIN loader.gif
  4. +14 −1 php-console.js
  5. +4 −0 styles.css
View
@@ -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
View
@@ -48,7 +48,13 @@
ob_start();
eval($code);
- $debugOutput = '<div class="output">'.ob_get_clean().'</div>';
+ $debugOutput = ob_get_clean();
+
+ if (isset($_GET['js'])) {
+ header('Content-Type: text/plain');
+ echo $debugOutput;
+ die('#end-php-console-output#');
+ }
}
?>
@@ -63,7 +69,8 @@
<script type="text/javascript" src="php-console.js"></script>
</script>
</head>
- <body><?php echo $debugOutput ?>
+ <body>
+ <div class="output"><?php echo $debugOutput ?></div>
<form method="POST" action="">
<textarea cols="100" rows="20" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : null) ?></textarea>
<input type="submit" name="subm" value="Try this!" />
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -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('<img src="loader.gif" class="loader" alt="" /> 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 + "<br /><br /><em>Script ended unexpectedly.</em>");
+ }
+ });
+ });
+
// adds a toggle button to expand/collapse all krumo sub-trees at once
if ($('.krumo-expand').length > 0) {
$('<a class="expand" href="#">Toggle all</a>')
View
@@ -29,6 +29,10 @@ a {
margin: 10px .4%;
}
+.output img.loader {
+ margin-bottom: -4px;
+}
+
.output, textarea {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;

0 comments on commit f54dc12

Please sign in to comment.