settings

Singleton for settings-related methods and data.

Source:

Members

(static) scheme

Source:
Properties:
Name Type Description
default object

Default value for each property.

local Array.<string>

List of local setting names. Local settings are settings set for the current wiki only.

undocumented object

Undocumented settings with their defaults. Undocumented settings are settings not shown in the settings dialog and not saved to the server.

aliases object

List of aliases for each property for seamless transition when changing a setting name.

states Array.<string>

List of state setting names. States are values to be remembered, or settings to be removed if the time comes. It is, in fact, user data, despite that we don't have much of it.

resetsTo object

For settings that are resetted not to their default values, those non-default values are specified here (used to determine whether the "Reset" button should be enabled).

ui Array.<object>

List of pages of the settings dialog, each with its control objects.

Settings scheme.

Methods

(static) addLinkToFooter()

Source:

Add a settings link to the page footer.

(static) get(name) → {*}

Source:

Get the value of a setting without loading from the server.

Parameters:
Name Type Description
name string
Returns:
Type
*

(static) init() → {Promise.<undefined>}

Source:

For internal use. Initialize user settings, returning a promise, or return an existing one.

Returns:
Type
Promise.<undefined>

(static) initUi()

Source:

For internal use. Initialize the configuration of the UI for the settings dialog}. This is better called each time the UI is rendered because some content is date-dependent.

(static) load(optionsopt) → {Promise.<object>}

Source:

Request the settings from the server, or extract the settings from the existing options strings.

Parameters:
Name Type Attributes Default Description
options object <optional>
{}
Properties
Name Type Attributes Default Description
options object <optional>

Object containing strings with the local and global settings.

omitLocal boolean <optional>
false

Whether to omit variables set via cdLocal... variables (they shouldn't need to be saved to the server).

reuse boolean <optional>
false

If options is not set, reuse the cached user info request.

Returns:
Type
Promise.<object>

(static) maybeConfirmDesktopNotifications()

Source:

Show a popup asking the user if they want to receive desktop notifications, or ask for a permission if it has not been granted but the user has desktop notifications enabled (for example, if they are using a browser different from where they have previously used). Save the settings after they make the choice.

(static) maybeSuggestEnableCommentReformatting() → {Promise.<boolean>}

Source:

Show a popup asking the user if they want to enable the new comment formatting. Save the settings after they make the choice.

Returns:

Did the user enable comment reformatting.

Type
Promise.<boolean>

(static) save(settingsopt)

Source:

Save the settings to the server. This function will split the settings into the global and local ones and make two respective requests.

Parameters:
Name Type Attributes Default Description
settings object <optional>
this.values

Settings to save.

(static) saveSettingOnTheFly(key, value) → {Promise.<undefined>}

Source:

Update a setting value, saving it to the server and changing it for the current session as well. This should be done cautiously, because many settings only have effect on page reload.

Parameters:
Name Type Description
key string

The key of the settings to save.

value *

The value to set.

Returns:
Type
Promise.<undefined>

(static) showDialog(initalPageNameopt)

Source:

Show a settings dialog.

Parameters:
Name Type Attributes Description
initalPageName string <optional>