Skip to content

Commit 42f4a65

Browse files
committed
Add more control chars and adjust styles a bit
1 parent 87c3912 commit 42f4a65

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

README.mdown

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Jordi Boggiano - <[email protected]><br />
3333
Changelog
3434
---------
3535

36+
- 1.4.0
37+
- Added control-char escaping to make them more visible
3638
- 1.3.0
3739
- Added code persistence across sessions in localStorage + a reset button
3840
- 1.2.3

index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
die('ERR/401 Go Away');
2424
}
2525

26-
define('PHP_CONSOLE_VERSION', '1.3.0');
26+
define('PHP_CONSOLE_VERSION', '1.4.0');
2727
require 'krumo/class.krumo.php';
2828

2929
ini_set('log_errors', 0);

php-console.js

+31-14
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,44 @@
7272
if (window.localStorage) {
7373
localStorage.setItem('phpCode', editor.getSession().getValue());
7474
}
75-
75+
7676
var controlChars = {
77-
'NUL' : /\x00/g,
78-
'SOH' : /\x01/g,
79-
'STX' : /\x02/g,
80-
'ETX' : /\x03/g,
81-
'EOT' : /\x04/g,
82-
'ENQ' : /\x05/g,
83-
'ACK' : /\x06/g,
84-
'BEL' : /\x07/g,
85-
'BS' : /\x08/g,
86-
'SUB' : /\x1A/g,
77+
'NUL' : /\x00/g, // Null char
78+
'SOH' : /\x01/g, // Start of Heading
79+
'STX' : /\x02/g, // Start of Text
80+
'ETX' : /\x03/g, // End of Text
81+
'EOT' : /\x04/g, // End of Transmission
82+
'ENQ' : /\x05/g, // Enquiry
83+
'ACK' : /\x06/g, // Acknowledgment
84+
'BEL' : /\x07/g, // Bell
85+
'BS' : /\x08/g, // Back Space
86+
'SO' : /\x0E/g, // Shift Out / X-On
87+
'SI' : /\x0F/g, // Shift In / X-Off
88+
'DLE' : /\x10/g, // Data Line Escape
89+
'DC1' : /\x11/g, // Device Control 1 (oft. XON)
90+
'DC2' : /\x12/g, // Device Control 2
91+
'DC3' : /\x13/g, // Device Control 3 (oft. XOFF)
92+
'DC4' : /\x14/g, // Device Control 4
93+
'NAK' : /\x15/g, // Negative Acknowledgement
94+
'SYN' : /\x16/g, // Synchronous Idle
95+
'ETB' : /\x17/g, // End of Transmit Block
96+
'CAN' : /\x18/g, // Cancel
97+
'EM' : /\x19/g, // End of Medium
98+
'SUB' : /\x1A/g, // Substitute
99+
'ESC' : /\x1B/g, // Escape
100+
'FS' : /\x1C/g, // File Separator
101+
'GS' : /\x1D/g, // Group Separator
102+
'RS' : /\x1E/g, // Record Separator
103+
'US' : /\x1F/g // Unit Separator
87104
};
88105

89106
// eval server-side
90107
$.post('?js=1', { code: editor.getSession().getValue() }, function (res) {
91108
if (res.match(/#end-php-console-output#$/)) {
92109
var result = res.substring(0, res.length - 24);
93-
for (var k in controlChars) {
94-
result = result.replace(controlChars[k], '<span class="control-char">'+ k +'</span>');
95-
}
110+
$.each(controlChars, function (identifier, regex) {
111+
result = result.replace(regex, '<span class="control-char">' + identifier + '</span>');
112+
});
96113
$('div.output').html(result);
97114
} else {
98115
$('div.output').html(res + "<br /><br /><em>Script ended unexpectedly.</em>");

styles.css

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ a {
1919
}
2020

2121
.expand {
22-
display: block;
23-
margin-bottom: 5px;
22+
display: block;
23+
margin-bottom: 5px;
2424
}
2525

2626
.output, .input {
@@ -96,11 +96,12 @@ a {
9696
color: #aaa;
9797
}
9898

99-
.krumo-root .control-char {
99+
.control-char {
100100
background: #000;
101101
color: #fff;
102102
margin-left: 2px;
103103
margin-right: 2px;
104-
-webkit-border-radius: 5px;
105-
border-radius: 5px;
104+
-webkit-border-radius: 3px;
105+
border-radius: 3px;
106+
padding: 1px 2px;
106107
}

0 commit comments

Comments
 (0)