Class: PageHTMLParser

PageHTMLParser($container)

new PageHTMLParser($container)

Parameters:
Name Type Description
$container jQuery.Object

Used when parsing to find children within this container

Source:

Members

(static) HEADING_SELECTOR

Selector for matching headings

Source:

(static) THUMB_SELECTOR

Selector for thumbnails.

Source:

Methods

findChildInSectionLead(sectionIndex, selector) → {jQuery.Object}

Finds all child elements that match the selector in a given section or subsection. Returns any direct child elements that match the selector, (i.e. searches only one level deep) as well as any elements that match the selector within those children. If the Page has no headings (e.g. a stub), then the search will target all nodes within the page.

This code should work on desktop (PHP parser HTML) as well as mobile formatted HTML (PHP parser + MobileFormatter)

Parameters:
Name Type Description
sectionIndex number

as defined by the PHP parser. It should correspond to the section id used in the edit link for the section. Note, confusingly, this is different from section "ID" which is used in methods

selector string

to match

Source:
Returns:
Type
jQuery.Object

findSectionHeadingByIndex(sectionIndex) → {jQuery.Object}

Find the heading in the page. This has the benefit of excluding any additional h2s and h3s that may have been added programatically.

Parameters:
Name Type Description
sectionIndex number

as defined by the PHP parser. It should correspond to the section id used in the edit link for the section. Note, confusingly, this is different from section "ID" which is used in methods

Source:
Returns:
Type
jQuery.Object

getLanguages(pageTitle) → {Object}

Returns an object consistent with MediaWiki API representing languages associated with the page in the user's current language.

Parameters:
Name Type Description
pageTitle string

to fallback to if none found

Source:
Returns:

containing langlinks and variant links as defined @ https://en.m.wikipedia.org/w/api.php?action=help&modules=query%2Blanglinks

Type
Object

getLeadSectionElement() → {jQuery.Object|null}

Get the lead section of the page view.

Source:
Returns:
Type
jQuery.Object | null

Returns a jQuery object representing all redlinks on the page.

Source:
Returns:
Type
jQuery.Object

getThumbnail($a) → {Thumbnail|null}

Returns a Thumbnail object from an anchor element containing an image or null if not valid.

Parameters:
Name Type Description
$a jQuery

Anchor element that contains the image.

Source:
Returns:
Type
Thumbnail | null

getThumbnails($elopt) → {Array.<Thumbnail>}

Return all the thumbnails in the article. Images which have a class or link container (.image|.thumbimage) that matches one of the items of the constant EXCLUDE_THUMBNAIL_CLASS_SELECTORS will be excluded. A thumbnail nested inside one of these classes will still be returned. e.g. <div class="noviewer"><a class="image"><img></a></div> is not a valid thumbnail <a class="image noviewer"><img></a> is not a valid thumbnail <a class="image"><img class="noviewer"></a> is not a valid thumbnail

Parameters:
Name Type Attributes Description
$el jQuery <optional>

Container to search, defaults to this.$el.

Source:
Returns:
Type
Array.<Thumbnail>