Static class that contains all the modules and the tools to manage them.
- Source:
Members
-
<static, readonly> STATUSES :integer
-
Enum which defines possible module statuses.
Type:
- integer
- Source:
Properties:
Name Type Default Description FAILED
integer -1 The module has failed to load.
UNKNOWN
integer 0 The module has an unkwnown status.
UNLOADED
integer 1 The module is not loaded yet. Default status.
LOADING
integer 2 The module is being loading.
LOADED
integer 3 The module has loaded successfully (coudl be not ready yet).
READY
integer 4 The module has loaded successfully and it is ready to be used.
-
<static> modules :Object
-
Contains all the modules, one per property.
Type:
- Object
- Source:
Properties:
Name Type Description name_of_the_module
CB_Modules.MODULE Object that contains the module data. The property name must be the name of the module.
Methods
-
<static> addNeededFiles(moduleName, neededFiles) → {boolean}
-
Attaches files to a module.
Parameters:
Name Type Description moduleName
string Name of the module which will contain the new files.
neededFiles
CB_Modules.NEEDED_FILES The "neededFiles" parameter for the module.
- Source:
Returns:
It will return true if succeeded or false otherwise.
- Type
- boolean
-
<static> addNeededModule(moduleNameParent, moduleName, neededFiles) → {boolean}
-
Attaches one module to another one.
Parameters:
Name Type Description moduleNameParent
string Name of the parent module where the new child module will be attached to.
moduleName
string Name of the new child module which will be attached to the given parent.
neededFiles
CB_Modules.NEEDED_FILES The "neededFiles" parameter for the new child module.
- Source:
Returns:
It will return true if succeeded or false otherwise.
- Type
- boolean
-
<static> editProperty(moduleName, property, value [, type] [, iterateArray]) → {boolean}
-
Modifies a desired property of a given module.
Parameters:
Name Type Argument Default Description moduleName
string Name of the module which contains the property to modify.
property
string Name of the property to modify.
value
* Value desired for the property.
type
'array' | 'object' | 'scalar' <optional>
'scalar' Type that the property uses.
If it is "array", the given "value" will be attached at the end of the array (all in a new single index if the "iterateArray" parameter is set to false, or each value in a new index otherwise).
If it is "object", the given "value" and the given "property" to modify will be treated as objects and the members of the "value" will be copied one by one (overwriting previous members in the case they existed).
If it is "scalar" or any other, the given "property" value will be replaced with the given "value".iterateArray
boolean <optional>
false If is set to true and the given "type" is "array", the given "value" will be considered an array and will be iterated to copy each of its values to a new index in the destiny. Otherwise, if it is set to false and the given "type" is "array", the given "value" will be attached at the end of the array in a new single index.
- Source:
Returns:
It will return true if succeeded or false otherwise.
- Type
- boolean
-
<static> get(moduleName) → {CB_Modules.MODULE|null}
-
Returns a
CB_Modules.MODULE
object for module management.Parameters:
Name Type Description moduleName
string Name of the desired module.
- Source:
Returns:
If found, it will return the
CB_Modules.MODULE
object desired. Otherwise, it will return null.- Type
- CB_Modules.MODULE | null
-
<static> getProperty(moduleName, property) → {*|null}
-
Gets the value of a desired module property (or returns null).
Parameters:
Name Type Description moduleName
string Name of the desired module.
property
string Name of the desired property.
- Source:
Returns:
If found, it will return the value of the desired module property. Otherwise, it will return null.
- Type
- * | null
-
<static> setStatus(moduleName, status) → {boolean}
-
Sets a status for a given module.
Parameters:
Name Type Description moduleName
string Name of the module.
status
integer The desired status. Must be a value that exists in the
CB_Modules.STATUSES
enum.- Source:
Returns:
It will return true if succeeded or false otherwise.
- Type
- boolean
Type Definitions
-
CALLBACK(scriptPath)
-
Callback for the different events of a module.
Parameters:
Name Type Description scriptPath
string The value for the "scriptPath" parameter used by
CB_init
when it was called.- Source:
-
MODULE
-
Object that contains a module.
Type:
- Object
- Source:
Properties:
Name Type Description name
string Name of the module.
status
CB_Modules.STATUSES Module status.
onCall
CB_Modules.CALLBACK Callback for when the module is called to be loaded. Being "this" the
CB_Modules.MODULE
object itself.onLoad
CB_Modules.CALLBACK Callback for when the module loads successfully. Being "this" the
CB_Modules.MODULE
object itself.onReady
CB_Modules.CALLBACK Callback for when the module is totally ready. Being "this" the
CB_Modules.MODULE
object itself.onFail
CB_Modules.CALLBACK Callback for when the module fails to load. Being "this" the
CB_Modules.MODULE
object itself. NOT IMPLEMENTED YET.neededFiles
CB_Modules.NEEDED_FILES Object containing the needed files.
neededModules
array Array of
CB_Modules.NEEDED_MODULE
objects, containing the needed modules.credits
string Credits of the module.
-
NEEDED_FILE
-
Object that contains a needed file for a module.
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description load
boolean <optional>
false Defines whether to load the file or not.
mandatory
boolean <optional>
false Defines whether the file is mandatory. If the file is not mandatory, its module could be declared as loaded successfully before the file is loaded (and maybe never will).
absolutePath
boolean <optional>
false Defines whether the path of the file is relative to the path of the main script or absolute.
loadChecker
CB_Modules.neededFile_LOAD_CHECKER <optional>
Callback that will be called when the file tries to be loaded and should return true if the file needs to be loaded.
id
string <optional>
Desired string to identify the file.
requires
array <optional>
Array of strings with the IDs of the files that must be loaded before loading this file. The file will not be loaded until the required files are loaded first.
-
NEEDED_FILES
-
Object that contains the needed files for a module. Each property will represent a needed file.
Type:
- Object
- Source:
Properties:
Name Type Description path_to_the_file
CB_Modules.NEEDED_FILE Object that contains a needed file for a module. The property name must be either the path to the file or a variable containing it. Tto use a variable, the name of the property must start with "VALUEOF_" and continue with the name of the variable. In the case that the variable is an object, each property must be separated by a dot (".").
-
NEEDED_MODULE
-
Object that contains a needed module for a parent module.
Type:
- Object
- Source:
Properties:
Name Type Description name
string Name of the module.
neededFiles
CB_Modules.NEEDED_FILES Object containing the needed files.
-
neededFile_LOAD_CHECKER(filepath, neededFile) → {boolean}
-
Callback that is called before loading a file and should return true if we want to load the file or false otherwise.
Parameters:
Name Type Description filepath
string Filepath of the needed file (including the filename).
neededFile
CB_Modules.NEEDED_FILE Object that contains the needed file.
- Source:
Returns:
- Returns true if we want to load the file or false otherwise.
- Type
- boolean