Options
All
  • Public
  • Public/Protected
  • All
Menu

twinkle-core

Index

Type aliases

BlockPresetInfo

BlockPresetInfo: { autoblock?: boolean; disabletalk?: boolean; expiry?: string; forAnonOnly?: boolean; forRangeOnly?: boolean; forRegisteredOnly?: boolean; hardblock?: boolean; nocreate?: boolean; noemail?: boolean; nonstandard?: boolean; pageParam?: boolean; prependReason?: boolean; reason?: string; reasonParam?: boolean; requireGroup?: string; sig?: string | null; summary?: string; suppressArticleInSummary?: boolean; templateName?: string; useInitialOptions?: boolean }

Type declaration

  • Optional autoblock?: boolean
  • Optional disabletalk?: boolean
  • Optional expiry?: string
  • Optional forAnonOnly?: boolean
  • Optional forRangeOnly?: boolean
  • Optional forRegisteredOnly?: boolean
  • Optional hardblock?: boolean
  • Optional nocreate?: boolean
  • Optional noemail?: boolean
  • Optional nonstandard?: boolean
  • Optional pageParam?: boolean
  • Optional prependReason?: boolean
  • Optional reason?: string
  • Optional reasonParam?: boolean
  • Optional requireGroup?: string
  • Optional sig?: string | null
  • Optional summary?: string
  • Optional suppressArticleInSummary?: boolean
  • Optional templateName?: string
  • Optional useInitialOptions?: boolean

LogEvent

LogEvent: { action: string; comment: string; logid: number; logpage: number; ns: number; pageid: number; params: any; timestamp: string; title: string; type: string; user: string }

Type representing a log event from ApiQueryLogEvents (action=query&list=logevents)

Type declaration

  • action: string
  • comment: string
  • logid: number
  • logpage: number
  • ns: number
  • pageid: number
  • params: any
  • timestamp: string
  • title: string
  • type: string
  • user: string

Preference

Preference: { adminOnly?: boolean; default: boolean | string | number | { label: string; value: string }[]; enumValues?: Record<string, string>; helptip?: string; label?: string; name: string; setValues?: Record<string, string>; type: "boolean" | "string" | "enum" | "integer" | "set" | "customList" }

Type declaration

  • Optional adminOnly?: boolean
  • default: boolean | string | number | { label: string; value: string }[]
  • Optional enumValues?: Record<string, string>
  • Optional helptip?: string
  • Optional label?: string
  • name: string
  • Optional setValues?: Record<string, string>
  • type: "boolean" | "string" | "enum" | "integer" | "set" | "customList"

PreferenceGroup

PreferenceGroup: { adminOnly?: boolean; hidden?: boolean; module?: string; preferences: Preference[]; title: string }

Type declaration

  • Optional adminOnly?: boolean
  • Optional hidden?: boolean
  • Optional module?: string
  • preferences: Preference[]
  • title: string

footerLinks

footerLinks: Record<string, string>

tagListType

tagListType: tagData[] | Record<string, tagData[] | Record<string, tagData[]>>

Variables

Const NS_CATEGORY

NS_CATEGORY: number = ...

Const NS_FILE

NS_FILE: number = ...

Const NS_MAIN

NS_MAIN: number = ...

Const NS_PROJECT

NS_PROJECT: number = ...

Const NS_SPECIAL

NS_SPECIAL: number = ...

Const NS_TALK

NS_TALK: number = ...

Const NS_TEMPLATE

NS_TEMPLATE: number = ...

Const NS_USER

NS_USER: number = ...

Const NS_USER_TALK

NS_USER_TALK: number = ...

Let language

language: string = ...
deprecated

Let mwApi

mwApi: mw.Api

Let userDisabledModules

userDisabledModules: string[] = []

List of names of modules disabled by user. Populated in init() before modules are initialised.

Functions

addMessages

  • addMessages(messages: Messages): void
  • Load messages into the message store.

    Parameters

    • messages: Messages

    Returns void

addNs

  • addNs(title: string, namespaceNumber: number): string
  • Add namespace name to page title if not already given CAUTION: namespace name won't be added if a namespace (not necessarily the same as the one given) already is there in the title

    Parameters

    • title: string
    • namespaceNumber: number

    Returns string

addPortletLink

  • addPortletLink(task: string | (() => void), text: string, id: string, tooltip: string): HTMLLIElement
  • Builds a portlet menu if it doesn't exist yet, and add the portlet link.

    Parameters

    • task: string | (() => void)
    • text: string
    • id: string
    • tooltip: string

    Returns HTMLLIElement

arr_find

  • arr_find<T>(arr: T[], predicate: (value: T, index: number, obj: T[]) => boolean): T
  • Shim for Array.prototype.find

    deprecated

    as this is now shimmed in MediaWiki

    Type parameters

    • T

    Parameters

    • arr: T[]
    • predicate: (value: T, index: number, obj: T[]) => boolean
        • (value: T, index: number, obj: T[]): boolean
        • Parameters

          • value: T
          • index: number
          • obj: T[]

          Returns boolean

    Returns T

