blob: ab5ed158f31ab1e30baabd22e8be2e03e2c10a51 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
export default class Helpers {
//@ts-expect-error
readonly chatListScroll = $("#chatlist").tinyscrollbar();
isColor(strColor: string): boolean {
const s = new Option().style;
s.color = strColor;
return s.color !== "";
}
suicide(msg: string): void {
document.body.innerHTML = /* html */ `
<div class="text-center" style="margin: 45vh auto; font-size: 3em;">${msg}</div>
`;
throw new Error(
"This page has committed suicide by design, that's a feature!"
);
}
updateScrollbar(update: string) {
$(this.chatListScroll).data().plugin_tinyscrollbar.update(update);
}
get getRandomColor(): string {
return "#" + (Math.random().toString(16) + "000000").substring(2, 8);
}
get getUsername(): string {
let username = prompt("Gimme your name: ");
if (username === null) {
this.suicide("You should give me your name!");
throw new Error("NoNameError");
}
username = username.trim();
if (username === "Server") {
this.suicide("That name is illegal!");
throw new Error("IllegalNameError");
}
return username;
}
}
|