Namespace for chat-related functionalities.
Members
-
static chat.channels :Array.<ChannelDescription>
-
Holds channels infos.
Methods
-
inner addChannel(channelDesc)
-
Add to the channel list a new channel description
If tabs are already created, a tab is created for this channel as well
Parameters:
Name Type Description channelDescChannelDescription channel description
-
inner addNickname(nick)
-
Adds a nickname to the chat input.
Parameters:
Name Type Description nickstring The nickname to add.
-
inner backgroundChannelData(instance, channel, flag)
-
Allows plugins to request and monitor COMM data streams in the background. This is useful for plugins that need to process COMM data even when the user is not actively viewing the COMM channels. It tracks the requested channels for each plugin instance and updates the global state accordingly.
Parameters:
Name Type Description instancestring A unique identifier for the plugin or instance requesting background COMM data.
channelstring The name of the COMM channel ('all', 'faction', or 'alerts').
flagboolean Set to true to request data for the specified channel, false to stop requesting.
-
inner chooser(event)
-
Chat tab chooser handler. This function is triggered by a click event on the chat tab. It reads the tab name from the event target and activates the corresponding chat tab.
Parameters:
Name Type Description eventEvent The event triggered by clicking a chat tab.
-
inner chooseTab(tab)
-
Chooses and activates a specified chat tab. Also triggers an early refresh of the chat data when switching tabs.
Parameters:
Name Type Description tabstring The name of the chat tab to activate ('all', 'faction', or 'alerts').
-
inner getActive() → {string}
-
Gets the name of the active chat tab.
Returns:
string -The name of the active chat tab.
-
inner getChannelDesc(tab) → {ChannelDescription}
-
Converts a chat tab name to its corresponding channel object.
Parameters:
Name Type Description tabstring The name of the chat tab.
Returns:
ChannelDescription -The corresponding channel name ('faction', 'alerts', or 'all').
-
inner handleTabCompletion()
-
Handles tab completion in chat input.
-
inner keepScrollPosition(box, scrollBefore, isOldMsgs)
-
Maintains the scroll position of a chat box when new messages are added. This function is designed to keep the scroll position fixed when old messages are loaded, and to automatically scroll to the bottom when new messages are added if the user is already at the bottom of the chat.
Parameters:
Name Type Description boxjQuery The jQuery object of the chat box.
scrollBeforenumber The scroll position before new messages were added.
isOldMsgsboolean Indicates if the added messages are older messages.
-
inner needMoreMessages()
-
Checks if the currently selected chat tab needs more messages. This function is triggered by scroll events and loads older messages when the user scrolls to the top.
-
inner nicknameClicked(event, nickname) → {boolean}
-
Handles click events on nicknames in the chat.
Parameters:
Name Type Description eventEvent The click event.
nicknamestring The clicked nickname.
Returns:
boolean -Always returns false.
-
inner postMsg()
-
Posts a chat message to the currently active chat tab.
-
inner renderAlerts(oldMsgsWereAdded)
-
Renders alerts chat in the UI.
Parameters:
Name Type Description oldMsgsWereAddedboolean Indicates if older messages were added to the chat.
-
inner renderFaction(oldMsgsWereAdded)
-
Renders faction chat.
Parameters:
Name Type Description oldMsgsWereAddedboolean Indicates if old messages were added in the current rendering.
-
inner renderMsg(msg, nick, time, team, msgToPlayer, systemNarrowcast) → {string}
-
Legacy function for rendering chat messages. Used for backward compatibility with plugins.
Parameters:
Name Type Description msgstring The chat message.
nickstring The nickname of the player who sent the message.
timenumber The timestamp of the message.
teamstring The team of the player who sent the message.
msgToPlayerboolean Flag indicating if the message is directed to the player.
systemNarrowcastboolean Flag indicating if the message is a system narrowcast.
Returns:
string -The HTML string representing a chat message row.
- Deprecated:
- Yes
-
inner renderPublic(oldMsgsWereAdded)
-
Renders public chat in the UI.
Parameters:
Name Type Description oldMsgsWereAddedboolean Indicates if older messages were added to the chat.
-
inner request()
-
Requests chat messages for the currently active chat tab and background channels. It calls the appropriate request function based on the active tab or background channels.
-
inner requestAlerts(getOlderMsgs, isRetryopt)
-
Initiates a request for alerts chat data.
Parameters:
Name Type Attributes Default Description getOlderMsgsboolean Whether to retrieve older messages.
isRetryboolean <optional>
false Whether the request is a retry.
-
inner requestFaction(getOlderMsgs, isRetryopt)
-
Requests faction chat messages.
Parameters:
Name Type Attributes Default Description getOlderMsgsboolean Flag to determine if older messages are being requested.
isRetryboolean <optional>
false Flag to indicate if this is a retry attempt.
-
inner requestPublic(getOlderMsgs, isRetryopt)
-
Initiates a request for public chat data.
Parameters:
Name Type Attributes Default Description getOlderMsgsboolean Whether to retrieve older messages.
isRetryboolean <optional>
false Whether the request is a retry.
-
inner setup()
-
Sets up the chat interface.
-
inner setupPosting()
-
Sets up the chat message posting functionality.
-
inner setupTabs()
-
Sets up all channels starting from intel COMM
-
inner setupTime()
-
Sets up the time display in the chat input box. This function updates the time displayed next to the chat input field every minute to reflect the current time.
-
inner show(name)
-
Displays the chat interface and activates a specified chat tab.
Parameters:
Name Type Description namestring The name of the chat tab to show and activate.
-
inner tabToChannel(tab) → {string}
-
Legacy function for converts a chat tab name to its corresponding COMM channel name. Used for backward compatibility with plugins.
Parameters:
Name Type Description tabstring The name of the chat tab.
Returns:
string -The corresponding channel name ('faction', 'alerts', or 'all').
- Deprecated:
- Yes
-
inner toggle()
-
Toggles the chat window between expanded and collapsed states. When expanded, the chat window covers a larger area of the screen. This function also ensures that the chat is scrolled to the bottom when collapsed.
Type Definitions
-
ChannelDescription
-
Hold channel description
See comm.js for examples
Properties:
Name Type Attributes Description idstring uniq id, matches 'tab' parameter for server requests
namestring visible name
inputPromptstring <optional>
(optional) string for the input prompt
inputClassstring <optional>
(optional) class to apply to #chatinput
sendMessageChannelSendMessageFn <optional>
(optional) function to send the message
requestChannelRequestFn <optional>
(optional) function to call to request new message
renderChannelRenderFn <optional>
(optional) function to render channel content,, called on tab change
localBoundsboolean <optional>
(optional) if true, reset on view change
-
ChannelRenderFn(id, oldMsgsWereAdded) → {void}
-
Parameters:
Name Type Description idstring channel id
oldMsgsWereAddedboolean true if data has been added at the top (to preserve scroll position)
Returns:
void -
ChannelRequestFn(id, getOlderMsgs, isRetry) → {void}
-
Parameters:
Name Type Description idstring channel id
getOlderMsgsboolean true if request data from a scroll to top
isRetryboolean Returns:
void -
ChannelSendMessageFn(id, message) → {void}
-
Parameters:
Name Type Description idstring channel id
messagestring input message
Returns:
void