arr_flatMap

  • arr_flatMap<T>(arr: T[], callbackfn: (value: T, index: number, array: T[]) => T | ReadonlyArray<T>): any
  • Shim for Array.prototype.flatMap

    Type parameters

    • T

    Parameters

    • arr: T[]
    • callbackfn: (value: T, index: number, array: T[]) => T | ReadonlyArray<T>
        • (value: T, index: number, array: T[]): T | ReadonlyArray<T>
        • Parameters

          • value: T
          • index: number
          • array: T[]

          Returns T | ReadonlyArray<T>

    Returns any

arr_includes

  • arr_includes<T>(arr: T[], item: T): boolean
  • Shim for Array.prototype.includes

    deprecated

    as this is now shimmed in MediaWiki

    Type parameters

    • T

    Parameters

    • arr: T[]
    • item: T

    Returns boolean

generateArrowLinks

  • generateArrowLinks(checkbox: HTMLInputElement): void
  • Used in batch listings to link to the page in question with >

    Parameters

    • checkbox: HTMLInputElement

    Returns void

generateBatchPageLinks

  • generateBatchPageLinks(checkbox: HTMLInputElement): void
  • Used in deprod and unlink listings to link the page title

    Parameters

    • checkbox: HTMLInputElement

    Returns void

getPref

  • getPref(name: string): any

init

  • init(): void
  • Initialise Twinkle. This must be called AFTER all configurations in Twinkle.* and SiteConfig.* have been defined.

    Returns void

isTextRedirect

  • isTextRedirect(text: string): boolean
  • Check if page is a redirect given the page text.

    Parameters

    • text: string

    Returns boolean

link

  • link(displaytext: string, title: string, params?: any): string
  • Parameters

    • displaytext: string
    • title: string
    • Optional params: any

    Returns string

loadAdditionalMediaWikiMessages

  • loadAdditionalMediaWikiMessages(messageList: string[]): Promise<void>
  • Load messages from MediaWiki, in addition to what twinkle-core loads. Deprecated: Instead of using this, set extra messages in Twinkle.extraMwMessages array, and init() would fetch those too.

    deprecated

    Parameters

    • messageList: string[]

    Returns Promise<void>

loadUserConfig

  • loadUserConfig(): JQuery.Promise<void>

makeArray

  • makeArray<T>(obj: T | T[] | undefined | null): T[]
  • Type parameters

    • T

    Parameters

    • obj: T | T[] | undefined | null

    Returns T[]

makeOptoutLink

  • makeOptoutLink(module: string): string

makeTemplate

  • makeTemplate(name: string, parameters: Record<string | number, string>): string
  • Make template wikitext from the template name and parameters

    Parameters

    • name: string

      name of the template. Include "subst:" if necessary

    • parameters: Record<string | number, string>

      object with keys and values being the template param names and values. Use numbers as keys for unnamed parameters. If a value is falsy (undefined or null or empty string), the param doesn't appear in output.

    Returns string

msg

  • msg(msg: string, ...parameters: (string | number | string[] | Date)[]): string
  • Get parsed message.

    Parameters

    • msg: string

      the message name

    • Rest ...parameters: (string | number | string[] | Date)[]

      the parameters for $1, $2, ... substitutions

    Returns string

num2order

  • num2order(num: number): string

obj_entries

  • obj_entries<T>(obj: {} | ArrayLike<T>): [string, T][]
  • Shim for Object.entries

    Type parameters

    • T

    Parameters

    • obj: {} | ArrayLike<T>

    Returns [string, T][]

obj_fromEntries

  • obj_fromEntries<T>(entries: [string, T][]): Record<string, T>
  • Shim for Object.fromEntries

    Type parameters

    • T

    Parameters

    • entries: [string, T][]

    Returns Record<string, T>

obj_values

  • obj_values<T>(obj: {} | ArrayLike<T>): T[]
  • Shim for Object.values

    Type parameters

    • T

    Parameters

    • obj: {} | ArrayLike<T>

    Returns T[]

registerModule

setDefaultConfig

  • setDefaultConfig(config: { name: string; value: any }[]): void
  • Extends the defaultConfig

    Parameters

    • config: { name: string; value: any }[]

    Returns void

setPortletConfig

  • setPortletConfig(): void
  • Set portlet configurations, which are skin-specific XXX: move to Config.ts and avoid the function

    Returns void

sortByNamespace

  • sortByNamespace(first: any, second: any): number
  • Used in batch, unlink, and deprod to sort pages by namespace, as json formatversion=2 sorts by pageid instead (#1251)

    Parameters

    • first: any
    • second: any

    Returns number

str_endsWith

  • str_endsWith(str: string, text: string): boolean
  • Shim for String.prototype.endsWith

    Parameters

    • str: string
    • text: string

    Returns boolean

str_includes

  • str_includes(str: string, item: string): boolean
  • Shim for String.prototype.includes

    Parameters

    • str: string
    • item: string

    Returns boolean

str_startsWith

  • str_startsWith(str: string, text: string): boolean
  • Shim for String.prototype.startsWith

    Parameters

    • str: string
    • text: string

    Returns boolean

stripNs

  • stripNs(title: string): string
  • Remove namespace name from title if present Exception-safe wrapper around mw.Title

    Parameters

    • title: string

    Returns string

urlParamValue

  • urlParamValue(param: string): string
  • Get URL parameter. Alias for mw.util.getParamValue

    Parameters

    • param: string

    Returns string

Generated using TypeDoc