eLabSDK.Experiment.Section.CustomSectionType

Classes

NameDescription
eLabSDKeLabSDK.Experiment.CustomSectionType

Functions

NameDescription
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).

ParamTypeDescription
categoryStringCategory for the custom type (e.g., 'data', 'text', 'inventory', 'files')
typeStringUnique identifier for the custom section type
labelStringDisplay name shown in the "Add Section" dropdown
getContentfunctionFunction that returns a Promise resolving to HTML content to display in the section
rootVarStringRoot variable identifier for the add-on
nameStringName of the add-on
versionStringVersion 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

ParamTypeDescription
configObjectConfiguration object for the custom section type
addonContextObjectContext 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

ParamTypeDescription
hexColorStringHex 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

ParamTypeDescription
hexStringHex color string without the # prefix
lumNumberLuminosity 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

ParamTypeDescription
htmlContentStringThe HTML content to save to the section
expJournalIdNumberThe experiment journal section ID
experimentIdNumberThe 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

ParamTypeDescription
rootVarStringThe root variable identifier for the add-on
pdfBooleanWhether this content is being generated for PDF export (affects image handling)

© 2023 eLabNext