Christian Fraß commited on 2021-11-19 01:20:59
Zeige 3 geänderte Dateien mit 14 Einfügungen und 9 Löschungen.
... | ... |
@@ -22,11 +22,11 @@ |
22 | 22 |
</form> |
23 | 23 |
</div> |
24 | 24 |
<div id="wait"> |
25 |
- <span>loading …</span> |
|
25 |
+ <span>connecting …</span> |
|
26 | 26 |
</div> |
27 | 27 |
<div id="main"> |
28 | 28 |
<div id="head"> |
29 |
- <button id="disconnect">exit</button> |
|
29 |
+ <button id="disconnect">disconnect</button> |
|
30 | 30 |
</div> |
31 | 31 |
<div id="middle"> |
32 | 32 |
<ul class="pane" id="history"></ul> |
... | ... |
@@ -1,11 +1,14 @@ |
1 | 1 |
type int = number; |
2 | 2 |
type float = number; |
3 | 3 |
|
4 |
+ |
|
4 | 5 |
var _conf: any = null; |
5 |
-var _state: (null | string) = null; |
|
6 |
-var _channel: (null | string) = null; |
|
7 |
-var _nickname: (null | string) = null; |
|
8 |
-var _userhash: (null | string) = null; |
|
6 |
+var _state: string = undefined; |
|
7 |
+var _channel: string = undefined; |
|
8 |
+var _nickname: string = undefined; |
|
9 |
+var _userhash: string = undefined; |
|
10 |
+var _id: (null | string) = null; |
|
11 |
+ |
|
9 | 12 |
|
10 | 13 |
function get_timestamp(): int |
11 | 14 |
{ |
... | ... |
@@ -29,7 +35,7 @@ async function backend_call(action: string, data: any): Promise<any> |
29 | 35 |
`${_conf.backend.scheme}://${_conf.backend.host}:${_conf.backend.port.toFixed(0)}`, |
30 | 36 |
{ |
31 | 37 |
"method": "POST", |
32 |
- "body": JSON.stringify({"action": action, "data": data}), |
|
38 |
+ "body": JSON.stringify({"action": action, "id": _id, "data": data}), |
|
33 | 39 |
} |
34 | 40 |
); |
35 | 41 |
if (response.ok) { |
... | ... |
@@ -165,7 +177,7 @@ function setup_control(): void |
165 | 177 |
let dom_channel: HTMLInputElement = document.querySelector<HTMLInputElement>("#channel"); |
166 | 178 |
const nickname: string = dom_nickname.value; |
167 | 179 |
const channel: string = dom_channel.value; |
168 |
- await backend_call( |
|
180 |
+ const id: string = await backend_call( |
|
169 | 181 |
"connect", |
170 | 182 |
{ |
171 | 183 |
"server": _conf["irc"]["server"], |
... | ... |
@@ -173,6 +185,7 @@ function setup_control(): void |
173 | 185 |
"nickname": nickname, |
174 | 186 |
} |
175 | 187 |
); |
188 |
+ _id = id; |
|
176 | 189 |
_channel = channel; |
177 | 190 |
_nickname = nickname; |
178 | 191 |
set_state("checking"); |
... | ... |
@@ -186,6 +199,7 @@ function setup_control(): void |
186 | 199 |
null |
187 | 200 |
); |
188 | 201 |
set_state("offline"); |
202 |
+ _id = null; |
|
189 | 203 |
} |
190 | 204 |
); |
191 | 205 |
document.querySelector("#main > form").addEventListener( |