Show More
@@ -1,41 +1,41 | |||||
1 | define ([], function() { |
|
1 | define ([], function() { | |
2 | "use strict"; |
|
2 | "use strict"; | |
3 | function make_terminal(element, size, ws_url) { |
|
3 | function make_terminal(element, size, ws_url) { | |
4 | var ws = new WebSocket(ws_url); |
|
4 | var ws = new WebSocket(ws_url); | |
5 | Terminal.brokenBold = true; |
|
5 | Terminal.brokenBold = true; | |
6 | var term = new Terminal({ |
|
6 | var term = new Terminal({ | |
7 | cols: size.cols, |
|
7 | cols: size.cols, | |
8 | rows: size.rows, |
|
8 | rows: size.rows, | |
9 |
screenKeys: |
|
9 | screenKeys: false, | |
10 | useStyle: false |
|
10 | useStyle: false | |
11 | }); |
|
11 | }); | |
12 | ws.onopen = function(event) { |
|
12 | ws.onopen = function(event) { | |
13 | ws.send(JSON.stringify(["set_size", size.rows, size.cols, |
|
13 | ws.send(JSON.stringify(["set_size", size.rows, size.cols, | |
14 | window.innerHeight, window.innerWidth])); |
|
14 | window.innerHeight, window.innerWidth])); | |
15 | term.on('data', function(data) { |
|
15 | term.on('data', function(data) { | |
16 | ws.send(JSON.stringify(['stdin', data])); |
|
16 | ws.send(JSON.stringify(['stdin', data])); | |
17 | }); |
|
17 | }); | |
18 |
|
18 | |||
19 | term.on('title', function(title) { |
|
19 | term.on('title', function(title) { | |
20 | document.title = title; |
|
20 | document.title = title; | |
21 | }); |
|
21 | }); | |
22 |
|
22 | |||
23 | term.open(element); |
|
23 | term.open(element); | |
24 |
|
24 | |||
25 | ws.onmessage = function(event) { |
|
25 | ws.onmessage = function(event) { | |
26 | var json_msg = JSON.parse(event.data); |
|
26 | var json_msg = JSON.parse(event.data); | |
27 | switch(json_msg[0]) { |
|
27 | switch(json_msg[0]) { | |
28 | case "stdout": |
|
28 | case "stdout": | |
29 | term.write(json_msg[1]); |
|
29 | term.write(json_msg[1]); | |
30 | break; |
|
30 | break; | |
31 | case "disconnect": |
|
31 | case "disconnect": | |
32 | term.write("\r\n\r\n[CLOSED]\r\n"); |
|
32 | term.write("\r\n\r\n[CLOSED]\r\n"); | |
33 | break; |
|
33 | break; | |
34 | } |
|
34 | } | |
35 | }; |
|
35 | }; | |
36 | }; |
|
36 | }; | |
37 | return {socket: ws, term: term}; |
|
37 | return {socket: ws, term: term}; | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | return {make_terminal: make_terminal}; |
|
40 | return {make_terminal: make_terminal}; | |
41 | }); |
|
41 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now