|
72 | 72 | if (window.localStorage) {
|
73 | 73 | localStorage.setItem('phpCode', editor.getSession().getValue());
|
74 | 74 | }
|
75 |
| - |
| 75 | + |
76 | 76 | 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 |
87 | 104 | };
|
88 | 105 |
|
89 | 106 | // eval server-side
|
90 | 107 | $.post('?js=1', { code: editor.getSession().getValue() }, function (res) {
|
91 | 108 | if (res.match(/#end-php-console-output#$/)) {
|
92 | 109 | 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 | + }); |
96 | 113 | $('div.output').html(result);
|
97 | 114 | } else {
|
98 | 115 | $('div.output').html(res + "<br /><br /><em>Script ended unexpectedly.</em>");
|
|
0 commit comments