handle control chars and make them visible. refs #20.

master
Markus Staab 12 years ago
parent 6818fed762
commit 35e1d6c9a1
  1. 19
      php-console.js
  2. 9
      styles.css

@ -72,11 +72,28 @@
if (window.localStorage) { if (window.localStorage) {
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>");
} }

@ -94,4 +94,13 @@ 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;
} }
Loading…
Cancel
Save