| 1 |
<!doctype html> |
| 2 |
<title>term.js</title> |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
<style> |
| 8 |
html { |
| 9 |
background: #555; |
| 10 |
} |
| 11 |
|
| 12 |
h1 { |
| 13 |
margin-bottom: 20px; |
| 14 |
font: 20px/1.5 sans-serif; |
| 15 |
} |
| 16 |
|
| 17 |
/* |
| 18 |
.terminal { |
| 19 |
float: left; |
| 20 |
border: #000 solid 5px; |
| 21 |
font-family: "DejaVu Sans Mono", "Liberation Mono", monospace; |
| 22 |
font-size: 11px; |
| 23 |
color: #f0f0f0; |
| 24 |
background: #000; |
| 25 |
} |
| 26 |
|
| 27 |
.terminal-cursor { |
| 28 |
color: #000; |
| 29 |
background: #f0f0f0; |
| 30 |
} |
| 31 |
*/ |
| 32 |
</style> |
| 33 |
<h1>term.js</h1> |
| 34 |
<script src="/socket.io/socket.io.js"></script> |
| 35 |
<script src="term.js"></script> |
| 36 |
<script> |
| 37 |
;(function() { |
| 38 |
window.onload = function() { |
| 39 |
var socket = io.connect(); |
| 40 |
socket.on('connect', function() { |
| 41 |
var term = new Terminal({ |
| 42 |
cols: 80, |
| 43 |
rows: 24, |
| 44 |
useStyle: true, |
| 45 |
screenKeys: true, |
| 46 |
cursorBlink: false |
| 47 |
}); |
| 48 |
|
| 49 |
term.on('data', function(data) { |
| 50 |
socket.emit('data', data); |
| 51 |
}); |
| 52 |
|
| 53 |
term.on('title', function(title) { |
| 54 |
document.title = title; |
| 55 |
}); |
| 56 |
|
| 57 |
term.open(document.body); |
| 58 |
|
| 59 |
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n'); |
| 60 |
|
| 61 |
socket.on('data', function(data) { |
| 62 |
term.write(data); |
| 63 |
}); |
| 64 |
|
| 65 |
socket.on('disconnect', function() { |
| 66 |
term.destroy(); |
| 67 |
}); |
| 68 |
}); |
| 69 |
}; |
| 70 |
}).call(this); |
| 71 |
</script> |