Changeset View
Changeset View
Standalone View
Standalone View
web/static/js/widgets/chatroom.js
- This file was added.
class ChatRoomWidget | |||||
{ | |||||
constructor(id, config) | |||||
{ | |||||
this.config = config || {} | |||||
this.id = id | |||||
this.render() | |||||
} | |||||
/** | |||||
* Renders text chat room widget | |||||
*/ | |||||
render() | |||||
{ | |||||
} | |||||
/** | |||||
* Appends text message to the chat room widget | |||||
*/ | |||||
append(user, text) | |||||
{ | |||||
user = ChatRoomWidget.sanitize(user) | |||||
text = ChatRoomWidget.sanitize(text) | |||||
$("#" + this.id).append(`<p><b>[${user}]</b>: ${text}</p>`) | |||||
} | |||||
static sanitize(str) | |||||
{ | |||||
return $("<div/>").text(str).html() | |||||
} | |||||
} | |||||
export default ChatRoomWidget |