commentRegistry

Singleton storing data about comments on the page and managing them.

Source:

Members

(static) layersContainers :Array.<Element>

Source:

List of containers of layers.

Type:
  • Array.<Element>

(static) underlays :Array.<Element>

Source:

List of underlays.

Type:
  • Array.<Element>

Methods

(static) add(item)

Source:

Add a comment to the list.

Parameters:
Name Type Description
item Comment

(static) addNewCommentsNotes(newComments)

Source:

For internal use. Add new comments notifications to threads and sections.

Parameters:
Name Type Description
newComments Map

(static) adjustDom()

Source:

For internal use. Perform some DOM-related tasks after parsing comments.

(static) changeElementType(element, newType) → {Element}

Source:

Replace an element with an identical one but with another tag name, i.e. move all child nodes, attributes, and some bound events to a new node, and also reassign references in some variables and properties to this element. Unfortunately, we can't just change the element's tagName to do that.

Parameters:
Name Type Description
element Element
newType string
Returns:
Type
Element

(static) configureAndAddLayers(condition)

Source:

Configure and add layers for a group of comments.

Parameters:
Name Type Description
condition function

(static) connectBrokenThreads()

Source:

For internal use. Add the 'cd-connectToPreviousItem' class to some item elements to visually connect threads broken by some intervention.

(static) findAndUpdateTableComments()

Source:

For internal use. Set the Comment#isTableComment property for each "table comment", i.e. a comment that is (or its signature is) inside a table containing only that comment.

(static) findInViewport(findClosestDirectionopt) → (nullable) {Comment}

Source:

Find any one comment inside the viewport.

Parameters:
Name Type Attributes Description
findClosestDirection string <optional>

If there is no comment in the viewport, find the closest comment in the specified direction.

Returns:
Type
Comment

(static) getAll() → {Array.<Comment>}

Source:

Get all comments on the page ordered the same way as in the DOM. It returns the original array, so use .slice() when changing it.

Returns:
Type
Array.<Comment>

(static) getByAnyId(id, impreciseDateopt) → (nullable) {Comment}

Source:

Get a comment by a comment ID in the CD or DiscussionTools format.

Parameters:
Name Type Attributes Default Description
id string
impreciseDate boolean <optional>
false

(For CD IDs.) Comment date is inferred from the edit date (but these may be different). If true, we allow the time on the page to be 1-3 minutes less than the edit time.

Returns:
Type
Comment

(static) getByDtId(id, returnComponentsopt) → (nullable) {Comment|object}

Source:

Get a comment by a comment ID in the DiscussionTools format.

Parameters:
Name Type Attributes Default Description
id string
returnComponents boolean <optional>
false

Whether to return the constituents of the ID (as an object) together with a comment.

Returns:
Type
Comment | object

(static) getById(id, impreciseDateopt) → (nullable) {Comment}

Source:

Get a comment by ID in the CD format.

Parameters:
Name Type Attributes Default Description
id string
impreciseDate boolean <optional>
false

Comment date is inferred from the edit date (but these may be different). If true, we allow the time on the page to be 1-3 minutes less than the edit time.

Returns:
Type
Comment

(static) getByIndex(index) → (nullable) {Comment}

Source:

Get a comment by index.

Parameters:
Name Type Description
index number

Use a negative index to count from the end.

Returns:
Type
Comment

(static) getCount() → {number}

Source:

Get the number of comments.

Returns:
Type
number

(static) getSelectedComment() → (nullable) {Comment}

Source:

Determine which comment on the page is selected.

Returns:
Type
Comment

(static) init()

Source:

For internal use. Initialize the registry.

(static) initNewAndSeen(currentPageData, currentTime, markAsReadRequested) → {boolean}

Source:

Set the Comment#isNew and Comment#isSeen properties to comments.

Parameters:
Name Type Description
currentPageData object

Visits data for the current page.

currentTime number

Unix timestamp.

markAsReadRequested boolean

Have the user requested to mark all shown comments as read.

Returns:

Whether there is a time conflict.

Type
boolean

(static) maybeHighlightHovered(e)

Source:

Handles the mousemove and mouseover events and highlights hovered comments even when the cursor is between comment parts, not over them. (An event handler for comment part elements wouldn't be able to handle this space between.)

Parameters:
Name Type Description
e Event

(static) maybeRedrawLayers(redrawAllopt)

Source:

Recalculate the offset of the highlighted comments' (usually, new or own) layers and redraw if they've changed.

Parameters:
Name Type Attributes Description
redrawAll boolean <optional>

Whether to redraw all layers and not stop at first three unmoved.

(static) query(condition) → {Array.<Comment>}

Source:

Get comments by a condition.

Parameters:
Name Type Description
condition function
Returns:
Type
Array.<Comment>

(static) reformatComments()

Source:

For internal use. Reformat the comments (moving the author and date up and links down) if the relevant setting is enabled.

(static) reformatTimestamps()

Source:

For internal use. Change the format of the comment timestamps according to the settings.

(static) registerSeen()

Source:

For internal use. Mark comments that are currently in the viewport as read, and also flash comments that are prescribed to flash.

(static) reset()

Source:

Reset the comment list.

(static) resetLayers()

Source:

For internal use. Empty the underlay registry and the layers container elements. Done on page reload.

(static) reviewHighlightables()

Source:

For internal use. Filter out floating and hidden elements from all the comments' highlightables, change their attributes, and update the comments' level and parent elements' level classes.

(static) setDtIds(ids)

Source:

For internal use. Add available DiscussionTools IDs to respective comments.

Parameters:
Name Type Description
ids Array.<string>

(static) setup()

Source:

For internal use. Perform some comment-related operations when the registry is filled, in addition to those performed when each comment is added to the registry.