Constructor
new CommentSkeleton(parser, signature, targets)
- Source:
Create a comment skeleton instance.
Parameters:
Name | Type | Description |
---|---|---|
parser |
Parser | |
signature |
object | Signature object returned by Parser#findSignatures. |
targets |
Array.<object> |
Throws:
Members
authorLink :Element|external:Element
- Source:
For internal use. User page (in the "User" namespace) link element.
Type:
- Element | external:Element
authorName :string
- Source:
For internal use. Comment author name.
Type:
- string
authorTalkLink :Element|external:Element
- Source:
For internal use. User talk page (in the "User talk" namespace) link element.
Type:
- Element | external:Element
(nullable) date :Date
- Source:
Comment date.
Type:
- Date
elements :Array.<Element>|Array.<external:Element>
- Source:
For internal use. Elements containing all parts of the comment.
Type:
- Array.<Element> | Array.<external:Element>
extraSignatures :Array.<object>
- Source:
Additional signatures in this comment (that go after the "official" signature).
Type:
- Array.<object>
followsHeading :boolean
- Source:
Is the comment preceded by a heading.
Type:
- boolean
highlightables :Array.<Element>|Array.<external:Element>
- Source:
Comment elements that are highlightable.
Keep in mind that elements may be replaced, and property values will need to be updated. See Comment#replaceElement.
Type:
- Array.<Element> | Array.<external:Element>
(nullable) id :string
- Source:
Comment ID.
Type:
- string
index :number
- Source:
Comment index. Same as the index in the array returned by module:commentRegistry.getAll.
Type:
- number
isOpeningSection :boolean
- Source:
Does the comment open a section (has a heading as the first element and is placed at the zeroth level).
Type:
- boolean
isOutdented :boolean
- Source:
Is the comment outdented with the {{outdent}}
template.
Type:
- boolean
isOwn :boolean
- Source:
Does the comment belong to the current user.
Type:
- boolean
isUnsigned :boolean
- Source:
Is the comment unsigned or not properly signed (an unsigned template class is present).
Not used anywhere in the script yet.
Type:
- boolean
level :number
- Source:
Comment level. A level is a number representing the number of indentation characters preceding the comment (no indentation means zeroth level).
Type:
- number
logicalLevel :number
- Source:
Comment level that takes into account {{outdent}}
templates.
Type:
- number
parts :Array.<object>
- Source:
Comment parts. They are not guaranteed to match the elements after some point (due to
CommentSkeleton#wrapHighlightables
, CommentSkeleton#fixEndLevel
) calls.
Type:
- Array.<object>
(nullable) section :Section
- Source:
Section that the comment is directly in (the section with lowest level / the biggest level number).
Type:
signatureElement :Element|external:Element
- Source:
For internal use. Comment signature element.
Type:
- Element | external:Element
signatureText :string
- Source:
Comment signature text.
Type:
- string
timestamp :string
- Source:
Comment timestamp as originally present on the page.
Type:
- string
timestampElement :Element|external:Element
- Source:
For internal use. Comment timestamp element.
Type:
- Element | external:Element
Methods
(static) generateId(dateopt, authoropt, existingIdsopt) → (nullable) {string}
- Source:
Generate a comment ID from a date and author.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
date |
Date |
<optional> |
|
author |
string |
<optional> |
|
existingIds |
Array.<string> |
<optional> |
IDs that collide with IDs in the array will get a |
Returns:
- Type
- string
(static) isAnyId(stringopt) → {boolean}
- Source:
Check whether a string is a comment ID in the CD or DiscussionTools format.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string |
<optional> |
Returns:
- Type
- boolean
(static) isDtId(stringopt) → {boolean}
- Source:
Check whether a string is a comment ID in the DiscussionTools format.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string |
<optional> |
Returns:
- Type
- boolean
(static) isId(stringopt) → {boolean}
- Source:
Check if a string is a comment ID in the CD format.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string |
<optional> |
Returns:
- Type
- boolean
(static) processOutdents(parser)
- Source:
For internal use. Set logical levels to the comments taking into
account {{outdent}}
templates.
Parameters:
Name | Type | Description |
---|---|---|
parser |
Parser |
(static) updateOutdentWidth(element, parser)
- Source:
Update the width of the outdent template to match our thread style changes. Doesn't run in the worker.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | external:Element | |
parser |
Parser |
(protected) addAttributes()
- Source:
Add the necessary attributes to the comment's elements.
collectParts(precedingHeadingElement)
- Source:
For internal use. Collect the parts of the comment given a signature element.
Parameters:
Name | Type | Description |
---|---|---|
precedingHeadingElement |
Element | external:Element |
filterParts()
- Source:
For internal use. Remove unnecessary and incorrect parts from the collection.
getChildren(indirectopt, visualopt, allowSiblingsopt) → {Array.<CommentSkeleton>}
- Source:
Get all replies to the comment.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
indirect |
boolean |
<optional> |
false
|
Whether to include children of children and so on (return descendants, in a word). |
visual |
boolean |
<optional> |
false
|
Whether to use visual levels instead of logical. |
allowSiblings |
boolean |
<optional> |
true
|
When |
Returns:
- Type
- Array.<CommentSkeleton>
getListsUpTree(initialElement, includeFirstMatchopt) → {Array.<Element>|Array.<external:Element>}
- Source:
For internal use. Get list elements up the DOM tree. They will then be assigned the class
cd-commentLevel
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initialElement |
Element | external:Element | |||
includeFirstMatch |
boolean |
<optional> |
false
|
Returns:
- Type
- Array.<Element> | Array.<external:Element>
getParent(visualopt) → (nullable) {CommentSkeleton}
- Source:
Get the parent comment of the comment. This shouldn't run before sections are set on comments which is done in the SectionSkeleton constructor.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
visual |
boolean |
<optional> |
false
|
Get the visual parent (according to the level property, not logicalLevel). |
Returns:
- Type
- CommentSkeleton
isIntro(options) → {boolean}
- Source:
Identify cases like:
=== Section title ===
Section introduction. Not a comment.
# Vote. [signature]
and similar. Without treatment of such cases, the section introduction would be considered a part of the comment. The same may happen inside a discussion thread (often because one of the users didn't sign).
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
Returns:
- Type
- boolean
isOtherKindOfList(element) → {boolean}
- Source:
Check whether the element is an other kind of list than a comment thread, like a gallery
created by the <gallery>
tag.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | external:Element |
Returns:
- Type
- boolean
isPartOfList(node, isDefinitionListOnly) → {boolean}
- Source:
Given a comment part (a node), tell if it is a part of a bulleted or unbulleted (but not numbered) list.
Parameters:
Name | Type | Description |
---|---|---|
node |
Element | external:Element | |
isDefinitionListOnly |
boolean |
Returns:
- Type
- boolean
isUnsignedItem(part) → {boolean}
- Source:
Check whether the element is an unsigned item of a bulleted or numbered list, in cases like this.
Parameters:
Name | Type | Description |
---|---|---|
part |
object |
Returns:
- Type
- boolean
removeNestedParts()
- Source:
For internal use. Remove comment parts that are inside of other parts.
replaceListsWithItems()
- Source:
For internal use. Replace list elements with collections of their items if appropriate.
(protected) updateLevels(fixMarkupopt)
- Source:
Set the necessary classes to parent elements of the comment's elements to make a visible tree structure. While doing that, fix some markup.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fixMarkup |
boolean |
<optional> |
true
|
wrapInlineParts() → {Array.<object>}
- Source:
For internal use. Wrap text and inline nodes into block elements.
Returns:
- Type
- Array.<object>
wrapNumberedList()
- Source:
For internal use. Wrap numbered list into a <div>
or <dl>
& <dd>
if the comment starts
with numbered list items.