Started work on client-side private message post-processing
This commit is contained in:
parent
e1cdca2b96
commit
faf72fd7a5
3 changed files with 53 additions and 56 deletions
|
|
@ -35,13 +35,13 @@ class chatPostprocessor{
|
|||
* @param {Object} rawData - Raw data from server
|
||||
* @returns {Node} Post-Processed Chat Entry
|
||||
*/
|
||||
postprocess(chatEntry, rawData){
|
||||
postprocess(rawData){
|
||||
//Create empty array to hold filter spans
|
||||
this.filterSpans = [];
|
||||
//Set raw message data
|
||||
this.rawData = rawData;
|
||||
//Set current chat nodes
|
||||
this.chatEntry = chatEntry;
|
||||
this.buildEntry();
|
||||
this.chatBody = this.chatEntry.querySelector(".chat-entry-body");
|
||||
|
||||
//Split the chat message into an array of objects representing each word/chunk
|
||||
|
|
@ -87,6 +87,48 @@ class chatPostprocessor{
|
|||
return this.chatEntry;
|
||||
}
|
||||
|
||||
buildEntry(){
|
||||
//Create chat-entry span
|
||||
this.chatEntry = document.createElement('span');
|
||||
this.chatEntry.classList.add("chat-panel-buffer","chat-entry",`chat-entry-${this.rawData.user}`);
|
||||
|
||||
//Create high-level label
|
||||
var highLevel = document.createElement('p');
|
||||
highLevel.classList.add("chat-panel-buffer","chat-entry-high-level","high-level");
|
||||
highLevel.textContent = utils.unescapeEntities(`${this.rawData.highLevel}`);
|
||||
this.chatEntry.appendChild(highLevel);
|
||||
|
||||
//If we're not using classic flair
|
||||
if(this.rawData.flair != "classic"){
|
||||
//Use flair
|
||||
var flair = `flair-${this.rawData.flair}`;
|
||||
//Otherwise
|
||||
}else{
|
||||
//Pull user's assigned color from the color map
|
||||
var flair = this.client.userList.colorMap.get(this.rawData.user);
|
||||
}
|
||||
|
||||
//Create username label
|
||||
var userLabel = document.createElement('p');
|
||||
userLabel.classList.add("chat-panel-buffer", "chat-entry-username", );
|
||||
|
||||
//Create color span
|
||||
var flairSpan = document.createElement('span');
|
||||
flairSpan.classList.add("chat-entry-flair-span", flair);
|
||||
flairSpan.innerHTML = this.rawData.user;
|
||||
|
||||
//Inject flair span into user label before the colon
|
||||
userLabel.innerHTML = `${flairSpan.outerHTML}: `;
|
||||
|
||||
//Append user label
|
||||
this.chatEntry.appendChild(userLabel);
|
||||
|
||||
//Create chat body
|
||||
var chatBody = document.createElement('p');
|
||||
chatBody.classList.add("chat-panel-buffer","chat-entry-body");
|
||||
this.chatEntry.appendChild(chatBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits message into an array of Word Objects for further processing
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue