summaryrefslogtreecommitdiff
path: root/client-web/source/user/mod.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client-web/source/user/mod.ts')
-rw-r--r--client-web/source/user/mod.ts37
1 files changed, 11 insertions, 26 deletions
diff --git a/client-web/source/user/mod.ts b/client-web/source/user/mod.ts
index 2ff60a8..e83c2e6 100644
--- a/client-web/source/user/mod.ts
+++ b/client-web/source/user/mod.ts
@@ -5,41 +5,26 @@
*/
/// <reference lib="dom" />
-import { epre, espan } from "../helper.ts";
+import { ediv, epre, espan } from "../helper.ts";
import { ROOM_CONTAINER } from "../index.ts";
-import { Resource } from "../resource/mod.ts";
-import { Room } from "../room.ts"
+import { Room } from "../room.ts";
-export abstract class User {
- public el: HTMLElement
- public local = false
- public resources: Map<string, Resource> = new Map()
-
- private name_el = espan("")
- protected stats_el = epre("", { class: "stats" })
+export class User {
private _name?: string
+ set name(v: string | undefined) { this._name = v; this.name_el.textContent = this.display_name }
get name() { return this._name }
- set name(n: string | undefined) { this._name = n; this.name_el.textContent = this.display_name }
- get display_name() { return this.name ?? `unknown (${this.id})` }
-
- constructor(public room: Room, public id: number) {
- room.users.set(this.id, this)
+ get display_name() { return this.name ?? "Unknown" }
- this.el = document.createElement("div")
- this.el.classList.add("user")
- ROOM_CONTAINER.append(this.el)
- this.setup_view()
- }
- leave() {
- this.room.users.delete(this.id)
- }
+ name_el = espan(this.display_name)
+ stats_el = epre("")
+ el = ediv({ class: "user" })
- setup_view() {
- const info_el = document.createElement("div")
- info_el.classList.add("info")
+ constructor(public room: Room, public id: number) {
+ const info_el = ediv({ class: "info" })
this.name_el.textContent = this.display_name
this.name_el.classList.add("name")
info_el.append(this.name_el, this.stats_el)
this.el.append(info_el)
+ ROOM_CONTAINER.append(this.el)
}
} \ No newline at end of file