JSDoc for www/js/channel/*.js complete. Just need to hadnle ww/js/channel/panels.
This commit is contained in:
parent
ac06f839ea
commit
c0f219276f
91 changed files with 38653 additions and 104 deletions
|
|
@ -13,11 +13,28 @@ GNU Affero General Public License for more details.
|
|||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
/**
|
||||
* Class contianing client-side message post-processing code
|
||||
*/
|
||||
class chatPostprocessor{
|
||||
/**
|
||||
* Instantiates a new Chat Post-Processor object
|
||||
* @param {channel} client - Parent client Management Object
|
||||
*/
|
||||
constructor(client){
|
||||
/**
|
||||
* Parent Client Management Object
|
||||
*/
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-Processes a single message from the server and returns a presntable DOM Node
|
||||
* @param {Node} chatEntry - Chat entry generated by initial chatBox method
|
||||
* @param {Object} rawData - Raw data from server
|
||||
* @returns {Node} Post-Processed Chat Entry
|
||||
*/
|
||||
postprocess(chatEntry, rawData){
|
||||
//Create empty array to hold filter spans
|
||||
this.filterSpans = [];
|
||||
|
|
@ -30,6 +47,7 @@ class chatPostprocessor{
|
|||
//Split the chat message into an array of objects representing each word/chunk
|
||||
this.splitMessage();
|
||||
|
||||
//Process Qoutes
|
||||
this.processQoute();
|
||||
|
||||
//Re-Hydrate and Inject links and embedded media into un-processed placeholders
|
||||
|
|
@ -62,13 +80,16 @@ class chatPostprocessor{
|
|||
//Handle non-standard chat types
|
||||
this.handleChatType();
|
||||
|
||||
//Inject the pre-processed chat into the chatEntry node
|
||||
//Inject the pre-processed chat hyper-text into the chatEntry node
|
||||
this.injectBody();
|
||||
|
||||
//Return the pre-processed node
|
||||
return this.chatEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits message into an array of Word Objects for further processing
|
||||
*/
|
||||
splitMessage(){
|
||||
//Create an empty array to hold the body
|
||||
this.messageArray = [];
|
||||
|
|
@ -93,6 +114,9 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects word objects into chat-entry as proper DOM Nodes
|
||||
*/
|
||||
injectBody(){
|
||||
//Create an empty array to hold the objects to inject
|
||||
const injectionArray = [];
|
||||
|
|
@ -285,6 +309,9 @@ class chatPostprocessor{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes qouted text in chat
|
||||
*/
|
||||
processQoute(){
|
||||
//If the message starts off with '>'
|
||||
if(this.messageArray[0].string[0] == '>'){
|
||||
|
|
@ -292,6 +319,9 @@ class chatPostprocessor{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes clickable command examples in chat
|
||||
*/
|
||||
processCommandExamples(){
|
||||
//for each word object in the body
|
||||
this.messageArray.forEach((wordObj, wordIndex) => {
|
||||
|
|
@ -324,6 +354,9 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes clickable channel names in chat
|
||||
*/
|
||||
processChannelNames(){
|
||||
//for each word object in the body
|
||||
this.messageArray.forEach((wordObj, wordIndex) => {
|
||||
|
|
@ -356,6 +389,9 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes clickable username callouts in chat
|
||||
*/
|
||||
processUsernames(){
|
||||
//for each word object in the body
|
||||
this.messageArray.forEach((wordObj, wordIndex) => {
|
||||
|
|
@ -375,6 +411,9 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects invisible whitespace in long-ass words to prevent fucking up the chat buffer size
|
||||
*/
|
||||
addWhitespace(){
|
||||
//for each word object in the body
|
||||
this.messageArray.forEach((wordObj, wordIndex) => {
|
||||
|
|
@ -400,6 +439,14 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for text in-between a specific delimiter and runs a given callback against it
|
||||
*
|
||||
* Internal command used by several text filters to prevent code re-writes
|
||||
* @param {String} delimiter - delimiter to search string by
|
||||
* @param {Function} cb - Callback function to run against found strings
|
||||
* @returns {Array} - list of found instances of filter
|
||||
*/
|
||||
processFilter(delimiter, cb){
|
||||
//Create empty array to hold spoilers (keep this seperate at first for internal function use)
|
||||
const foundFilters = [];
|
||||
|
|
@ -451,6 +498,9 @@ class chatPostprocessor{
|
|||
return foundFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes in-line spoilers
|
||||
*/
|
||||
processSpoilers(){
|
||||
//Process spoilers using '##' delimiter
|
||||
this.processFilter('##', (foundSpoiler)=>{
|
||||
|
|
@ -459,6 +509,9 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes in-line Strike-through
|
||||
*/
|
||||
processStrikethrough(){
|
||||
//Process strikethrough's using '~~' delimiter
|
||||
this.processFilter('~~', (foundStrikethrough)=>{
|
||||
|
|
@ -468,6 +521,9 @@ class chatPostprocessor{
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes in-line Bold/Strong text
|
||||
*/
|
||||
processBold(){
|
||||
//Process strong text using '*' delimiter
|
||||
this.processFilter('**', (foundStrikethrough)=>{
|
||||
|
|
@ -477,6 +533,9 @@ class chatPostprocessor{
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes in-line Italics
|
||||
*/
|
||||
processItalics(){
|
||||
//Process italics using '__' delimiter
|
||||
this.processFilter('*', (foundStrikethrough)=>{
|
||||
|
|
@ -486,6 +545,9 @@ class chatPostprocessor{
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes clickable links and embedded media
|
||||
*/
|
||||
processLinks(){
|
||||
//If we don't have links
|
||||
if(this.rawData.links == null){
|
||||
|
|
@ -513,6 +575,9 @@ class chatPostprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks chat nodes in-case of non-standard chat types
|
||||
*/
|
||||
handleChatType(){
|
||||
if(this.rawData.type == "whisper"){
|
||||
//add whisper class
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue