Chat-panel UI framework: tabs, input, scrolling and the channel-registration API. The COMM data layer lives in comm.js
Members
-
static chat.channelContainerTemplate :string
-
Template of a channel message container appended to the chat panel.
-
static chat.channelTabTemplate :string
-
Template of a channel tab link shown in the chat controls.
-
static chat.channels :Array.<ChannelDescription>
-
Holds channels infos.
Methods
-
static chat.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
-
static chat.addNickname(nick)
-
Adds a nickname to the chat input.
Parameters:
Name Type Description nickstring The nickname to add.
-
static chat.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.
-
static chat.channelState(el) → {Object}
-
Returns the per-channel-element UI flag store for the given channel DOM element. The native WeakMap store is the source of truth, but writes are mirrored into
$(el).data(key)and reads fall back to it, so legacy plugins that access these flags via jQuery.data()keep working.Parameters:
Name Type Description elHTMLElement The channel DOM element.
Returns:
Object -A proxy exposing the element's UI flags.
-
static chat.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').
-
static chat.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.
-
static chat.getActive() → {string}
-
Gets the name of the active chat tab.
Returns:
string -The name of the active chat tab.
-
static chat.getChannelDesc(tab) → {ChannelDescription}
-
Converts a chat tab name to its corresponding channel object.
Parameters:
Name Type Description tabstring The name of the chat tab.
-
static chat.handleTabCompletion()
-
Handles tab completion in chat input.
-
static chat.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 boxHTMLElement | jQuery The chat box element (a jQuery object is also accepted for legacy callers).
scrollBeforenumber The scroll position before new messages were added.
isOldMsgsboolean Indicates if the added messages are older messages.
-
static chat.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.
-
static chat.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.
-
static chat.postMsg()
-
Posts a chat message to the currently active chat tab.
-
static chat.renderAlerts(oldMsgsWereAdded)
-
Renders alerts chat in the UI.
Parameters:
Name Type Description oldMsgsWereAddedboolean Indicates if older messages were added to the chat.
-
static chat.renderFaction(oldMsgsWereAdded)
-
Renders faction chat.
Parameters:
Name Type Description oldMsgsWereAddedboolean Indicates if old messages were added in the current rendering.
-
static chat.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
-
static chat.renderPublic(oldMsgsWereAdded)
-
Renders public chat in the UI.
Parameters:
Name Type Description oldMsgsWereAddedboolean Indicates if older messages were added to the chat.
-
static chat.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.
-
static chat.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.
-
static chat.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.
-
static chat.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.
-
static chat.setup()
-
Sets up the chat interface.
-
static chat.setupPosting()
-
Sets up the chat message posting functionality.
-
static chat.setupTabs()
-
Sets up all channels starting from intel COMM
-
static chat.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.
-
static chat.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.
-
static chat.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
-
static chat.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.