-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchat-log.js
More file actions
25 lines (21 loc) · 936 Bytes
/
Copy pathchat-log.js
File metadata and controls
25 lines (21 loc) · 936 Bytes
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
"use strict";
var Chat = Chat || {};
Chat.Log = (function() {
// Log extends HTMLElement.
var Log = Object.create(HTMLElement.prototype);
// Takes a message, creates a new <chat-message> element, appends it to
// the chat log and scrolls the log to the bottom.
//
// Example message element: <chat-message user="audre" timestamp="123455677">Hi.</chat-message>
//
// Returns the created <chat-message>.
// Message is a chat room message object (see README.md for the structure).
Log.append = function(message) {
// TODO: make a DOM element to hold the message with document.createElement.
// (The styles are already in place for 'chat-message' elements, so you
// probably want to make one of those).
// TODO: add attributes for the timestamp and user.
// TODO: append a message element to the log
};
return document.registerElement('chat-log', { prototype: Log });
})();