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 FAILEDinteger -1 The module has failed to load.
UNKNOWNinteger 0 The module has an unkwnown status.
UNLOADEDinteger 1 The module is not loaded yet. Default status.
LOADINGinteger 2 The module is being loading.
LOADEDinteger 3 The module has loaded successfully (coudl be not ready yet).
READYinteger 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_moduleCB_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 moduleNamestring Name of the module which will contain the new files.
neededFilesCB_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 moduleNameParentstring Name of the parent module where the new child module will be attached to.
moduleNamestring Name of the new child module which will be attached to the given parent.
neededFilesCB_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 moduleNamestring Name of the module which contains the property to modify.
propertystring 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".iterateArrayboolean <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.MODULEobject for module management.Parameters:
Name Type Description moduleNamestring Name of the desired module.
- Source:
Returns:
If found, it will return the
CB_Modules.MODULEobject 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 moduleNamestring Name of the desired module.
propertystring 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 moduleNamestring Name of the module.
statusinteger The desired status. Must be a value that exists in the
CB_Modules.STATUSESenum.- 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 scriptPathstring The value for the "scriptPath" parameter used by
CB_initwhen it was called.- Source:
-
MODULE
-
Object that contains a module.
Type:
- Object
- Source:
Properties:
Name Type Description namestring Name of the module.
statusCB_Modules.STATUSES Module status.
onCallCB_Modules.CALLBACK Callback for when the module is called to be loaded. Being "this" the
CB_Modules.MODULEobject itself.onLoadCB_Modules.CALLBACK Callback for when the module loads successfully. Being "this" the
CB_Modules.MODULEobject itself.onReadyCB_Modules.CALLBACK Callback for when the module is totally ready. Being "this" the
CB_Modules.MODULEobject itself.onFailCB_Modules.CALLBACK Callback for when the module fails to load. Being "this" the
CB_Modules.MODULEobject itself. NOT IMPLEMENTED YET.neededFilesCB_Modules.NEEDED_FILES Object containing the needed files.
neededModulesarray Array of
CB_Modules.NEEDED_MODULEobjects, containing the needed modules.creditsstring Credits of the module.
-
NEEDED_FILE
-
Object that contains a needed file for a module.
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description loadboolean <optional>
false Defines whether to load the file or not.
mandatoryboolean <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).
absolutePathboolean <optional>
false Defines whether the path of the file is relative to the path of the main script or absolute.
loadCheckerCB_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.
idstring <optional>
Desired string to identify the file.
requiresarray <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_fileCB_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 namestring Name of the module.
neededFilesCB_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 filepathstring Filepath of the needed file (including the filename).
neededFileCB_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