Skip to content
On this page

custom-belt-lib / Modules / Belt

Module: Belt ​

Table of contents ​

Enumerations ​

Interfaces ​

Variables ​

Functions ​

Variables ​

DefaultBeltBorderColor ​

• Const DefaultBeltBorderColor: "#434244"

Default border color when no color provided

Defined in ​

Belt.ts:222


DefaultBeltColor ​

• Const DefaultBeltColor: "#FF0000"

Default color when no color provided

Defined in ​

Belt.ts:220


MaximumStripeCount ​

• Const MaximumStripeCount: 10

Maximum number of stripes a belt may have

Defined in ​

Belt.ts:224


MinimumStripeCount ​

• Const MinimumStripeCount: 0

Minimum number of stripes

Defined in ​

Belt.ts:226


StripePositionDefault ​

• Const StripePositionDefault: Right = StripePosition.Right

Default stripe position

Defined in ​

Belt.ts:228


UniqueIDPrefix ​

• Const UniqueIDPrefix: "custom-belt-"

Default prefix for unique element id

Defined in ​

Belt.ts:230

Functions ​

combineBeltProps ​

▸ combineBeltProps(beltProps): BeltProps[]

Combine multiple BeltProps[] arrays into a single BeltProps[] array

Parameters ​

NameTypeDescription
beltPropsBeltProps[][]array of BeltProp[] arrays to combine

Returns ​

BeltProps[]

combined array of BeltProps[] arrays

Defined in ​

Belt.ts:241


generateUniqueId ​

▸ generateUniqueId(): string

Generate unique element id for belt

Returns ​

string

unique element id

Defined in ​

Belt.ts:253


getBelt ​

▸ getBelt(id?, name?, type?, sortOrder?, color1?, color2?, color3?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?): Belt

Create new Belt object

Parameters ​

NameTypeDefault valueDescription
idnumber0unique identifier for belt
namestring''unique name of belt
typeBeltTypeBeltType.Solidtype of belt
sortOrdernumber0used for sorting belts for display
color1string''hex value for belt color 1
color2string''hex value for belt color 2
color3string''hex value for belt color 3
borderColorstring''hex value for belt border color
hasPatchbooleanfalsewhether belt has patch or not
patchColorstring''hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePositionDefaultstarting position of stripes on belt
minStripesnumberMinimumStripeCountminimum number of stripes for belt
maxStripesnumberMaximumStripeCountmaximum number of stripes for belt

Returns ​

Belt

Belt object

Defined in ​

Belt.ts:280


getBeltAttributes ​

▸ getBeltAttributes(id?, width?, styles?, classes?): BeltAttributes

Create new BeltAttributes object

Parameters ​

NameTypeDefault valueDescription
idnull | stringnullelement id for belt SVG
widthnull | stringnullwidth of belt SVG
stylesnull | stringnulladditional style elements for belt SVG
classesnull | stringnullclasses for belt SVG

Returns ​

BeltAttributes

Belt object

Defined in ​

Belt.ts:337


getBeltColorCount ​

▸ getBeltColorCount(beltType): number

Get number of colors in BeltType [1-3]

Parameters ​

NameTypeDescription
beltTypeBeltTypeBeltType to lookup color count

Returns ​

number

number of colors in beltType

Defined in ​

Belt.ts:359


getBeltProps ​

