Merge remote-tracking branch 'staabm/control-chars'

This commit is contained in:
Jordi Boggiano
2013-07-03 09:40:35 +02:00
2 changed files with 27 additions and 1 deletions
+18 -1
View File
@@ -73,10 +73,27 @@
localStorage.setItem('phpCode', editor.getSession().getValue()); localStorage.setItem('phpCode', editor.getSession().getValue());
} }
var controlChars = {
'NUL' : /\x00/g,
'SOH' : /\x01/g,
'STX' : /\x02/g,
'ETX' : /\x03/g,
'EOT' : /\x04/g,
'ENQ' : /\x05/g,
'ACK' : /\x06/g,
'BEL' : /\x07/g,
'BS' : /\x08/g,
'SUB' : /\x1A/g,
};
// eval server-side // eval server-side
$.post('?js=1', { code: editor.getSession().getValue() }, function (res) { $.post('?js=1', { code: editor.getSession().getValue() }, function (res) {
if (res.match(/#end-php-console-output#$/)) { if (res.match(/#end-php-console-output#$/)) {
$('div.output').html(res.substring(0, res.length - 24)); var result = res.substring(0, res.length - 24);
for (var k in controlChars) {
result = result.replace(controlChars[k], '<span class="control-char">'+ k +'</span>');
}
$('div.output').html(result);
} else { } else {
$('div.output').html(res + "<br /><br /><em>Script ended unexpectedly.</em>"); $('div.output').html(res + "<br /><br /><em>Script ended unexpectedly.</em>");
} }
+9
View File
@@ -95,3 +95,12 @@ a {
.footer a { .footer a {
color: #aaa; color: #aaa;
} }
.krumo-root .control-char {
background: #000;
color: #fff;
margin-left: 2px;
margin-right: 2px;
-webkit-border-radius: 5px;
border-radius: 5px;
}