Mercurial > hg > rlgwebd
annotate rlgterm.js @ 67:b6a3b26fe0dc
RLG-Web client: some visual improvements.
Hide the debugging messages by default.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Wed, 20 Jun 2012 14:11:57 -0700 |
parents | 57bf0dcd080e |
children | d7eb63cd7a16 |
rev | line source |
---|---|
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
1 /* rlgterm.js: Roguelike Gallery's driver for termemu.js */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
2 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
3 // 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
|
4 var ajaxstate = { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
5 state: 0, |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
6 timerID: null, |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
7 clear: function () { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
8 if (this.timerID != null) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
9 window.clearTimeout(this.timerID); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
10 this.timerID = null; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
11 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
12 }, |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
13 set: function (ms) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
14 this.clear(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
15 this.timerID = window.setTimeout(getData, ms); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
16 }, |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
17 gotdata: function () { |
35
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
18 this.set(1000); |
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
19 this.state = 1; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
20 }, |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
21 gotnothing: function () { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
22 if (this.state == 0) { |
35
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
23 this.set(1000); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
24 this.state = 1; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
25 } |
38
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
26 else if (this.state < 4) { |
35
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
27 this.set(4000); |
38
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
28 this.state++; |
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
29 } |
63
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
30 else if (session.playing) { |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
31 if (this.state < 8) { |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
32 this.set(15000); |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
33 this.state++; |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
34 } |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
35 else { |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
36 /* It's been over a minute. Stop polling. */ |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
37 this.clear(); |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
38 } |
38
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
39 } |
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
40 else { |
63
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
41 /* If watching, it can't stop polling entirely, because there |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
42 * are no POST events to start it up again. */ |
a077f9f84052
RLG-Web client: adjust polling for watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
61
diff
changeset
|
43 this.set(10000); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
44 } |
35
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
45 }, |
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
46 posted: function (wasdata) { |
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
47 if (wasdata) { |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
48 this.set(1000); |
35
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
49 this.state = 1; |
0
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 else { |
35
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
52 this.set(200); |
f15efa4818b4
rglterm.js: reduce the server polling.
John "Elwin" Edwards <elwin@sdf.org>
parents:
27
diff
changeset
|
53 this.state = 0; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
54 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
55 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
56 }; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
57 |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
58 /* Data on the available games. */ |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
59 var games = { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
60 "rogue3": { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
61 "name": "Rogue V3", |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
62 "uname": "rogue3" |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
63 }, |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
64 "rogue4": { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
65 "name": "Rogue V4", |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
66 "uname": "rogue4" |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
67 }, |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
68 "rogue5": { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
69 "name": "Rogue V5", |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
70 "uname": "rogue5" |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
71 }, |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
72 "srogue": { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
73 "name": "Super-Rogue", |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
74 "uname": "srogue" |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
75 } |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
76 }; |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
77 |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
78 var session = { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
79 /* The session id assigned by the server. */ |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
80 id: null, |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
81 /* Login name and key */ |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
82 lname: null, |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
83 lcred: null, |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
84 /* Whether the game is being played or just watched. */ |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
85 playing: false |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
86 }; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
87 |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
88 function writeData(hexstr) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
89 var codenum; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
90 var codes = []; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
91 var nc; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
92 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
|
93 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
|
94 /* UTF-8 translation. */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
95 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
|
96 nc = Number("0x" + hexstr.substr(i, 2)); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
97 if (nc < 0x7F) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
98 /* 0------- */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
99 codes.push(nc); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
100 /* Any incomplete sequence will be discarded. */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
101 u8wait = 0; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
102 expect = 0; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
103 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
104 else if (nc < 0xC0) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
105 /* 10------ : part of a multibyte sequence */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
106 if (expect > 0) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
107 u8wait <<= 6; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
108 u8wait += (nc & 0x3F); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
109 expect--; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
110 if (expect == 0) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
111 codes.push(u8wait); |
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 } |
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 else { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
116 /* Assume an initial byte was missed. */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
117 u8wait = 0; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
118 } |
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 /* These will all discard any incomplete sequence. */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
121 else if (nc < 0xE0) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
122 /* 110----- : introduces 2-byte sequence */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
123 u8wait = (nc & 0x1F); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
124 expect = 1; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
125 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
126 else if (nc < 0xF0) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
127 /* 1110---- : introduces 3-byte sequence */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
128 u8wait = (nc & 0x0F); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
129 expect = 2; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
130 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
131 else if (nc < 0xF8) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
132 /* 11110--- : introduces 4-byte sequence */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
133 u8wait = (nc & 0x07); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
134 expect = 3; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
135 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
136 else if (nc < 0xFC) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
137 /* 111110-- : introduces 5-byte sequence */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
138 u8wait = (nc & 0x03); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
139 expect = 4; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
140 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
141 else if (nc < 0xFE) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
142 /* 1111110- : introduces 6-byte sequence */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
143 u8wait = (nc & 0x01); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
144 expect = 5; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
145 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
146 else { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
147 /* 1111111- : should never appear */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
148 u8wait = 0; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
149 expect = 0; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
150 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
151 /* Supporting all 31 bits is probably overkill... */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
152 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
153 termemu.write(codes); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
154 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
155 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
156 |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
157 /* State for sending and receiving messages. */ |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
158 var nsend = 0; // The number of the next packet to send. |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
159 var nrecv = 0; // The next packet expected. |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
160 var msgQ = []; // Queue for out-of-order messages. |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
161 |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
162 /* Processes a message from the server, returning true or false if it was a |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
163 * data message with or without data, null if not data. |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
164 * All non-special responseTexts should be handed directly to this function. |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
165 */ |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
166 function processMsg(msg) { |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
167 var msgDicts; |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
168 var havedata = null; // eventual return value |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
169 try { |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
170 msgDicts = JSON.parse(msg); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
171 } catch (e) { |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
172 if (e instanceof SyntaxError) |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
173 return null; |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
174 } |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
175 if (msgDicts.length === 0) |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
176 return false; |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
177 for (var j = 0; j < msgDicts.length; j++) { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
178 if (!msgDicts[j].t) |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
179 continue; |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
180 else if (msgDicts[j].t == "E") { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
181 if (msgDicts[j].c == 1 || msgDicts[j].c == 6 || msgDicts[j].c == 7) { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
182 gameover(); |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
183 if (msgDicts[j].c == 1) { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
184 logout(); |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
185 } |
47
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
186 } |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
187 debug(1, "Server error: " + msgDicts[j].s); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
188 } |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
189 // A data message |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
190 else if (msgDicts[j].t == "d") { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
191 if (msgDicts[j].n === nrecv) { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
192 writeData(msgDicts[j].d); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
193 nrecv++; |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
194 /* Process anything in the queue that's now ready. */ |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
195 var next; |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
196 while ((next = msgQ.shift()) !== undefined) { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
197 writeData(next.d); |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
198 nrecv++; |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
199 } |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
200 } |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
201 else if (msgDicts[j].n > nrecv) { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
202 /* The current message comes after one still missing. Queue this one |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
203 * for later use. */ |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
204 debug(1, "Got packet " + msgDicts[j].n + ", expected " + nrecv); |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
205 msgQ[msgDicts[j].n - nrecv - 1] = msgDicts[j]; |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
206 } |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
207 else { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
208 /* This message's number was encountered previously. */ |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
209 debug(1, "Discarding packet " + msgDicts[j].n + ", expected " + nrecv); |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
210 } |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
211 havedata = true; |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
212 } |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
213 else if (msgDicts[j].t == "T") { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
214 setTitle(msgDicts[j].d); |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
215 } |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
216 else if (msgDicts[j].t == "q") { |
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
217 gameover(); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
218 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
219 else { |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
220 debug(1, "Unrecognized server message " + msg); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
221 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
222 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
223 return havedata; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
224 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
225 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
226 function getData() { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
227 if (session.id == null) |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
228 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
229 var datareq = new XMLHttpRequest(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
230 var msg = JSON.stringify({"id": session.id, "t": "n"}); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
231 datareq.onreadystatechange = function () { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
232 if (datareq.readyState == 4 && datareq.status == 200) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
233 var wasdata = processMsg(datareq.responseText); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
234 if (wasdata != null) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
235 if (wasdata) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
236 ajaxstate.gotdata(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
237 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
238 ajaxstate.gotnothing(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
239 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
240 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
241 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
242 }; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
243 datareq.open('POST', '/feed', true); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
244 datareq.send(msg); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
245 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
246 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
247 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
248 function postResponseHandler() { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
249 if (this.readyState == 4 && this.status == 200) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
250 // We might want to do something with wasdata someday. |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
251 var wasdata = processMsg(this.responseText); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
252 ajaxstate.posted(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
253 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
254 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
255 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
256 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
257 function sendback(str) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
258 /* For responding to terminal queries. */ |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
259 var msgDict = {"id": session.id, "t": "d", "n": nsend++, "d": str}; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
260 var datareq = new XMLHttpRequest(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
261 datareq.onreadystatechange = postResponseHandler; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
262 datareq.open('POST', '/feed', true); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
263 datareq.send(JSON.stringify(msgDict)); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
264 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
265 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
266 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
267 function sendkey(ev) { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
268 if (!session.playing) |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
269 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
270 var keynum = ev.keyCode; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
271 var code; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
272 if (keynum >= ev.DOM_VK_A && keynum <= ev.DOM_VK_Z) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
273 /* Letters. This assumes the codes are 65-90. */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
274 if (ev.ctrlKey) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
275 keynum -= 64; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
276 else if (!ev.shiftKey) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
277 keynum += 32; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
278 code = keynum.toString(16); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
279 if (code.length < 2) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
280 code = "0" + code; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
281 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
282 else if (keynum >= ev.DOM_VK_0 && keynum <= ev.DOM_VK_9) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
283 /* The number row, NOT the numpad. */ |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
284 if (ev.shiftKey) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
285 code = numShifts[keynum - 48].toString(16); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
286 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
287 else { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
288 code = keynum.toString(16); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
289 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
290 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
291 else if (keynum in keyHexCodes) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
292 if (ev.shiftKey) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
293 code = keyHexCodes[keynum][1]; |
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 code = keyHexCodes[keynum][0]; |
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 if (keynum == ev.DOM_VK_SHIFT || keynum == ev.DOM_VK_CONTROL || |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
298 keynum == ev.DOM_VK_ALT || keynum == ev.DOM_VK_CAPS_LOCK) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
299 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
300 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
301 else { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
302 debug(1, "Ignoring keycode " + keynum); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
303 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
304 } |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
305 ev.preventDefault(); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
306 var datareq = new XMLHttpRequest(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
307 var msgDict = {"id": session.id, "t": "d", "n": nsend++, "d": code}; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
308 datareq.onreadystatechange = postResponseHandler; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
309 datareq.open('POST', '/feed', true); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
310 datareq.send(JSON.stringify(msgDict)); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
311 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
312 } |
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 var charshifts = { '-': "5f", '=': "2b", '[': "7b", ']': "7d", '\\': "7c", |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
315 ';': "3a", '\'': "22", ',': "3c", '.': "3e", '/': "3f", '`': "7e" |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
316 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
317 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
318 function vkey(c) { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
319 if (!session.playing) |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
320 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
321 var keystr; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
322 if (c.match(/^[a-z]$/)) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
323 if (termemu.ctrlp()) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
324 var n = c.charCodeAt(0) - 96; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
325 keystr = n.toString(16); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
326 if (keystr.length < 2) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
327 keystr = "0" + keystr; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
328 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
329 else if (termemu.shiftp()) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
330 keystr = c.toUpperCase().charCodeAt(0).toString(16); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
331 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
332 keystr = c.charCodeAt(0).toString(16); |
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 else if (c.match(/^[0-9]$/)) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
335 if (termemu.shiftp()) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
336 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
|
337 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
338 keystr = c.charCodeAt(0).toString(16); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
339 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
340 else if (c == '\n') |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
341 keystr = "0a"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
342 else if (c == '\t') |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
343 keystr = "09"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
344 else if (c == '\b') |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
345 keystr = "08"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
346 else if (c == ' ') |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
347 keystr = "20"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
348 else if (c in charshifts) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
349 if (termemu.shiftp()) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
350 keystr = charshifts[c]; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
351 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
352 keystr = c.charCodeAt(0).toString(16); |
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 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
355 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
356 var datareq = new XMLHttpRequest(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
357 var msgDict = {"id": session.id, "t": "d", "n": nsend++, "d": keystr}; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
358 datareq.onreadystatechange = postResponseHandler; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
359 datareq.open('POST', '/feed', true); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
360 datareq.send(JSON.stringify(msgDict)); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
361 return; |
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 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
364 function setup() { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
365 keyHexCodes.init(); |
4
ee22eb9ab009
Client: don't assume the terminal is 24x80.
John "Elwin" Edwards <elwin@sdf.org>
parents:
0
diff
changeset
|
366 termemu.init("termwrap", 24, 80); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
367 setTitle("Not connected."); |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
368 setmode("login"); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
369 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
370 } |
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 function toggleshift() { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
373 termemu.toggleshift(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
374 keydiv = document.getElementById("shiftkey"); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
375 if (termemu.shiftp()) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
376 keydiv.className = "keysel"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
377 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
378 keydiv.className = "key"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
379 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
380 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
381 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
382 function togglectrl() { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
383 termemu.togglectrl(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
384 keydiv = document.getElementById("ctrlkey"); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
385 if (termemu.ctrlp()) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
386 keydiv.className = "keysel"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
387 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
388 keydiv.className = "key"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
389 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
390 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
391 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
392 function formlogin(ev) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
393 ev.preventDefault(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
394 if (session.id != null) |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
395 return; |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
396 var loginmsg = {}; |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
397 loginmsg["name"] = document.getElementById("input_name").value; |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
398 loginmsg["pw"] = document.getElementById("input_pw").value; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
399 var req = new XMLHttpRequest(); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
400 req.onreadystatechange = function () { |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
401 if (req.readyState != 4 || req.status != 200) |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
402 return; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
403 var reply = JSON.parse(req.responseText); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
404 if (reply.t == 'l') { |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
405 /* Success */ |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
406 session.lcred = reply.k; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
407 session.lname = reply.u; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
408 setTitle("Logged in as " + reply.u); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
409 debug(1, "Logged in as " + reply.u + " with id " + reply.k); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
410 setmode("choose"); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
411 } |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
412 else if (reply.t == 'E') { |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
413 debug(1, "Could not log in: " + reply.s); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
414 document.getElementById("input_name").value = ""; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
415 document.getElementById("input_pw").value = ""; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
416 } |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
417 }; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
418 req.open('POST', '/login', true); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
419 req.send(JSON.stringify(loginmsg)); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
420 return; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
421 } |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
422 |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
423 function getcurrent() { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
424 if (session.id) |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
425 return; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
426 var req = new XMLHttpRequest(); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
427 req.onreadystatechange = function () { |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
428 if (req.readyState != 4 || req.status != 200) |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
429 return; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
430 var reply; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
431 try { |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
432 reply = JSON.parse(req.responseText); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
433 } catch (e) { |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
434 if (e instanceof SyntaxError) |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
435 return; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
436 } |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
437 if (!reply.s) { |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
438 return; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
439 } |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
440 var gamediv = document.getElementById("gametable"); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
441 while (gamediv.children.length > 2) |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
442 gamediv.removeChild(gamediv.children[2]); |
57
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
443 if (reply.g.length === 0) { |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
444 gamediv.style.display = "none"; |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
445 document.getElementById("nogames").style.display = "block"; |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
446 } |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
447 else { |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
448 gamediv.style.display = "table"; |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
449 document.getElementById("nogames").style.display = "none"; |
e7c864e80a79
RLG-Web client: explain when there are no games to watch
John "Elwin" Edwards <elwin@sdf.org>
parents:
56
diff
changeset
|
450 } |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
451 for (var i = 0; i < reply.g.length; i++) { |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
452 var row = document.createElement("div"); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
453 var cell1 = document.createElement("div"); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
454 var cell2 = document.createElement("div"); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
455 var cell3 = document.createElement("div"); |
66
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
456 var cell4 = document.createElement("div"); |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
457 cell1.appendChild(document.createTextNode(reply.g[i].p)); |
64
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
458 var uname = reply.g[i].g; |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
459 if (uname in games) |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
460 cell2.appendChild(document.createTextNode(games[uname].name)); |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
461 else { |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
462 debug(1, "Unrecognized game: " + uname); |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
463 continue; |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
464 } |
66
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
465 cell3.appendChild(document.createTextNode(idlestr(reply.g[i].i))); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
466 var button = document.createElement("span"); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
467 button.appendChild(document.createTextNode("Watch")); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
468 button.onclick = makeWatcher(reply.g[i].n); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
469 button.className = "ibutton"; |
66
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
470 cell4.appendChild(button); |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
471 row.appendChild(cell1); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
472 row.appendChild(cell2); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
473 row.appendChild(cell3); |
66
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
474 row.appendChild(cell4); |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
475 gamediv.appendChild(row); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
476 } |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
477 }; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
478 req.open('GET', '/status', true); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
479 req.send(); |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
480 return; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
481 } |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
482 |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
483 function getchoices() { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
484 if (session.id != null || !session.lcred) |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
485 return; |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
486 var req = new XMLHttpRequest(); |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
487 req.onreadystatechange = function () { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
488 if (req.readyState != 4 || req.status != 200) |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
489 return; |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
490 var reply; |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
491 try { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
492 reply = JSON.parse(req.responseText); |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
493 } catch (e) { |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
494 if (e instanceof SyntaxError) |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
495 return; |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
496 } |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
497 if (!("name" in reply) || reply["name"] != session.lname || |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
498 !("stat" in reply)) |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
499 return; |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
500 var optdiv = document.getElementById("opttable"); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
501 /* Don't remove the first child, it's the header. */ |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
502 while (optdiv.childNodes.length > 1) |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
503 optdiv.removeChild(optdiv.childNodes[1]); |
64
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
504 for (var gname in games) { |
e3082fd06520
Some status improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
63
diff
changeset
|
505 if (!(gname in reply.stat)) |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
506 continue; |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
507 var acttext; |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
508 if (reply.stat[gname] == "s") |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
509 acttext = "Resume your game"; |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
510 else if (reply.stat[gname] == "0") |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
511 acttext = "Start a game"; |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
512 else if (reply.stat[gname] == "p") |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
513 acttext = "Game in progress"; |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
514 else |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
515 continue; |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
516 var button = document.createElement("span"); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
517 button.appendChild(document.createTextNode(acttext)); |
46
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
518 if ("s0".indexOf(reply.stat[gname]) >= 0) { |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
519 button.onclick = makeStarter(gname); |
51
2eda3909f6a3
rlgterm.js: don't make nonfunctional button.
John "Elwin" Edwards <elwin@sdf.org>
parents:
47
diff
changeset
|
520 button.className = "ibutton"; |
46
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
521 } |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
522 var actdiv = document.createElement("div"); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
523 actdiv.appendChild(button); |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
524 var gamediv = document.createElement("div"); |
45
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
525 gamediv.appendChild(document.createTextNode(games[gname].name)); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
526 var rowdiv = document.createElement("div"); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
527 rowdiv.appendChild(gamediv); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
528 rowdiv.appendChild(actdiv); |
1bbd0e76ba92
RLG-Web: put the game options into a table.
John "Elwin" Edwards <elwin@sdf.org>
parents:
44
diff
changeset
|
529 optdiv.appendChild(rowdiv); |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
530 } |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
531 }; |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
532 req.open('GET', '/pstatus/' + session.lname, true); |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
533 req.send(); |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
534 return; |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
535 } |
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
536 |
46
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
537 /* This can't be in the loop in getchoices(), or the closure's scope will |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
538 * get overwritten on the next iteration, and then all the games end up |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
539 * being Super-Rogue. |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
540 */ |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
541 function makeStarter(gname) { |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
542 if (!(gname in games)) |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
543 return null; |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
544 var game = games[gname]; |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
545 function starter(ev) { |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
546 startgame(game); |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
547 } |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
548 return starter; |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
549 } |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
550 |
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
551 function startgame(game) { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
552 if (session.id != null || !session.lcred) |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
553 return; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
554 var smsg = {}; |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
555 smsg["key"] = session.lcred; |
46
59ecd99845eb
rlgterm.js: make the options table functional.
John "Elwin" Edwards <elwin@sdf.org>
parents:
45
diff
changeset
|
556 smsg["game"] = game.uname; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
557 smsg["h"] = 24; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
558 smsg["w"] = 80; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
559 var req = new XMLHttpRequest(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
560 req.onreadystatechange = function () { |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
561 if (req.readyState != 4 || req.status != 200) |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
562 return; |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
563 var reply = JSON.parse(req.responseText); |
55
96815eae4ebe
RLG-Web: make multiple watchers possible.
John "Elwin" Edwards <elwin@sdf.org>
parents:
51
diff
changeset
|
564 if (reply.t == 's') { |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
565 /* Success */ |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
566 session.id = reply.id; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
567 session.playing = true; |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
568 termemu.resize(reply.h, reply.w); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
569 setTitle("Playing as " + session.lname); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
570 debug(1, "Playing with id " + session.id); |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
571 setmode("play"); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
572 getData(); |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
573 } |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
574 else if (reply.t == 'E') { |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
575 debug(1, "Could not start game: " + reply.s); |
47
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
576 if (reply.c == 1) { |
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
577 logout(); |
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
578 } |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
579 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
580 }; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
581 req.open('POST', '/play', true); |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
582 req.send(JSON.stringify(smsg)); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
583 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
584 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
585 |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
586 function startwatching(gamenumber) { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
587 if (session.id != null) |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
588 return; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
589 var wmsg = {"n": Number(gamenumber)}; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
590 var req = new XMLHttpRequest(); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
591 req.onreadystatechange = function () { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
592 if (req.readyState != 4 || req.status != 200) |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
593 return; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
594 var reply = JSON.parse(req.responseText); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
595 if (reply.t == 'w') { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
596 /* Success */ |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
597 session.id = reply.id; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
598 session.playing = false; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
599 termemu.resize(reply.h, reply.w); |
61
071ec6b1ec03
RLG-Web client: initialize and restore the terminal when watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
59
diff
changeset
|
600 termemu.reset(); |
071ec6b1ec03
RLG-Web client: initialize and restore the terminal when watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
59
diff
changeset
|
601 termemu.toAltBuf(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
602 setTitle("Watching"); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
603 debug(1, "Watching with id " + session.id); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
604 setmode("play"); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
605 getData(); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
606 } |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
607 else if (reply.t == 'E') { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
608 debug(1, "Could not watch game " + gamenumber + ": " + reply.s); |
65
e63c26dc0497
RLG-Web client: refresh the current games list.
John "Elwin" Edwards <elwin@sdf.org>
parents:
64
diff
changeset
|
609 getcurrent(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
610 } |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
611 }; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
612 req.open('POST', '/watch', true); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
613 req.send(JSON.stringify(wmsg)); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
614 return; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
615 } |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
616 |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
617 function makeWatcher(n) { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
618 function watcher(ev) { |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
619 startwatching(n); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
620 } |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
621 return watcher; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
622 } |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
623 |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
624 function formreg(ev) { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
625 ev.preventDefault(); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
626 if (session.id != null) |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
627 return; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
628 var regmsg = {}; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
629 regmsg["name"] = document.getElementById("regin_name").value; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
630 regmsg["pw"] = document.getElementById("regin_pw").value; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
631 regmsg["email"] = document.getElementById("regin_email").value; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
632 var req = new XMLHttpRequest(); |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
633 req.onreadystatechange = function () { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
634 if (req.readyState != 4 || req.status != 200) |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
635 return; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
636 var reply = JSON.parse(req.responseText); |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
637 if (reply.t == 'r') { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
638 /* Success */ |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
639 debug(1, "Registered account: " + reply.d); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
640 session.lcred = reply.k; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
641 session.lname = reply.u; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
642 setTitle("Logged in as " + session.lname); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
643 debug(1, "Logged in as " + session.lname + "with id " + session.lcred); |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
644 setmode("choose"); |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
645 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
646 else if (reply.t == 'E') { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
647 debug(1, "Could not register: " + reply.s); |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
648 document.getElementById("regin_name").value = ""; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
649 document.getElementById("regin_pw").value = ""; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
650 document.getElementById("regin_email").value = ""; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
651 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
652 }; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
653 req.open('POST', '/addacct', true); |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
654 req.send(JSON.stringify(regmsg)); |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
655 return; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
656 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
657 |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
658 function gameover() { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
659 if (session.id == null) |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
660 return; |
38
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
661 /* TODO IFACE2 If the end was unexpected, tell player the game was saved. */ |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
662 session.id = null; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
663 session.playing = false; |
38
b06a14876645
RLG-Web: reduce polling further.
John "Elwin" Edwards <elwin@sdf.org>
parents:
35
diff
changeset
|
664 ajaxstate.clear(); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
665 setTitle("Game over."); |
61
071ec6b1ec03
RLG-Web client: initialize and restore the terminal when watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
59
diff
changeset
|
666 termemu.toNormBuf(); |
16
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
667 nsend = 0; |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
668 nrecv = 0; |
ef6127ed6da3
RLGWeb: switch to JSON protocol.
John "Elwin" Edwards <elwin@sdf.org>
parents:
9
diff
changeset
|
669 msgQ = []; |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
670 if (session.lcred != null) |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
671 setmode("choose"); |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
672 else |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
673 setmode("login"); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
674 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
675 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
676 |
47
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
677 function logout() { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
678 session.lcred = null; |
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
679 session.lname = null; |
47
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
680 setmode("login"); |
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
681 } |
27b7f0c8b9f0
RLG-Web: make login sessions time out.
John "Elwin" Edwards <elwin@sdf.org>
parents:
46
diff
changeset
|
682 |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
683 function stop() { |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
684 if (!session.id) |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
685 return; |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
686 var req = new XMLHttpRequest(); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
687 req.onreadystatechange = function () { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
688 if (req.readyState == 4 && req.status == 200) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
689 processMsg(req.responseText); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
690 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
691 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
692 }; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
693 req.open('POST', '/feed', true); |
59
00b985b8ba6a
RLG-Web client: implement watching.
John "Elwin" Edwards <elwin@sdf.org>
parents:
58
diff
changeset
|
694 req.send(JSON.stringify({"id": session.id, "t": "q"})); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
695 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
696 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
697 |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
698 function setmode(mode, ev) { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
699 if (ev) |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
700 ev.preventDefault(); |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
701 if (mode == "play") { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
702 document.getElementById("keyboard").style.display = "block"; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
703 document.getElementById("startgame").style.display = "none"; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
704 document.getElementById("login").style.display = "none"; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
705 document.getElementById("register").style.display = "none"; |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
706 document.getElementById("current").style.display = "none"; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
707 } |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
708 if (mode == "choose") { |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
709 document.getElementById("keyboard").style.display = "none"; |
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
710 document.getElementById("startgame").style.display = "block"; |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
711 document.getElementById("login").style.display = "none"; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
712 document.getElementById("register").style.display = "none"; |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
713 document.getElementById("current").style.display = "block"; |
44
b848cb50cd69
rlgterm.js: present game options to the player.
John "Elwin" Edwards <elwin@sdf.org>
parents:
41
diff
changeset
|
714 getchoices(); |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
715 getcurrent(); |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
716 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
717 else if (mode == "login") { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
718 document.getElementById("keyboard").style.display = "none"; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
719 document.getElementById("startgame").style.display = "none"; |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
720 document.getElementById("login").style.display = "block"; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
721 document.getElementById("register").style.display = "none"; |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
722 document.getElementById("current").style.display = "block"; |
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
723 getcurrent(); |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
724 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
725 else if (mode == "register") { |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
726 document.getElementById("keyboard").style.display = "none"; |
39
e8ac0e3d2614
RLG-Web: separate logging in and starting a game.
John "Elwin" Edwards <elwin@sdf.org>
parents:
38
diff
changeset
|
727 document.getElementById("startgame").style.display = "none"; |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
728 document.getElementById("login").style.display = "none"; |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
729 document.getElementById("register").style.display = "block"; |
56
7f3ca16409fe
RLG-Web client: display a list of current games.
John "Elwin" Edwards <elwin@sdf.org>
parents:
55
diff
changeset
|
730 document.getElementById("current").style.display = "none"; |
19
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
731 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
732 } |
188bbd857124
RLG-Web: add user registration
John "Elwin" Edwards <elwin@sdf.org>
parents:
16
diff
changeset
|
733 |
67
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
734 function toggledebug() { |
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
735 if (document.getElementById("debug").style.display != "block") |
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
736 document.getElementById("debug").style.display = "block"; |
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
737 else |
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
738 document.getElementById("debug").style.display = "none"; |
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
739 } |
b6a3b26fe0dc
RLG-Web client: some visual improvements.
John "Elwin" Edwards <elwin@sdf.org>
parents:
66
diff
changeset
|
740 |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
741 function debug(level, msg) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
742 if (level < debugSuppress) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
743 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
744 var msgdiv = document.createElement("div"); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
745 var msgtext = document.createTextNode(msg); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
746 msgdiv.appendChild(msgtext); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
747 document.getElementById("debug").appendChild(msgdiv); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
748 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
749 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
750 |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
751 function textsize(larger) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
752 var cssSize = termemu.view.style.fontSize; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
753 if (!cssSize) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
754 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
755 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
756 var match = cssSize.match(/\d*/); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
757 if (!match) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
758 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
759 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
760 var csize = Number(match[0]); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
761 var nsize; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
762 if (larger) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
763 if (csize >= 48) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
764 nsize = 48; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
765 else if (csize >= 20) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
766 nsize = csize + 4; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
767 else if (csize >= 12) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
768 nsize = csize + 2; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
769 else if (csize >= 8) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
770 nsize = csize + 1; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
771 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
772 nsize = 8; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
773 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
774 else { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
775 if (csize <= 8) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
776 nsize = 8; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
777 else if (csize <= 12) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
778 nsize = csize - 1; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
779 else if (csize <= 20) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
780 nsize = csize - 2; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
781 else if (csize <= 48) |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
782 nsize = csize - 4; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
783 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
784 nsize = 48; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
785 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
786 document.getElementById("term").style.fontSize = nsize.toString() + "px"; |
9
826a7ced69f8
Make the emulator screen resizable.
John "Elwin" Edwards <elwin@sdf.org>
parents:
6
diff
changeset
|
787 termemu.fixsize(); |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
788 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
|
789 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
790 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
791 |
66
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
792 function idlestr(ms) { |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
793 if (typeof(ms) != "number") |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
794 return "?"; |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
795 var seconds = Math.round(ms / 1000); |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
796 var ss = String(seconds % 60); |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
797 if (ss.length < 2) |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
798 ss = "0" + ss; |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
799 var mm = String(Math.floor((seconds % 3600) / 60)); |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
800 if (mm.length < 2) |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
801 mm = "0" + mm; |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
802 var hh = String(Math.floor(seconds / 3600)); |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
803 if (hh.length < 2) |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
804 hh = "0" + hh; |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
805 return hh + ":" + mm + ":" + ss; |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
806 } |
57bf0dcd080e
Display idle time of games in progress.
John "Elwin" Edwards <elwin@sdf.org>
parents:
65
diff
changeset
|
807 |
0
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
808 function bell(on) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
809 var imgnode = document.getElementById("bell"); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
810 if (on) { |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
811 imgnode.style.visibility = "visible"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
812 window.setTimeout(bell, 1500, false); |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
813 } |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
814 else |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
815 imgnode.style.visibility = "hidden"; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
816 return; |
bd412f63ce0d
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
817 } |