mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-06-03 02:49:42 +00:00
Implement pseudo terminal
This commit is contained in:
@@ -1,2 +1,41 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
console.log('main js file loaded');
|
||||
var ws;
|
||||
|
||||
ws = null;
|
||||
|
||||
$(function() {
|
||||
ws = new WebSocket('ws://' + document.location.host + '/ws');
|
||||
ws.onopen = function() {
|
||||
return console.log("WebSocket open", arguments);
|
||||
};
|
||||
ws.onclose = function() {
|
||||
return console.log("WebSocket closed", arguments);
|
||||
};
|
||||
ws.onerror = function() {
|
||||
return console.log("WebSocket error", arguments);
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
return $('.term code').html($('.term code').html() + event.data);
|
||||
};
|
||||
return $('html,body').on('keypress', function(event) {
|
||||
var code;
|
||||
code = event.keyCode;
|
||||
ws.send(String.fromCharCode(code));
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
}).on('keydown', function(event) {
|
||||
var code;
|
||||
code = event.keyCode;
|
||||
if (code === 17) {
|
||||
return;
|
||||
}
|
||||
if (event.ctrlKey) {
|
||||
code -= 64;
|
||||
ws.send(String.fromCharCode(code));
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user