Class: Model

Model()

new Model()

TemplateData Model

Mixes In:
  • OO.EventEmitter
Source:

Methods

addKeyTemplateParamOrder(key)

Add a key to the end of the paramOrder

Parameters:
Name Type Description
key string

New key the add into the paramOrder

Source:
Fires:

addParam(key, paramDataopt)

Add parameter to the model

Parameters:
Name Type Attributes Description
key string

Parameter key

paramData Object <optional>

Parameter data

Source:
Fires:

deleteParam(paramKey)

Mark a parameter for deletion. Don't actually delete the parameter so we can make sure it is removed from the final output.

Parameters:
Name Type Description
paramKey string

Parameter key

Source:
Fires:

emptyParamData(paramKey)

Delete all data attached to a parameter

Parameters:
Name Type Description
paramKey string

Parameter key

Source:

getAllParamNames() → {Array.<string>}

Retrieve an array of all used parameter names. Note that parameter names can be different than their stored keys.

Source:
Returns:

Used parameter names

Type
Array.<string>

getDefaultLanguage() → {string}

Get the current wiki language code. Defaults on 'en'.

Source:
Returns:

Wiki language

Type
string

getExistingLanguageCodes() → {Array.<string>}

Retrieve all existing language codes in the current templatedata model

Source:
Returns:

Language codes in use

Type
Array.<string>

getFullPageName() → {string}

Get page full name

Source:
Returns:

Page full name

Type
string

getMapInfo() → {Object|undefined}

Get the template info.

Source:
Returns:

The template map info.

Type
Object | undefined

getMissingParams() → {Array.<string>}

Go over the importable parameters and check if they are included in the parameter model. Return the parameter names that are not included yet.

Source:
Returns:

Parameters that are not yet included in the model

Type
Array.<string>

getNewValidParameterKey(key) → {string}

Check the key if it already exists in the parameter list. If it does, find a new key that doesn't, and return it.

Parameters:
Name Type Description
key string

New parameter key

Source:
Returns:

Valid new parameter key

Type
string

getOriginalMapsInfo() → {Object|undefined}

Get the template info.

Source:
Returns:

The Original template map info.

Type
Object | undefined

getOriginalTemplateDataObject() → {Object|null}

Get original templatedata object

Source:
Returns:

Templatedata object at the beginning of this editing session, or null if we're creating a new object.

Type
Object | null

getParamData(key) → {Object|undefined}

Retrieve a specific parameter data

Parameters:
Name Type Description
key string

Parameter key

Source:
Returns:

Parameter data

Type
Object | undefined

getParamProperty(paramKey, prop) → {Mixed|null}

Get a parameter property.

Parameters:
Name Type Description
paramKey string

Parameter key

prop string

Parameter property

Source:
Returns:

Property value if it exists. Returns null if the parameter key itself doesn't exist.

Type
Mixed | null

getParamValue(paramKey, property, languageopt) → {string}

Get a specific parameter's localized property

Parameters:
Name Type Attributes Description
paramKey string

Parameter key

property string

Property name

language string <optional>

Optional language key

Source:
Returns:

Parameter property in specified language

Type
string

getParams() → {Object}

Return the complete object of all parameters.

Source:
Returns:

All parameters and their data

Type
Object

getParentPage() → {string}

Get parent page

Source:
Returns:

Parent page

Type
string

getSourceCodeParameters() → {Array.<string>}

Get the parameters that are available in the template source code

Source:
Returns:

Parameters available in template source

Type
Array.<string>

getTemplateDescription(languageopt) → {string}

Get the template description.

Parameters:
Name Type Attributes Description
language string <optional>

Optional language key

Source:
Returns:
Type
string

getTemplateFormat() → {string|null}

Retrieve the template preferred format

Source:
Returns:

Preferred format

Type
string | null

getTemplateParamOrder() → {Array.<string>}

Retrieve the template paramOrder array

Source:
Returns:

orderArray Parameter keys in order

Type
Array.<string>

importSourceCodeParameters() → {Object}

Add imported parameters into the model

Source:
Returns:

Parameters added. -1 for failure.

Type
Object

isOutputInLanguageObject(originalPropValue, newPropValue) → {boolean}

Check whether the output of the current parameter property should be outputted in full language mode (object) or a simple string.

Parameters:
Name Type Description
originalPropValue string | Object

Original property value

newPropValue string | Object

New property value

Source:
Returns:

Output should be a full language object

Type
boolean

outputTemplateData() → {Object}

Process the current model and output it

Source:
Returns:

Templatedata object

Type
Object

propRemoveUnusedLanguages(propData) → {Object}

Go over a language property and remove empty language key values

Parameters:
Name Type Description
propData Object

Property data

Source:
Returns:

Property data with only used language keys

Type
Object

removeKeyTemplateParamOrder(key)

Add a key to the end of the paramOrder

Parameters:
Name Type Description
key string

New key the add into the paramOrder

Source:
Fires:

reorderParamOrderKey(key, newIndex)

TODO: document

Parameters:
Name Type Description
key string
newIndex number
Source:
Fires:

restoreOriginalMaps()

Get original Parameters/Info from the model and discard any changes

Source:

restoreParam(paramKey)

Restore parameter by unmarking it as deleted.

Parameters:
Name Type Description
paramKey string

Parameter key

Source:
Fires:

setFullPageName(pageName)

Get full page name

Parameters:
Name Type Description
pageName string

Page name

Source:

setMapInfo(map)

Parameters:
Name Type Description
map Object | undefined

New template map info

Source:
Fires:

setOriginalTemplateDataObject(templatedataObj)

Set the original templatedata object

Parameters:
Name Type Description
templatedataObj Object | null

TemplateData object

Source:

setParamProperty(paramKey, prop, value, languageopt) → {boolean}

Set a specific parameter's property

Parameters:
Name Type Attributes Description
paramKey string

Parameter key

prop string

Property name

value Mixed
language string <optional>

Value language

Source:
Fires:
Returns:

Operation was successful

Type
boolean

setParentPage(parent)

Set parent page

Parameters:
Name Type Description
parent string

Parent page

Source:

setSourceCodeParameters(sourceParams)

Set the parameters that are available in the template source code

Parameters:
Name Type Description
sourceParams Array.<string>

Parameters available in template source

Source:

setTemplateDescription(desc, languageopt)

Set the template description

Parameters:
Name Type Attributes Description
desc string | Object

New template description

language string <optional>

Description language, if supplied. If not given, will default to the wiki language.

Source:
Fires:

setTemplateFormat(formatopt)

Set template format.

Parameters:
Name Type Attributes Default Description
format string | null <optional>
null

Preferred format

Source:
Fires:

setTemplateParamOrder(orderArrayopt)

Set template param order array.

Parameters:
Name Type Attributes Description
orderArray Array.<string> <optional>

Parameter key array in order

Source:
Fires: