4 <title>Remote Terminal Viewer</title>
5 <script src="/jquery.js"></script>
6 <script src="/terminal.js"></script>
7 <script src="/socket.io/socket.io.js"></script>
11 // 8-14 are bolded versions
272 var $body = $('body');
273 var socket = io.connect('http://localhost');
274 var color_to_css = function(i) {
276 // lighten the basic 8 colors when they're bold
277 if (i & 0x10000 && index < 8) {
280 return 'color: #' + palette[index] + '; ';
282 var bg_color_to_css = function(i) {
283 return 'background-' + color_to_css((i&0x10000) | ((i&0xff00) >> 8));
285 var stylize = function (txt, style) {
286 if (txt.length == 0 || style == 0x000007) {
290 if (style & 0x10000) css += 'font-weight: bold; ';
291 if (style & 0x20000) css += 'text-decoration: underline; ';
292 if (style & 0x40000) css += 'text-decoration: underline; '; // blink
293 if (style & 0x80000) css += 'text-decoration: line-through; '; // invisible
294 if (style & 0x000ff) css += color_to_css(style);
295 if (style & 0x0ff00) css += bg_color_to_css(style);
296 return $('<span style="'+css+'"></span>').text(txt);
298 var redraw_wait = false;
299 var redraw_again = false;
300 var redraw_now = function () {
301 $body.children().remove();
302 for (i in term.text) {
306 for (j in term.text[i]) {
307 if (term.attributes[i][j] != a) {
309 div.append(stylize(txt, a));
312 a = term.attributes[i][j]
314 txt += term.text[i][j]
317 div.append(stylize(txt, a));
323 var redraw = function () {
329 redraw_again = false;
330 setTimeout(function () {
333 redraw_again = false;
339 var update = function (data) {
346 socket.on('data', function (data) {
349 socket.on('init', function (v) {
350 term = terminal.new(v.width, v.height);
355 term.attributes = v.attributes;
364 font-family: monospace;