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 |
Fires:
- event:add-paramOrder
- event:change
addParam(name, paramDataopt)
Add parameter to the model
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | ||
paramData |
Object |
<optional> |
Parameter data |
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 |
Fires:
- event:delete-param
- event:change
emptyParamData(paramKey)
Delete all data attached to a parameter
Parameters:
Name | Type | Description |
---|---|---|
paramKey |
string | Parameter key |
getAllParamNames() → {Array.<string>}
Retrieve an array of all used parameter names. Note that parameter names can be different than their stored keys.
Returns:
Used parameter names
- Type
- Array.<string>
getDefaultLanguage() → {string}
Get the current wiki language code. Defaults on 'en'.
Returns:
Wiki language
- Type
- string
getExistingLanguageCodes() → {Array.<string>}
Retrieve all existing language codes in the current templatedata model
Returns:
Language codes in use
- Type
- Array.<string>
getFullPageName() → {string}
Get page full name
Returns:
Page full name
- Type
- string
getMapInfo() → {Object|undefined}
Get the template info.
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.
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 |
Returns:
Valid new parameter key
- Type
- string
getOriginalMapsInfo() → {Object|undefined}
Get the template info.
Returns:
The Original template map info.
- Type
- Object | undefined
getOriginalTemplateDataObject() → {Object|null}
Get original templatedata object
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 |
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 |
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 |
Returns:
Parameter property in specified language
- Type
- string
getParams() → {Object}
Return the complete object of all parameters.
Returns:
All parameters and their data
- Type
- Object
getParentPage() → {string}
Get parent page
Returns:
Parent page
- Type
- string
getSourceCodeParameters() → {Array.<string>}
Get the parameters that are available in the template source code
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 |
Returns:
- Type
- string
getTemplateFormat() → {string|null}
Retrieve the template preferred format
Returns:
Preferred format
- Type
- string | null
getTemplateParamOrder() → {Array.<string>}
Retrieve the template paramOrder array
Returns:
orderArray Parameter keys in order
- Type
- Array.<string>
importSourceCodeParameters() → {Object}
Add imported parameters into the model
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 |
Returns:
Output should be a full language object
- Type
- boolean
outputTemplateData() → {Object}
Process the current model and output it
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 |
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 |
Fires:
reorderParamOrderKey(key, newIndex)
TODO: document
Parameters:
Name | Type | Description |
---|---|---|
key |
string | |
newIndex |
number |
Fires:
restoreOriginalMaps()
Get original Parameters/Info from the model and discard any changes
setFullPageName(pageName)
Get full page name
Parameters:
Name | Type | Description |
---|---|---|
pageName |
string | Page name |
setMapInfo(map)
Parameters:
Name | Type | Description |
---|---|---|
map |
Object | undefined | New template map info |
Fires:
- event:change-map
- event:change
setOriginalTemplateDataObject(templatedataObj)
Set the original templatedata object
Parameters:
Name | Type | Description |
---|---|---|
templatedataObj |
Object | null | TemplateData object |
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 |
Fires:
Returns:
Operation was successful
- Type
- boolean
setParentPage(parent)
Set parent page
Parameters:
Name | Type | Description |
---|---|---|
parent |
string | Parent page |
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 |
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. |
Fires:
setTemplateFormat(formatopt)
Set template format.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
format |
string | null |
<optional> |
null | Preferred format |
Fires:
- event:change-format
- event:change
setTemplateParamOrder(orderArrayopt)
Set template param order array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
orderArray |
Array.<string> |
<optional> |
Parameter key array in order |