annotate shterm.js @ 70:d7eb63cd7a16

Try to get some compatibility for keys. I'd thought using the DOM_VK_ names was a good idea. Symbolic names ought to be more portable than opaque numeric constants. Foolish me, expecting things to be sane. Keys now work with FF15 and Chrome 17.
author John "Elwin" Edwards <elwin@sdf.org>
date Thu, 21 Jun 2012 09:43:52 -0700
parents 7a50b4412fea
children a497ecd116d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
9bef0941c6dd Add a few comments.
John "Elwin" Edwards <elwin@sdf.org>
parents: 0
diff changeset
1 /* shterm.js: browser-side JavaScript to handle I/O for termemu.js when it
9bef0941c6dd Add a few comments.
John "Elwin" Edwards <elwin@sdf.org>
parents: 0
diff changeset
2 * is running a shell via the webtty.js server.
9bef0941c6dd Add a few comments.
John "Elwin" Edwards <elwin@sdf.org>
parents: 0
diff changeset
3 */
9bef0941c6dd Add a few comments.
John "Elwin" Edwards <elwin@sdf.org>
parents: 0
diff changeset
4
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
5 var isalive = false; // Whether the session is currently active.
14
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
6 var nsend = 0; // The number of the next packet to send.
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
7 var nrecv = 0; // The next packet expected.
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
8 var msgQ = []; // Queue for out-of-order messages.
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
9
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
10 // A state machine that keeps track of polling the server.
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
11 var ajaxstate = {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
12 state: 0,
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
13 timerID: null,
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
14 clear: function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
15 if (this.timerID != null) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
16 window.clearTimeout(this.timerID);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
17 this.timerID = null;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
18 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
19 },
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
20 set: function (ms) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
21 this.clear();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
22 this.timerID = window.setTimeout(getData, ms);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
23 },
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
24 gotdata: function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
25 this.set(100);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
26 this.state = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
27 },
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
28 gotnothing: function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
29 if (this.state == 0) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
30 this.set(100);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
31 this.state = 1;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
32 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
33 else if (this.state == 1) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
34 this.set(300);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
35 this.state = 2;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
36 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
37 else if (this.state == 2) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
38 this.set(1000);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
39 this.state = 3;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
40 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
41 else {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
42 this.set(5000);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
43 this.state = 3;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
44 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
45 },
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
46 posted: function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
47 this.set(100);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
48 this.state = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
49 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
50 };
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
51
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
52 function writeData(hexstr) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
53 var codenum;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
54 var codes = [];
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
55 var nc;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
56 var u8wait = 0; /* Stores bits from previous bytes of multibyte sequences. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
57 var expect = 0; /* The number of 10------ bytes expected. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
58 /* UTF-8 translation. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
59 for (var i = 0; i < hexstr.length; i += 2) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
60 nc = Number("0x" + hexstr.substr(i, 2));
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
61 if (nc < 0x7F) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
62 /* 0------- */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
63 codes.push(nc);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
64 /* Any incomplete sequence will be discarded. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
65 u8wait = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
66 expect = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
67 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
68 else if (nc < 0xC0) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
69 /* 10------ : part of a multibyte sequence */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
70 if (expect > 0) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
71 u8wait <<= 6;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
72 u8wait += (nc & 0x3F);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
73 expect--;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
74 if (expect == 0) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
75 codes.push(u8wait);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
76 u8wait = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
77 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
78 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
79 else {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
80 /* Assume an initial byte was missed. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
81 u8wait = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
82 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
83 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
84 /* These will all discard any incomplete sequence. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
85 else if (nc < 0xE0) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
86 /* 110----- : introduces 2-byte sequence */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
87 u8wait = (nc & 0x1F);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
88 expect = 1;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
89 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
90 else if (nc < 0xF0) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
91 /* 1110---- : introduces 3-byte sequence */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
92 u8wait = (nc & 0x0F);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
93 expect = 2;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
94 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
95 else if (nc < 0xF8) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
96 /* 11110--- : introduces 4-byte sequence */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
97 u8wait = (nc & 0x07);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
98 expect = 3;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
99 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
100 else if (nc < 0xFC) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
101 /* 111110-- : introduces 5-byte sequence */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
102 u8wait = (nc & 0x03);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
103 expect = 4;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
104 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
105 else if (nc < 0xFE) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
106 /* 1111110- : introduces 6-byte sequence */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
107 u8wait = (nc & 0x01);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
108 expect = 5;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
109 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
110 else {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
111 /* 1111111- : should never appear */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
112 u8wait = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
113 expect = 0;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
114 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
115 /* Supporting all 31 bits is probably overkill... */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
116 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
117 termemu.write(codes);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
118 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
119 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
120
14
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
121 function processMsg(response) {
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
122 if (response.t != "d" || typeof(response.d) != "string")
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
123 return;
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
124 if (response.n === nrecv) {
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
125 writeData(response.d);
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
126 nrecv++;
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
127 var next;
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
128 /* msgQ must be shifted every time nrecv is incremented, but the process
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
129 * stops whenever an empty space, corresponding to an unarrived message,
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
130 * is encountered.
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
131 */
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
132 while ((next = msgQ.shift()) !== undefined) {
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
133 writeData(next.d);
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
134 nrecv++;
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
135 }
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
136 }
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
137 else if (response.n > nrecv) {
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
138 /* The current message comes after one still missing. Queue this one
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
139 * for later use.
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
140 */
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
141 debug(1, "Got packet " + response.n + ", expected " + nrecv);
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
142 msgQ[response.n - nrecv - 1] = response;
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
143 }
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
144 else {
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
145 /* This message's number was encountered previously. */
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
146 debug(1, "Discarding packet " + response.n + ", expected " + nrecv);
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
147 }
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
148 }
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
149
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
150 function getData() {
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
151 if (!isalive)
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
152 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
153 var datareq = new XMLHttpRequest();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
154 datareq.onreadystatechange = function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
155 if (datareq.readyState == 4 && datareq.status == 200) {
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
156 var response = JSON.parse(this.responseText);
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
157 if (!response.t)
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
158 return;
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
159 else if (response.t == "E") {
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
160 if (response.c == 1) {
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
161 isalive = false;
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
162 debug(1, "Server error: " + response.s);
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
163 }
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
164 }
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
165 else if (response.t == "n")
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
166 ajaxstate.gotnothing();
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
167 else if (response.t == "d") {
14
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
168 processMsg(response);
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
169 ajaxstate.gotdata();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
170 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
171 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
172 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
173 };
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
174 datareq.open('GET', '/feed', true);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
175 datareq.send(null);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
176 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
177 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
178
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
179 function postResponseHandler() {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
180 if (this.readyState == 4 && this.status == 200) {
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
181 var response = JSON.parse(this.responseText);
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
182 if (!response.t || response.t == "n")
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
183 return;
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
184 else if (response.t == "E") {
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
185 if (response.c == 1) {
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
186 isalive = false;
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
187 debug(1, "Server error: " + response.s);
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
188 }
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
189 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
190 }
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
191 else if (response.t != "d")
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
192 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
193 /* It is a data message */
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
194 if (response.d) {
14
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
195 processMsg(response);
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
196 //debug(1, "Got packet " + response.n);
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
197 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
198 ajaxstate.posted();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
199 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
200 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
201 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
202
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
203 function sendback(str) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
204 /* For responding to terminal queries. */
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
205 var formdata = {"t": "d", "n": nsend++, "d": str};
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
206 var datareq = new XMLHttpRequest();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
207 datareq.onreadystatechange = postResponseHandler;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
208 datareq.open('POST', '/feed', true);
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
209 datareq.send(JSON.stringify(formdata));
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
210 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
211 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
212
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
213 function sendkey(ev) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
214 var keynum = ev.keyCode;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
215 var code;
70
d7eb63cd7a16 Try to get some compatibility for keys.
John "Elwin" Edwards <elwin@sdf.org>
parents: 58
diff changeset
216 if (keynum >= 65 && keynum <= 90) {
d7eb63cd7a16 Try to get some compatibility for keys.
John "Elwin" Edwards <elwin@sdf.org>
parents: 58
diff changeset
217 /* Letters. */
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
218 if (ev.ctrlKey)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
219 keynum -= 64;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
220 else if (!ev.shiftKey)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
221 keynum += 32;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
222 code = keynum.toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
223 if (code.length < 2)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
224 code = "0" + code;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
225 }
70
d7eb63cd7a16 Try to get some compatibility for keys.
John "Elwin" Edwards <elwin@sdf.org>
parents: 58
diff changeset
226 else if (keynum >= 48 && keynum <= 57) {
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
227 /* The number row. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
228 if (ev.shiftKey) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
229 code = numShifts[keynum - 48].toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
230 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
231 else {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
232 code = keynum.toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
233 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
234 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
235 else if (keynum in keyHexCodes) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
236 if (ev.shiftKey)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
237 code = keyHexCodes[keynum][1];
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
238 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
239 code = keyHexCodes[keynum][0];
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
240 }
70
d7eb63cd7a16 Try to get some compatibility for keys.
John "Elwin" Edwards <elwin@sdf.org>
parents: 58
diff changeset
241 else if (keynum >= 16 && keynum <= 20) {
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
242 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
243 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
244 else {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
245 debug(1, "Ignoring keycode " + keynum);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
246 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
247 }
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
248 if (isalive)
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
249 ev.preventDefault();
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
250 var formdata = {"t": "d", "n": nsend++, "d": code};
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
251 var datareq = new XMLHttpRequest();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
252 datareq.onreadystatechange = postResponseHandler;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
253 datareq.open('POST', '/feed', true);
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
254 datareq.send(JSON.stringify(formdata));
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
255 //dkey(code);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
256 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
257 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
258
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
259 var charshifts = { '-': "5f", '=': "2b", '[': "7b", ']': "7d", '\\': "7c",
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
260 ';': "3a", '\'': "22", ',': "3c", '.': "3e", '/': "3f", '`': "7e"
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
261 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
262
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
263 function vkey(c) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
264 var keystr;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
265 if (c.match(/^[a-z]$/)) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
266 if (termemu.ctrlp()) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
267 var n = c.charCodeAt(0) - 96;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
268 keystr = n.toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
269 if (keystr.length < 2)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
270 keystr = "0" + keystr;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
271 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
272 else if (termemu.shiftp())
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
273 keystr = c.toUpperCase().charCodeAt(0).toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
274 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
275 keystr = c.charCodeAt(0).toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
276 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
277 else if (c.match(/^[0-9]$/)) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
278 if (termemu.shiftp())
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
279 keystr = numShifts[c.charCodeAt(0) - 48].toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
280 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
281 keystr = c.charCodeAt(0).toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
282 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
283 else if (c == '\n')
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
284 keystr = "0a";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
285 else if (c == '\t')
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
286 keystr = "09";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
287 else if (c == '\b')
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
288 keystr = "08";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
289 else if (c == ' ')
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
290 keystr = "20";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
291 else if (c in charshifts) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
292 if (termemu.shiftp())
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
293 keystr = charshifts[c];
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
294 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
295 keystr = c.charCodeAt(0).toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
296 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
297 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
298 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
299 //writeData("Sending " + keystr);
70
d7eb63cd7a16 Try to get some compatibility for keys.
John "Elwin" Edwards <elwin@sdf.org>
parents: 58
diff changeset
300 var formdata = {"t": "d", "n": nsend++, "d": keystr};
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
301 var datareq = new XMLHttpRequest();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
302 datareq.onreadystatechange = postResponseHandler;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
303 datareq.open('POST', '/feed', true);
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
304 datareq.send(JSON.stringify(formdata));
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
305 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
306 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
307
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
308 function setup() {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
309 keyHexCodes.init();
9
826a7ced69f8 Make the emulator screen resizable.
John "Elwin" Edwards <elwin@sdf.org>
parents: 7
diff changeset
310 termemu.init("termwrap", 24, 80);
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
311 setTitle("Not connected.");
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
312 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
313 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
314
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
315 function toggleshift() {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
316 termemu.toggleshift();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
317 keydiv = document.getElementById("shiftkey");
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
318 if (termemu.shiftp())
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
319 keydiv.className = "keysel";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
320 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
321 keydiv.className = "key";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
322 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
323 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
324
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
325 function togglectrl() {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
326 termemu.togglectrl();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
327 keydiv = document.getElementById("ctrlkey");
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
328 if (termemu.ctrlp())
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
329 keydiv.className = "keysel";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
330 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
331 keydiv.className = "key";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
332 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
333 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
334
9
826a7ced69f8 Make the emulator screen resizable.
John "Elwin" Edwards <elwin@sdf.org>
parents: 7
diff changeset
335 function login(h, w) {
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
336 if (isalive)
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
337 return;
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
338 params = {"login": true, "h": h, "w": w};
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
339 var req = new XMLHttpRequest();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
340 req.onreadystatechange = function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
341 if (req.readyState == 4 && req.status == 200) {
10
d051aad3e95f webtty: begin experimenting with JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents: 9
diff changeset
342 var logindict = JSON.parse(req.responseText);
d051aad3e95f webtty: begin experimenting with JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents: 9
diff changeset
343 if (logindict.login) {
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
344 /* Success */
10
d051aad3e95f webtty: begin experimenting with JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents: 9
diff changeset
345 termemu.resize(logindict.h, logindict.w);
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
346 isalive = true;
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
347 nsend = 0;
14
155f3c104759 shterm.js: Client-side message ordering
John "Elwin" Edwards <elwin@sdf.org>
parents: 13
diff changeset
348 nrecv = 0;
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
349 setTitle("Logged in");
10
d051aad3e95f webtty: begin experimenting with JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents: 9
diff changeset
350 debug(1, "Logged in with id " + logindict.id);
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
351 getData();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
352 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
353 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
354 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
355 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
356 };
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
357 req.open('POST', '/login', true);
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
358 req.send(JSON.stringify(params));
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
359 //req.send("login=login&h=" + String(h) + "&w=" + String(w));
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
360 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
361 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
362
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
363 function stop() {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
364 var req = new XMLHttpRequest();
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
365 req.onreadystatechange = function () {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
366 if (req.readyState == 4 && req.status == 200) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
367 /* Figure out whether or not it worked. */
11
481dcee353c9 webtty: switch all server responses to JSON.
John "Elwin" Edwards <elwin@sdf.org>
parents: 10
diff changeset
368 /* FIXME the server might respond with output. */
58
7a50b4412fea Move credentials into the drivers.
John "Elwin" Edwards <elwin@sdf.org>
parents: 14
diff changeset
369 isalive = false;
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
370 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
371 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
372 };
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
373 req.open('POST', '/feed', true);
13
bf7c26d0b66d webtty: switch upward protocol to JSON
John "Elwin" Edwards <elwin@sdf.org>
parents: 12
diff changeset
374 req.send(JSON.stringify({"t": "q", "n": nsend++}));
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
375 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
376 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
377
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
378 function setTitle(tstr) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
379 var titlespan = document.getElementById("ttitle");
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
380 var tnode = document.createTextNode(tstr);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
381 if (titlespan.childNodes.length == 0)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
382 titlespan.appendChild(tnode);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
383 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
384 titlespan.replaceChild(tnode, titlespan.childNodes[0]);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
385 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
386 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
387
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
388 function debug(level, msg) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
389 if (level < debugSuppress)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
390 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
391 var msgdiv = document.createElement("div");
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
392 var msgtext = document.createTextNode(msg);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
393 msgdiv.appendChild(msgtext);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
394 document.getElementById("debug").appendChild(msgdiv);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
395 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
396 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
397
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
398 /* This should be a termemu method. */
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
399 function textsize(larger) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
400 var cssSize = document.getElementById("term").style.fontSize;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
401 if (!cssSize)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
402 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
403 var match = cssSize.match(/\d*/);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
404 if (!match)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
405 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
406 var csize = Number(match[0]);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
407 var nsize;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
408 if (larger) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
409 if (csize >= 48)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
410 nsize = 48;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
411 else if (csize >= 20)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
412 nsize = csize + 4;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
413 else if (csize >= 12)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
414 nsize = csize + 2;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
415 else if (csize >= 8)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
416 nsize = csize + 1;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
417 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
418 nsize = 8;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
419 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
420 else {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
421 if (csize <= 8)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
422 nsize = 8;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
423 else if (csize <= 12)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
424 nsize = csize - 1;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
425 else if (csize <= 20)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
426 nsize = csize - 2;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
427 else if (csize <= 48)
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
428 nsize = csize - 4;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
429 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
430 nsize = 48;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
431 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
432 document.getElementById("term").style.fontSize = nsize.toString() + "px";
9
826a7ced69f8 Make the emulator screen resizable.
John "Elwin" Edwards <elwin@sdf.org>
parents: 7
diff changeset
433 termemu.fixsize();
0
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
434 debug(1, "Changing font size to " + nsize.toString());
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
435 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
436 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
437
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
438 function bell(on) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
439 var imgnode = document.getElementById("bell");
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
440 if (on) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
441 imgnode.style.visibility = "visible";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
442 window.setTimeout(bell, 1500, false);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
443 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
444 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
445 imgnode.style.visibility = "hidden";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
446 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
447 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
448
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
449 function dkey(codestr) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
450 var dstr = "Keystring: ";
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
451 for (var i = 0; i < codestr.length; i += 2) {
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
452 code = Number("0x" + codestr.substr(i, 2));
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
453 if (code < 32 || (code >= 127 && code < 160))
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
454 dstr += "\\x" + code.toString(16);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
455 else
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
456 dstr += String.fromCharCode(code);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
457 }
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
458 debug(1, dstr);
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
459 return;
bd412f63ce0d Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
460 }