-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserElement.js
65 lines (57 loc) · 1.83 KB
/
UserElement.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
export default class UserElement {
username;
roomId;
rank;
icons;
clan;
bIgnored;
userPanel;
constructor(userPanel, username, clan, rank, icons) {
this.userPanel = userPanel;
this.roomId = -1;
this.username = username;
this.clan = clan;
this.rank = rank;
this.icons = icons;
}
// implement a way to get an HTML representation of this element
toHtml() {
// TODO - add a click handler to bring up a dialog box for this user to see stats and whisper to them
// make a new table row
const tableRow = document.createElement("tr");
tableRow.className = "userElementRow";
tableRow.id = `user:${this.username}`;
const clanElement = document.createElement("td");
const usernameElement = document.createElement("td");
const roomIndexElement = document.createElement("td");
const rankElement = document.createElement("td");
clanElement.innerText = this.clan;
usernameElement.innerText = this.username;
roomIndexElement.innerText = this.userPanel.gamePanel.lobbyPanel.roomPanel
.roomIndex(this.roomId);
// TODO - use graphic for rank rather than text
rankElement.innerText = this.rank;
tableRow.appendChild(clanElement);
tableRow.appendChild(usernameElement);
tableRow.appendChild(roomIndexElement);
tableRow.appendChild(rankElement);
return tableRow;
}
// maybe used for sorting the elements,
// will sort by the username or rank
// compareTo(element) {
// if (element == null || !(element instanceof UserElement)) {
// return 0;
// }
// let b = cfUserElement.getIcons().length > 0;
// if (b == this.icons.length > 0) {
// return this.name
// .toLowerCase()
// .compareTo(cfUserElement.getName().toLowerCase());
// }
// if (b) {
// return 1;
// }
// return -1;
// }
}