Wrappers for MediaWiki action API requests (https://www.mediawiki.org/wiki/API:Main_page) together with some user options handling functions. See also the Page class methods for API methods related to specific titles.
- Source:
Methods
(static) convertHtmlToWikitext(html, syntaxHighlightLanguages) → {Promise.<string>}
- Source:
Convert HTML into wikitext.
Parameters:
Name | Type | Description |
---|---|---|
html |
string | |
syntaxHighlightLanguages |
Array.<(string|undefined)> |
Returns:
- Type
- Promise.<string>
(static) getPageIds(titles) → {Promise.<Array.<object>>}
- Source:
Get page IDs for an array of page titles.
Parameters:
Name | Type | Description |
---|---|---|
titles |
Array.<string> |
Returns:
- Type
- Promise.<Array.<object>>
(static) getPagesExistence(titles) → {Promise.<object>}
- Source:
Get existence of a list of pages by title.
Parameters:
Name | Type | Description |
---|---|---|
titles |
Array.<string> | Titles to check existence of. |
Returns:
- Type
- Promise.<object>
(static) getPageTitles(pageIds) → {Promise.<Array.<object>>}
- Source:
Get page titles for an array of page IDs.
Parameters:
Name | Type | Description |
---|---|---|
pageIds |
Array.<number> |
Returns:
- Type
- Promise.<Array.<object>>
(static) getUserInfo(reuseopt) → {Promise.<object>}
- Source:
Make a userinfo request (see https://www.mediawiki.org/wiki/API:Userinfo).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
reuse |
boolean |
<optional> |
false
|
Whether to reuse a cached request. |
Returns:
Promise for an object containing the full options object, visits, subscription list, and rights.
- Type
- Promise.<object>
(static) handleApiReject(code, resp)
- Source:
Callback used in the .catch()
parts of API requests.
Parameters:
Name | Type | Description |
---|---|---|
code |
string | Array | |
resp |
object |
Throws:
(static) loadUserGenders(users, doRequestInBackgroundopt)
- Source:
Request genders of a list of users and assign them as properties. A gender may be 'male'
,
'female'
, or 'unknown'
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
users |
Array.<module:userRegistry.User> | |||
doRequestInBackground |
boolean |
<optional> |
false
|
Make a request that won't set the process on hold when the tab is in the background. |
(async, static) parseCode(code, customOptionsopt) → {external:jQueryPromise.<object>}
- Source:
Make a parse request with arbitrary code. We assume that if something is parsed, it will be shown, so we automatically load modules.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
code |
string | ||
customOptions |
object |
<optional> |
Returns:
- Type
- external:jQueryPromise.<object>
(static) requestInBackground(params, methodopt) → {Promise.<object>}
- Source:
Make a request that won't set the process on hold when the tab is in the background.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params |
object | |||
method |
string |
<optional> |
'post'
|
Returns:
- Type
- Promise.<object>
(static) saveGlobalOption(name, value)
- Source:
Save a global preferences' option value to the server. See https://www.mediawiki.org/wiki/Extension:GlobalPreferences/API.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
value |
string |
Throws:
(static) saveLocalOption(name, value)
- Source:
Save an option value to the server. See https://www.mediawiki.org/wiki/API:Options.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
value |
string |
(static) saveOptions(options, isGlobalopt)
- Source:
Generic function for saving user options to the server.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
object | Name-value pairs. |
||
isGlobal |
boolean |
<optional> |
false
|
Whether to save the options globally (using Extension:GlobalPreferences). |
Throws:
(static) splitIntoBatches(arr) → {Array.<Array.<*>>}
- Source:
Split an array into batches of 50 (500 if the user has the apihighlimits
right) to use in API
requests.
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array.<*> |
Returns:
- Type
- Array.<Array.<*>>