|
@ -3,67 +3,66 @@ var socket = io(location.origin, {path: '/wetty/socket.io'}) |
|
|
var buf = ''; |
|
|
var buf = ''; |
|
|
|
|
|
|
|
|
function Wetty(argv) { |
|
|
function Wetty(argv) { |
|
|
this.argv_ = argv; |
|
|
this.argv_ = argv; |
|
|
this.io = null; |
|
|
this.io = null; |
|
|
this.pid_ = -1; |
|
|
this.pid_ = -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Wetty.prototype.run = function() { |
|
|
Wetty.prototype.run = function() { |
|
|
this.io = this.argv_.io.push(); |
|
|
this.io = this.argv_.io.push(); |
|
|
|
|
|
|
|
|
this.io.onVTKeystroke = this.sendString_.bind(this); |
|
|
this.io.onVTKeystroke = this.sendString_.bind(this); |
|
|
this.io.sendString = this.sendString_.bind(this); |
|
|
this.io.sendString = this.sendString_.bind(this); |
|
|
this.io.onTerminalResize = this.onTerminalResize.bind(this); |
|
|
this.io.onTerminalResize = this.onTerminalResize.bind(this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Wetty.prototype.sendString_ = function(str) { |
|
|
Wetty.prototype.sendString_ = function(str) { |
|
|
socket.emit('input', str); |
|
|
socket.emit('input', str); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Wetty.prototype.onTerminalResize = function(col, row) { |
|
|
Wetty.prototype.onTerminalResize = function(col, row) { |
|
|
socket.emit('resize', { col: col, row: row }); |
|
|
socket.emit('resize', { col: col, row: row }); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
socket.on('connect', function() { |
|
|
socket.on('connect', function() { |
|
|
lib.init(function() { |
|
|
lib.init(function() { |
|
|
hterm.defaultStorage = new lib.Storage.Local(); |
|
|
hterm.defaultStorage = new lib.Storage.Local(); |
|
|
term = new hterm.Terminal(); |
|
|
term = new hterm.Terminal(); |
|
|
window.term = term; |
|
|
window.term = term; |
|
|
term.decorate(document.getElementById('terminal')); |
|
|
term.decorate(document.getElementById('terminal')); |
|
|
|
|
|
|
|
|
term.setCursorPosition(0, 0); |
|
|
term.setCursorPosition(0, 0); |
|
|
term.setCursorVisible(true); |
|
|
term.setCursorVisible(true); |
|
|
term.prefs_.set('ctrl-c-copy', true); |
|
|
term.prefs_.set('ctrl-c-copy', true); |
|
|
term.prefs_.set('ctrl-v-paste', true); |
|
|
term.prefs_.set('ctrl-v-paste', true); |
|
|
term.prefs_.set('use-default-window-copy', true); |
|
|
term.prefs_.set('use-default-window-copy', true); |
|
|
|
|
|
|
|
|
term.runCommandClass(Wetty, document.location.hash.substr(1)); |
|
|
term.runCommandClass(Wetty, document.location.hash.substr(1)); |
|
|
socket.emit('resize', { |
|
|
socket.emit('resize', { |
|
|
col: term.screenSize.width, |
|
|
col: term.screenSize.width, |
|
|
row: term.screenSize.height |
|
|
row: term.screenSize.height |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (buf && buf != '') |
|
|
|
|
|
{ |
|
|
|
|
|
term.io.writeUTF16(buf); |
|
|
|
|
|
buf = ''; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (buf && buf != '') { |
|
|
|
|
|
term.io.writeUTF16(buf); |
|
|
|
|
|
buf = ''; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
socket.on('output', function(data) { |
|
|
socket.on('output', function(data) { |
|
|
if (!term) { |
|
|
if (!term) { |
|
|
buf += data; |
|
|
buf += data; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
term.io.writeUTF16(data); |
|
|
term.io.writeUTF16(data); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
socket.on('logout', function(data) { |
|
|
socket.on('logout', function(data) { |
|
|
console.log("user logout"); |
|
|
console.log("user logout"); |
|
|
document.getElementById("overlay").style.display = "block"; |
|
|
document.getElementById("overlay").style.display = "block"; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
socket.on('disconnect', function() { |
|
|
socket.on('disconnect', function() { |
|
|
console.log("Socket.io connection closed"); |
|
|
console.log("Socket.io connection closed"); |
|
|
}); |
|
|
}); |
|
|