Class: Page

Page(options)

Mobile page view object

Constructor

new Page(options)

Parameters:
Name Type Description
options Object

Configuration options

Properties
Name Type Description
id number

Page ID. The default value of 0 represents a new or missing page. Be sure to override it to avoid side effects.

title string

Title of the page. It includes prefix where needed and is human readable, e.g. Talk:The man who lived.

titleObj Object
displayTitle string

HTML title of the page for display. Falls back to defaults.title (escaped) if no value is provided. Must be safe HTML!

namespaceNumber number

the number of the namespace the page belongs to

protection Object

List of permissions as returned by API, e.g. [{ edit: ['*'] }]

sections Array

Array of {Section} objects.

url string
wikidataDescription string
isMainPage boolean

Whether the page is the Main Page.

isMissing boolean

Whether the page exists in the wiki.

lastModified string
anchor string
revId number

Revision ID. See wgRevisionId.

isWatched boolean

Whether the page is being watched

thumbnail Object

thumbnail definition corresponding to page image

Properties
Name Type Description
isLandscape boolean

whether the image is in landscape format

width number

of image in pixels.

height number

of image in pixels.

source string

url for image

Source:

Methods

(static) parse(resp) → {Page}

Create a Page object from an API response.

Parameters:
Name Type Description
resp Object

as representing a page in the API

Source:
Returns:
Type
Page

getDisplayTitle() → {string}

Retrieve the title that should be displayed to the user

Source:
Returns:

HTML

Type
string

getNamespaceId() → {number}

return namespace id

Source:
Returns:

namespace Number

Type
number

getRevisionId() → {number}

Return the latest revision id for this page

Source:
Returns:
Type
number

getSection(id) → {Section}

FIXME: Change function signature to take the anchor of the heading

Parameters:
Name Type Description
id string

of the section as defined by MobileFormatter. Note, that currently, this is different from the PHP parser in that it relates to top-level sections. For example, mf-section-1 would relate to section 1. See FIXME.

Source:
Returns:
Type
Section

getSections() → {Array}

Obtain the list of high level (and grouped) sections. Note that this list will not include subsections.

Source:
Returns:

of Section instances

Type
Array

getTitle() → {string}

Return prefixed page title

Source:
Returns:
Type
string

inNamespace(namespace) → {boolean}

Determine if current page is in a specified namespace

Parameters:
Name Type Description
namespace string

Name of namespace

Source:
Returns:
Type
boolean

isMainPage() → {boolean}

Checks whether the current page is the main page

Source:
Returns:
Type
boolean

isWatched() → {boolean}

Checks whether the current page is watched

Source:
Returns:
Type
boolean

isWikiText() → {boolean}

Determines if content model is wikitext

Source:
Returns:
Type
boolean