Started work on JSDoc for www/js/channel
This commit is contained in:
parent
5ad20f6823
commit
ac06f839ea
97 changed files with 18556 additions and 91 deletions
|
|
@ -13,10 +13,29 @@ 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 for object containing chat and command pre-processing logic
|
||||
*/
|
||||
class commandPreprocessor{
|
||||
/**
|
||||
* Instantiates a new commandPreprocessor object
|
||||
* @param {channel} client - Parent client Management Object
|
||||
*/
|
||||
constructor(client){
|
||||
/**
|
||||
* Parent Client Management object
|
||||
*/
|
||||
this.client = client;
|
||||
|
||||
/**
|
||||
* Child Command Processor object
|
||||
*/
|
||||
this.commandProcessor = new commandProcessor(client);
|
||||
|
||||
/**
|
||||
* Set of arrays containing site-wide, channel-wide, and user-specific emotes
|
||||
*/
|
||||
this.emotes = {
|
||||
site: [],
|
||||
chan: [],
|
||||
|
|
@ -27,6 +46,9 @@ class commandPreprocessor{
|
|||
this.defineListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines Network-Related Listeners
|
||||
*/
|
||||
defineListeners(){
|
||||
//When we receive site-wide emote list
|
||||
this.client.socket.on("siteEmotes", this.setSiteEmotes.bind(this));
|
||||
|
|
@ -35,21 +57,34 @@ class commandPreprocessor{
|
|||
this.client.socket.on("usedTokes", this.setUsedTokes.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-Processes a single chat/command before sending it off to the server
|
||||
* @param {String} command - Chat/Command to pre-process
|
||||
*/
|
||||
preprocess(command){
|
||||
//Set command and sendFlag
|
||||
this.command = command;
|
||||
this.sendFlag = true;
|
||||
|
||||
//Attempt to process as local command
|
||||
this.processLocalCommand();
|
||||
|
||||
//If we made it through the local command processor
|
||||
if(this.sendFlag){
|
||||
//Set the message to the command
|
||||
this.message = command;
|
||||
//Process message emotes into links
|
||||
this.processEmotes();
|
||||
//Process unmarked links into marked links
|
||||
this.processLinks();
|
||||
//Send command off to server
|
||||
this.sendRemoteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes local commands, starting with '/'
|
||||
*/
|
||||
processLocalCommand(){
|
||||
//Create an empty array to hold the command
|
||||
this.commandArray = [];
|
||||
|
|
@ -70,6 +105,9 @@ class commandPreprocessor{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes emotes refrences in loaded message into links to be further processed by processLinks()
|
||||
*/
|
||||
processEmotes(){
|
||||
//inject invisible whitespace in-between emotes to prevent from mushing links together
|
||||
this.message = this.message.replaceAll('][',']ㅤ[');
|
||||
|
|
@ -84,6 +122,9 @@ class commandPreprocessor{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes links into numbered file seperators, putting links into a dedicated array.
|
||||
*/
|
||||
processLinks(){
|
||||
//Strip out file seperators in-case the user is being a smart-ass
|
||||
this.message = this.message.replaceAll('␜','');
|
||||
|
|
@ -109,26 +150,50 @@ class commandPreprocessor{
|
|||
this.message = splitMessage.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits message/command off to server
|
||||
*/
|
||||
sendRemoteCommand(){
|
||||
this.client.socket.emit("chatMessage",{msg: this.message, links: this.links});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets site emotes
|
||||
* @param {Object} data - Emote data from server
|
||||
*/
|
||||
setSiteEmotes(data){
|
||||
this.emotes.site = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets channel emotes
|
||||
* @param {Object} data - Emote data from server
|
||||
*/
|
||||
setChanEmotes(data){
|
||||
this.emotes.chan = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets personal emotes
|
||||
* @param {Object} data - Emote data from server
|
||||
*/
|
||||
setPersonalEmotes(data){
|
||||
this.emotes.personal = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets used tokes
|
||||
* @param {Object} data - Used toke data from server
|
||||
*/
|
||||
setUsedTokes(data){
|
||||
this.usedTokes = data.tokes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches emote by link
|
||||
* @param {String} link - Link to fetch emote with
|
||||
* @returns {Object} found emote
|
||||
*/
|
||||
getEmoteByLink(link){
|
||||
//Create an empty variable to hold the found emote
|
||||
var foundEmote = null;
|
||||
|
|
@ -148,6 +213,10 @@ class commandPreprocessor{
|
|||
return foundEmote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates flat list of emote names
|
||||
* @returns {Array} List of strings containing emote names
|
||||
*/
|
||||
getEmoteNames(){
|
||||
//Create an empty array to hold names
|
||||
let names = [];
|
||||
|
|
@ -165,6 +234,10 @@ class commandPreprocessor{
|
|||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates auto-complete dictionary from pre-written commands, emotes, and used tokes from servers for use with autocomplete
|
||||
* @returns {Object} Generated Dictionary object
|
||||
*/
|
||||
buildAutocompleteDictionary(){
|
||||
let dictionary = {
|
||||
tokes: {
|
||||
|
|
@ -226,11 +299,25 @@ class commandPreprocessor{
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for Object which contains logic for client-side commands
|
||||
*/
|
||||
class commandProcessor{
|
||||
/**
|
||||
* Instantiates a new Command Processor object
|
||||
* @param {channel} client - Parent client mgmt object
|
||||
*/
|
||||
constructor(client){
|
||||
/**
|
||||
* Parent Client Management object
|
||||
*/
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* Method handling /high client command
|
||||
* @param {Array} argumentArray - Array of arguments passed down from Command Pre-Processor
|
||||
*/
|
||||
high(argumentArray){
|
||||
//If we have an argument
|
||||
if(argumentArray[1]){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue