import {UIElement} from "./UIElement"; import {UserDetails} from "../Logic/OsmConnection"; import {UIEventSource} from "./UIEventSource"; /** * Handles and updates the user badge */ export class UserBadge extends UIElement { private _userDetails: UIEventSource; private _pendingChanges: UIElement; constructor(userDetails: UIEventSource, pendingChanges : UIElement) { super(userDetails); this._userDetails = userDetails; this._pendingChanges = pendingChanges; userDetails.addCallback(function () { const profilePic = document.getElementById("profile-pic"); profilePic.onload = function () { profilePic.style.opacity = "1" }; }); } protected InnerRender(): string { const user = this._userDetails.data; if (!user.loggedIn) { return "
Klik hier om aan te melden bij OSM
"; } let messageSpan = "" + " " + user.totalMessages + ""; if (user.unreadMessages > 0) { messageSpan = "" + " " + " " + "" + user.unreadMessages.toString() + ""; } let dryrun = ""; if (user.dryRun) { dryrun = " TESTING"; } return " " + "
" + "

" + "" + user.name + "" + dryrun + "

" + "

" + messageSpan + " " + " " + user.csCount + " " + this._pendingChanges.Render() + "

" + "
"; } InnerUpdate(htmlElement: HTMLElement) { this._pendingChanges.Update(); } Activate() { this._pendingChanges.Activate(); } }