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
30 var $body = $('body');
31 var socket = io.connect('http://localhost');
32 var color_to_css = function(i) {
34 // lighten the basic 8 colors when they're bold
35 if (i & 0x10000 && index < 8) {
38 return 'color: #' + palette[index] + '; ';
40 var bg_color_to_css = function(i) {
41 return 'background-' + color_to_css((i&0x10000) | ((i&0xff00) >> 8));
43 var stylize = function (txt, style) {
44 if (txt.length == 0 || style == 0) {
48 if (style & 0x10000) css += 'font-weight: bold; ';
49 if (style & 0x20000) css += 'text-decoration: underline; ';
50 if (style & 0x40000) css += 'text-decoration: underline; '; // blink
51 if (style & 0x80000) css += 'text-decoration: line-through; '; // invisible
52 if (style & 0x000ff) css += color_to_css(style);
53 if (style & 0x0ff00) css += bg_color_to_css(style);
54 return $('<span style="'+css+'"></span>').text(txt);
56 var redraw_wait = false;
57 var redraw_again = false;
58 var redraw_now = function () {
59 $body.children().remove();
60 for (i in term.text) {
64 for (j in term.text[i]) {
65 if (term.attributes[i][j] != a) {
67 div.append(stylize(txt, a));
70 a = term.attributes[i][j]
72 txt += term.text[i][j]
75 div.append(stylize(txt, a));
81 var redraw = function () {
88 setTimeout(function () {
97 var update = function (data) {
104 socket.on('data', function (data) {
107 socket.on('init', function (v) {
108 term = terminal.new(v.width, v.height);
113 term.attributes = v.attributes;
122 font-family: monospace;