chat

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
channelDesc ChannelDescription

channel description

inner addNickname(nick)

Adds a nickname to the chat input.

Parameters:
Name Type Description
nick string

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
instance string

A unique identifier for the plugin or instance requesting background COMM data.

channel string

The name of the COMM channel ('all', 'faction', or 'alerts').

flag boolean

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
event Event

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
tab string

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
tab string

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
box jQuery

The jQuery object of the chat box.

scrollBefore number

The scroll position before new messages were added.

isOldMsgs boolean

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
event Event

The click event.

nickname string

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
oldMsgsWereAdded boolean

Indicates if older messages were added to the chat.

inner renderFaction(oldMsgsWereAdded)

Renders faction chat.

Parameters:
Name Type Description
oldMsgsWereAdded boolean

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
msg string

The chat message.

nick string

The nickname of the player who sent the message.

time number

The timestamp of the message.

team string

The team of the player who sent the message.

msgToPlayer boolean

Flag indicating if the message is directed to the player.

systemNarrowcast boolean

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
oldMsgsWereAdded boolean

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
getOlderMsgs boolean

Whether to retrieve older messages.

isRetry boolean <optional>
false

Whether the request is a retry.

inner requestFaction(getOlderMsgs, isRetryopt)

Requests faction chat messages.

Parameters:
Name Type Attributes Default Description
getOlderMsgs boolean

Flag to determine if older messages are being requested.

isRetry boolean <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
getOlderMsgs boolean

Whether to retrieve older messages.

isRetry boolean <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
name string

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
tab string

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
id string

uniq id, matches 'tab' parameter for server requests

name string

visible name

inputPrompt string <optional>

(optional) string for the input prompt

inputClass string <optional>

(optional) class to apply to #chatinput

sendMessage ChannelSendMessageFn <optional>

(optional) function to send the message

request ChannelRequestFn <optional>

(optional) function to call to request new message

render ChannelRenderFn <optional>

(optional) function to render channel content,, called on tab change

localBounds boolean <optional>

(optional) if true, reset on view change

ChannelRenderFn(id, oldMsgsWereAdded) → {void}

Parameters:
Name Type Description
id string

channel id

oldMsgsWereAdded boolean

true if data has been added at the top (to preserve scroll position)

Returns:
void

ChannelRequestFn(id, getOlderMsgs, isRetry) → {void}

Parameters:
Name Type Description
id string

channel id

getOlderMsgs boolean

true if request data from a scroll to top

isRetry boolean
Returns:
void

ChannelSendMessageFn(id, message) → {void}

Parameters:
Name Type Description
id string

channel id

message string

input message

Returns:
void