refactor(terminal) rm listener

This commit is contained in:
coderaiser 2014-02-04 09:42:09 -05:00
parent 060cdf2297
commit ca91d26f49

View file

@ -44,7 +44,8 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
function show(callback) {
var socket = CloudCmd.Socket;
var size,
socket = CloudCmd.Socket;
if (!Loading) {
Images.showLoad({top:true});
@ -56,10 +57,17 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
style : 'height :100%'
});
/* hack to determine console size
* inspired with
*
* https://github.com/petethepig/devtools-terminal
*/
Cell = DOM.anyload({
name : 'div',
inner : '&nbsp',
parent : Element
parent : Element,
style : 'position: absolute;' +
'top : -1000px;'
});
DOM.cssSet({
@ -69,12 +77,13 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
'}'
});
size = getSize();
Term = new Terminal({
Term = new Terminal({
screenKeys: true,
cursorBlink: false,
cols: 80,
rows: 25
cols: size.cols,
rows: size.rows
});
Term.open(Element);
@ -93,21 +102,11 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
Term.write(data);
}
function listener(event) {
var keyCode = event.keyCode;
if (keyCode === ESC)
CloudCmd.View.hide();
}
function addListeners(callback) {
var socket = CloudCmd.Socket,
size = maxSize();
var socket = CloudCmd.Socket;
socket.on(CHANNEL, write);
Term.on('keydown', listener);
Term.on('data', function(data) {
var code;
@ -128,7 +127,7 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
Util.exec(callback);
}
function maxSize() {
function getSize() {
var wSubs = Element.offsetWidth - Element.clientWidth,
w = Element.clientWidth - wSubs,