▸ getBeltProps(name, beltType, color1, color2, color3, id?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
namestringundefinedunique name of belt
beltTypeBeltTypeundefinedtype of belt
color1stringundefinedhex value for belt color 1
color2stringundefinedhex value for belt color 2
color3stringundefinedhex value for belt color 3
idnumber0unique identifier for belt
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
minStripesnumber0minimum number of stripes for belt
maxStripesnumber10maximum number of stripes for belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:406


getBeltPropsCheckered ​

▸ getBeltPropsCheckered(name, color1, color2, id?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new Checkered BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
namestringundefinedunique name of belt
color1stringundefinedhex value for belt color 1
color2stringundefinedhex value for belt color 2
idnumber0unique identifier for belt
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
minStripesnumber0minimum number of stripes for belt
maxStripesnumber10maximum number of stripes for belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:489


getBeltPropsCoral ​

▸ getBeltPropsCoral(name, color1, color2, id?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new Coral BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
namestringundefinedunique name of belt
color1stringundefinedhex value for belt color 1
color2stringundefinedhex value for belt color 2
idnumber0unique identifier for belt
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
minStripesnumber0minimum number of stripes for belt
maxStripesnumber10maximum number of stripes for belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:558


getBeltPropsCrazy ​

▸ getBeltPropsCrazy(borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeCount?, stripePosition?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new Crazy BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:623


getBeltPropsFromBelt ​

▸ getBeltPropsFromBelt(belt, stripeCount?, stripePosition?, transitionCSS?, refreshInterval?, callback?): BeltProps

Create new BeltProps[] array from Belt object

Parameters ​

NameTypeDefault valueDescription
beltBeltundefinedBelt object to create BeltProps[] array from
stripeCountnumber0number of stripes for belt [0-10]
stripePosition?StripePositionStripePositionDefaultstarting position of stripes on belt patch
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval in milliseconds before displaying next belt
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps

BeltProps[] array

Defined in ​

Belt.ts:666


getBeltPropsRandom ​

▸ getBeltPropsRandom(hasPatch?, hasProfessorPatch?, stripeCount?, stripePosition?, transitionCSS?, includeBelts?, refreshInterval?, callback?): BeltProps[]

Create new random BeltProps[] array

Parameters ​

NameTypeDescription
hasPatch?booleanwhether belt has a patch
hasProfessorPatch?booleanwhether belt has a professor patch
stripeCount?numbernumber of stripes for belt [0-10]
stripePosition?StripePositionstarting position of streips on belt patch
transitionCSS?stringCSS for transition animation
includeBelts?BeltType[]array of BeltTyps to include in random selection
refreshInterval?numberinterval in milliseconds before displaying next belt
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidcallback function to call after belt actions

Returns ​

BeltProps[]

Belt object

Defined in ​

Belt.ts:812


getBeltPropsSolid ​

▸ getBeltPropsSolid(name, color, id?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new Solid BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
namestringundefinedunique name of belt
colorstringundefinedhex value for belt color 1
idnumber0unique identifier for belt
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
minStripesnumber0minimum number of stripes for belt
maxStripesnumber10maximum number of stripes for belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:946


getBeltPropsSplit ​

▸ getBeltPropsSplit(name, color1, color2, id?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new Split BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
namestringundefinedunique name of belt
color1stringundefinedhex value for belt color 1
color2stringundefinedhex value for belt color 2
idnumber0unique identifier for belt
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
minStripesnumber0minimum number of stripes for belt
maxStripesnumber10maximum number of stripes for belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:1014


getBeltPropsStriped ​

▸ getBeltPropsStriped(name, color1, color2, color3, id?, borderColor?, hasPatch?, patchColor?, patchBorderColor?, hasProfessorPatch?, professorPatchColor?, professorBorderColor?, stripeColor?, stripeCount?, stripePosition?, minStripes?, maxStripes?, transitionCSS?, refreshInterval?, callback?): BeltProps[]

Create new Striped BeltProps[] array

Parameters ​

NameTypeDefault valueDescription
namestringundefinedunique name of belt
color1stringundefinedhex value for belt color 1
color2stringundefinedhex value for belt color 2
color3stringundefinedhex value for belt color 3
idnumber0unique identifier for belt
borderColorstringDefaultBeltBorderColorhex value for belt border color
hasPatchbooleantruewhether belt has patch or not
patchColorstring'#000000'hex value for patch color
patchBorderColorstring''hex value for patch border color
hasProfessorPatchbooleanfalsewhether belt has professor patch or not
professorPatchColorstring''hex value for professor patch color
professorBorderColorstring''hex value for professor patch border color
stripeColorstring''hex value for stripe color
stripeCountnumber0number of stripes for belt [0-10]
stripePositionStripePositionStripePosition.Rightstarting position of stripes on belt
minStripesnumber0minimum number of stripes for belt
maxStripesnumber10maximum number of stripes for belt
transitionCSSstring''CSS for transition animation
refreshIntervalnumber0interval for refreshing belt in milliseconds
callback?(callbackType: BeltCallbackType, belt: BeltProps, event: null | Event) => voidundefinedcallback function to call after belt actions

Returns ​

BeltProps[]

BeltProps[] array

Defined in ​

Belt.ts:1084


isValidHexCode ​

▸ isValidHexCode(input): boolean

Check for valid color hex code (must begin with # and then 3 or 6 valid hex characters)

RegEx: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/

Example JavaScript Usage:

js
isValidHexCode("#1AFFa1"); // returns true
isValidHexCode("#F00"); // returns true
isValidHexCode("123456"); // returns false (does not begin with #)
isValidHexCode("#123abce"); // returns false (too long)
isValidHexCode("#afafah"); // returns false (contains invalid character)

Parameters ​

NameTypeDescription
inputstringstring to validate

Returns ​

boolean

true if valid color hex code, false otherwise

Defined in ​

Belt.ts:1149


mapBeltColor ​

▸ mapBeltColor(color, colors): string

Return hex code from BeltColor[] for color name

Parameters ​

NameTypeDescription
colorstringcolor name to lookup
colorsBeltColor[]BeltColor[] lookup array

Returns ​

string

found hex code or original color name

Defined in ​

Belt.ts:1172


mapBeltColors ​

▸ mapBeltColors(belts, colors): void

Map all belt color names in all Belt array object to hex codes

Parameters ​

NameTypeDescription
beltsBelt[]belt object
colorsBeltColor[]BeltColor[] lookup array

Returns ​

void

Defined in ​

Belt.ts:1195

Released under the MIT License.