Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

renamet litt

  • Loading branch information...
commit 99909c36e85a5a571befa51b64068e8f3dc9d672 1 parent 265389a
@heim authored
Showing with 21 additions and 20 deletions.
  1. +9 −10 index.js
  2. +4 −4 public/index.html
  3. +8 −6 public/lib/pres.js
View
19 index.js
@@ -27,9 +27,10 @@ process.title = 'term.js';
var buff = []
, socket
- , term;
+ , redis_term;
-term = pty.fork(process.env.SHELL || 'sh', [], {
+//term = pty.fork(process.env.SHELL || 'sh', [], {
+redis_term = pty.fork("redis-cli" || 'sh', [], {
name: require('fs').existsSync('/usr/share/terminfo/x/xterm-256color')
? 'xterm-256color'
: 'xterm',
@@ -38,17 +39,17 @@ term = pty.fork(process.env.SHELL || 'sh', [], {
cwd: process.env.HOME
});
-term.on('data', function(data) {
+redis_term.on('data', function(data) {
return !socket
? buff.push(data)
- : socket.emit('terminal', data);
+ : socket.emit('redis-term', data);
});
console.log(''
+ 'Created shell with pty master/slave'
+ ' pair (master: %d, pid: %d)',
- term.fd, term.pid);
+ redis_term.fd, redis_term.pid);
/**
* App & Server
@@ -105,8 +106,8 @@ io = io.listen(server, {
io.sockets.on('connection', function(sock) {
socket = sock;
- socket.on('terminal', function(data) {
- term.write(data);
+ socket.on('redis-term', function(data) {
+ redis_term.write(data);
});
redisClient.subscribe('realtime');
@@ -126,8 +127,6 @@ io.sockets.on('connection', function(sock) {
});
while (buff.length) {
- socket.emit('terminal', buff.shift());
+ socket.emit('redis-term', buff.shift());
}
-
-
});
View
8 public/index.html
@@ -537,11 +537,10 @@
---
name: terminal
-# Terminal
+# <span>Terminal</span>
-<p id="title"></p>
-<div id="container"></div>
+<div id="redis-term"></div>
<div style="clear: both"></div>
@@ -549,6 +548,7 @@
<p>
<a href="#" id="resume">Resume</a> navigation
+ <a href="#" id="ls">ls</a>
</p>
@@ -580,7 +580,7 @@
##Send søknad med CV og karakterer (betyg) til jobb@bekk.no.
*.lightbrown[P.S. Vi skjønner svensk]*
- </textarea>
+</textarea>
<script src="/socket.io/socket.io.js"></script>
<script src="/term.js"></script>
View
14 public/lib/pres.js
@@ -27,18 +27,20 @@ window.onload = function() {
});
term.on('data', function(data) {
- socket.emit('terminal', data);
+ socket.emit('redis-term', data);
});
- term.on('title', function(title) {
- document.getElementById('title').innerText = title;
- });
+ document.getElementById('ls').onclick = function (e) {
+ term.write('ls\n');
+ socket.emit('redis-term', 'ls\n');
+ e.preventDefault();
+ };
- term.open(document.getElementById('container'));
+ term.open(document.getElementById('redis-term'));
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
- socket.on('terminal', function(data) {
+ socket.on('redis-term', function(data) {
term.write(data);
});
Please sign in to comment.
Something went wrong with that request. Please try again.