eLabSDK.Experiment.Section.CustomSectionType
Classes
| Name | Description |
|---|---|
| eLabSDK | eLabSDK.Experiment.CustomSectionType |
Functions
| Name | Description |
|---|---|
| init(config, addonContext) | Initialize the custom section type and register it with the experiment system |
| backgroundColor(hexColor) | Generate a background color gradient from a hex color |
| colorLuminance(hex, lum) | Adjust the luminosity of a hex color |
| saveHtmlContent(htmlContent, expJournalId, experimentId) | Save HTML content to the database for a custom section |
| getInitialContent(rootVar, pdf) | Generate initial content for a new custom section based on marketplace add-on information |
eLabSDK
eLabSDK.Experiment.CustomSectionType
Kind: global class
Extends: eLabSDK.Experiment.Section
new eLabSDK(category, type, label, getContent, rootVar, name, version)
Class that allows the creation of a custom section type.
The class registers the custom section type in the sdk.
Note: Despite the filename, this class is accessed via eLabSDK.Experiment.CustomSectionType
(not eLabSDK.Experiment.Section.CustomSectionType).
| Param | Type | Description |
|---|---|---|
| category | String | Category for the custom type (e.g., 'data', 'text', 'inventory', 'files') |
| type | String | Unique identifier for the custom section type |
| label | String | Display name shown in the "Add Section" dropdown |
| getContent | function | Function that returns a Promise resolving to HTML content to display in the section |
| rootVar | String | Root variable identifier for the add-on |
| name | String | Name of the add-on |
| version | String | Version of the add-on |
Example
Example usage in plugin:
var my_root_var = {};
(function (context) {
context = new eLabSDK.Experiment.CustomSectionType({
category: 'data',
type: 'MyCustomSectionType',
label: 'My Custom Section',
rootVar: 'MY_ADDON_ROOT',
name: 'My Add-on',
version: '1.0.0',
getContent: async function(data, section) {
return '<div>Custom section content</div>';
}
});
})(my_root_var);
init(config, addonContext)
Initialize the custom section type and register it with the experiment system
Kind: global function
| Param | Type | Description |
|---|---|---|
| config | Object | Configuration object for the custom section type |
| addonContext | Object | Context object containing add-on information and license status |
backgroundColor(hexColor)
Generate a background color gradient from a hex color
Kind: global function
Returns: String - CSS linear gradient string
| Param | Type | Description |
|---|---|---|
| hexColor | String | Hex color value (e.g., '#FF0000') |
colorLuminance(hex, lum)
Adjust the luminosity of a hex color
Kind: global function
Returns: String - Adjusted hex color with # prefix
| Param | Type | Description |
|---|---|---|
| hex | String | Hex color string without the # prefix |
| lum | Number | Luminosity adjustment factor (-1 to 1, where -1 is completely dark, 1 is completely bright) |
saveHtmlContent(htmlContent, expJournalId, experimentId)
Save HTML content to the database for a custom section
Kind: global function
Returns: Promise - Promise that resolves when content is successfully saved, rejects on error
| Param | Type | Description |
|---|---|---|
| htmlContent | String | The HTML content to save to the section |
| expJournalId | Number | The experiment journal section ID |
| experimentId | Number | The experiment ID |
getInitialContent(rootVar, pdf)
Generate initial content for a new custom section based on marketplace add-on information
Kind: global function
Returns: Promise - Promise that resolves to HTML string containing the initial section content
| Param | Type | Description |
|---|---|---|
| rootVar | String | The root variable identifier for the add-on |
Boolean | Whether this content is being generated for PDF export (affects image handling) |
© 2023 eLabNext
Updated about 18 hours ago