Finished up work on advanced formatted private messaging.

This commit is contained in:
rainbow napkin 2025-10-03 08:58:43 -04:00
parent faf72fd7a5
commit 2feea72694
11 changed files with 164 additions and 94 deletions

View file

@ -35,14 +35,13 @@ class chatPostprocessor{
* @param {Object} rawData - Raw data from server
* @returns {Node} Post-Processed Chat Entry
*/
postprocess(rawData){
postprocess(rawData, pm = false){
//Create empty array to hold filter spans
this.filterSpans = [];
//Set raw message data
this.rawData = rawData;
//Set current chat nodes
this.buildEntry();
this.chatBody = this.chatEntry.querySelector(".chat-entry-body");
this.buildEntry(pm);
//Split the chat message into an array of objects representing each word/chunk
this.splitMessage();
@ -87,14 +86,16 @@ class chatPostprocessor{
return this.chatEntry;
}
buildEntry(){
buildEntry(pm){
const classSuffix = pm ? 'pm-panel-sesh' : 'chat';
const classSuffixAlt = pm ? classSuffix : 'chat-panel';
//Create chat-entry span
this.chatEntry = document.createElement('span');
this.chatEntry.classList.add("chat-panel-buffer","chat-entry",`chat-entry-${this.rawData.user}`);
this.chatEntry.classList.add(`${classSuffixAlt}-buffer`,`${classSuffix}-entry`,`${classSuffix}-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.classList.add(`${classSuffixAlt}-buffer`,`${classSuffix}-entry-high-level`,"high-level");
highLevel.textContent = utils.unescapeEntities(`${this.rawData.highLevel}`);
this.chatEntry.appendChild(highLevel);
@ -110,11 +111,11 @@ class chatPostprocessor{
//Create username label
var userLabel = document.createElement('p');
userLabel.classList.add("chat-panel-buffer", "chat-entry-username", );
userLabel.classList.add(`${classSuffixAlt}-buffer`, `${classSuffix}-entry-username`, );
//Create color span
var flairSpan = document.createElement('span');
flairSpan.classList.add("chat-entry-flair-span", flair);
flairSpan.classList.add(`${classSuffix}-entry-flair-span`, flair);
flairSpan.innerHTML = this.rawData.user;
//Inject flair span into user label before the colon
@ -124,9 +125,11 @@ class chatPostprocessor{
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);
this.chatBody = document.createElement('p');
this.chatBody.classList.add(`${classSuffixAlt}-buffer`,`${classSuffix}-entry-body`);
//Append chat body to chat entry
this.chatEntry.appendChild(this.chatBody);
}
/**