poker-html-client
Version:
HTML client for online poker
34 lines (29 loc) • 1.13 kB
text/typescript
import * as ko from "knockout";
import * as authManager from "../authmanager";
export class PlayerMessage {
public messageId: number;
public sender: string;
public message: KnockoutObservable<string>;
public fullMessage: KnockoutComputed<string>;
public date: string;
public isMy: KnockoutObservable<boolean>;
public isAdmin: boolean;
constructor(messageId: number, sender: string, message: string) {
this.messageId = messageId;
this.isAdmin = false;
if (sender.toLowerCase() === "admin") {
this.isAdmin = true;
}
this.isMy = ko.observable(authManager.login() === sender);
authManager.authenticated.subscribe(() => {
this.isMy(authManager.login() === sender);
});
this.sender = sender;
this.message = ko.observable(message);
const d = new Date();
this.date = d.getHours() + ":" + d.getMinutes();
this.fullMessage = ko.computed(() => {
return "[" + this.date + "]" + this.sender + " - " + this.message();
});
}
}