Converse converse.js

Namespace: u

u

Methods

addClass(className, el)

Add a class to an element.

Parameters:
Name Type Description
className string
el Element
Source:

calculateElementHeight(el) → {number}

Return the height of the passed in DOM element, based on the heights of its children.

Parameters:
Name Type Description
el HTMLElement
Source:
Returns:
Type
number

(private) clearTimers(timeout, interval)

Clears the specified timeout and interval.

Parameters:
Name Type Description
timeout number

Id if the timeout to clear.

interval number

Id of the interval to clear.

License:
  • MIT
Source:

(private) clearTimers(timeout, interval)

Clears the specified timeout and interval.

Parameters:
Name Type Description
timeout number

Id if the timeout to clear.

interval number

Id of the interval to clear.

License:
  • MIT
Source:

(private) getCurrentWord(input, indexopt, delineatoropt)

Returns the current word being written in the input element

Parameters:
Name Type Attributes Description
input HTMLElement

The HTMLElement in which text is being entered

index number <optional>

An optional rightmost boundary index. If given, the text value of the input element will only be considered up until this index.

delineator string <optional>

An optional string delineator to differentiate between words.

Source:

(private) getCurrentWord(input, indexopt, delineatoropt)

Returns the current word being written in the input element

Parameters:
Name Type Attributes Description
input HTMLElement

The HTMLElement in which text is being entered

index number <optional>

An optional rightmost boundary index. If given, the text value of the input element will only be considered up until this index.

delineator string <optional>

An optional string delineator to differentiate between words.

Source:

getOOBURLMarkup(url) → {TemplateResult}

Returns the markup for a URL that points to a downloadable asset (such as a video, image or audio file).

Parameters:
Name Type Description
url String
Source:
Returns:
Type
TemplateResult

hasClass(className, el)

Has an element a class?

Parameters:
Name Type Description
className string
el Element
Source:

(private) matchesSelector(el, selector)

Checks whether the DOM element matches the given selector.

Parameters:
Name Type Description
el Element

The DOM element

selector String

The selector

Source:

(private) matchesSelector(el, selector)

Checks whether the DOM element matches the given selector.

Parameters:
Name Type Description
el Element

The DOM element

selector String

The selector

Source:

merge(dst, src)

Merge the second object into the first one.

Parameters:
Name Type Description
dst Object
src Object
Source:

merge(dst, src)

Merge the second object into the first one.

Parameters:
Name Type Description
dst Object
src Object
Source:

(private) nextUntil(el, selector)

Return the element's siblings until one matches the selector.

Parameters:
Name Type Description
el HTMLElement
selector String
Source:

(private) onMultipleEvents(events:, callback:)

Call the callback once all the events have been triggered

Parameters:
Name Type Description
events: Array

An array of objects, with keys object and event, representing the event name and the object it's triggered upon.

callback: function

The function to call once all events have been triggered.

Source:

(private) onMultipleEvents(events:, callback:)

Call the callback once all the events have been triggered

Parameters:
Name Type Description
events: Array

An array of objects, with keys object and event, representing the event name and the object it's triggered upon.

callback: function

The function to call once all events have been triggered.

Source:

(private) queryChildren(el, selector)

Returns a list of children of the DOM element that match the selector.

Parameters:
Name Type Description
el Element

the DOM element

selector String

the selector they should be matched against

Source:

(private) queryChildren(el, selector)

Returns a list of children of the DOM element that match the selector.

Parameters:
Name Type Description
el Element

the DOM element

selector String

the selector they should be matched against

Source:

removeClass(className, el)

Remove a class from an element.

Parameters:
Name Type Description
className string
el Element
Source:

removeElement(el)

Remove an element from its parent

Parameters:
Name Type Description
el Element
Source:

(private) stringToElement(s)

Converts an HTML string into a DOM element. Expects that the HTML string has only one top-level element, i.e. not multiple ones.

Parameters:
Name Type Description
s String

The HTML string

Source:

(private) stringToElement(s)

Converts an HTML string into a DOM element. Expects that the HTML string has only one top-level element, i.e. not multiple ones.

Parameters:
Name Type Description
s String

The HTML string

Source:

(private) unescapeHTML(string)

Helper method that replace HTML-escaped symbols with equivalent characters (e.g. transform occurrences of '&' to '&')

Parameters:
Name Type Description
string String

a String containing the HTML-escaped symbols.

Source:

waitUntil(func, max_waitopt, check_delayopt) → {Promise}

Creates a Promise that resolves if the passed in function returns a truthy value. Rejects if it throws or does not return truthy within the given max_wait.

Parameters:
Name Type Attributes Default Description
func function

The function called every check_delay, and the result of which is the resolved value of the promise.

max_wait number <optional>
300

The time to wait before rejecting the promise.

check_delay number <optional>
3

The time to wait before each invocation of {func}.

License:
  • MIT
Source:
Returns:

A promise resolved with the value of func, or rejected with the exception thrown by it or it times out.

Type
Promise

waitUntil(func, max_waitopt, check_delayopt) → {Promise}

Creates a Promise that resolves if the passed in function returns a truthy value. Rejects if it throws or does not return truthy within the given max_wait.

Parameters:
Name Type Attributes Default Description
func function

The function called every check_delay, and the result of which is the resolved value of the promise.

max_wait number <optional>
300

The time to wait before rejecting the promise.

check_delay number <optional>
3

The time to wait before each invocation of {func}.

License:
  • MIT
Source:
Returns:

A promise resolved with the value of func, or rejected with the exception thrown by it or it times out.

Type
Promise

(private) webForm2xForm(field)

Takes an HTML DOM and turns it into an XForm field.

Parameters:
Name Type Description
field Element

the field to convert

Source:

xForm2TemplateResult(field, stanza, options) → {TemplateResult}

Takes an XML field in XMPP XForm (XEP-004: Data Forms) format returns a TemplateResult.

Parameters:
Name Type Description
field Element

the field to convert

stanza Element

the containing stanza

options Object
Source:
Returns:
Type
TemplateResult

(static) getEmojisByAtrribute(attr) → {Object}

Parameters:
Name Type Description
attr 'category' | 'cp' | 'sn'

The attribute according to which the returned map should be keyed.

Source:
Returns:

Map of emojis with the passed in attr used as key and a list of emojis as values.

Type
Object

(static) getEmojisByAtrribute(attr) → {Object}

Parameters:
Name Type Description
attr 'category' | 'cp' | 'sn'

The attribute according to which the returned map should be keyed.

Source:
Returns:

Map of emojis with the passed in attr used as key and a list of emojis as values.

Type
Object

(static) isOnlyEmojis(text) → {Boolean}

Determines whether the passed in string is just a single emoji shortname;

Parameters:
Name Type Description
text String

A string which migh be just an emoji shortname

Source:
Returns:
Type
Boolean

(static) isOnlyEmojis(text) → {Boolean}

Determines whether the passed in string is just a single emoji shortname;

Parameters:
Name Type Description
text String

A string which migh be just an emoji shortname

Source:
Returns:
Type
Boolean

(static) shortnamesToEmojis(str, options) → {Array}

Returns an emoji represented by the passed in shortname. Scans the passed in text for shortnames and replaces them with emoji unicode glyphs or alternatively if it's a custom emoji without unicode representation then a lit TemplateResult which represents image tag markup is returned.

The shortname needs to be defined in emojis.json and needs to have either a cp attribute for the codepoint, or an url attribute which points to the source for the image.

Parameters:
Name Type Description
str String

String containg the shortname(s)

options Object
Properties
Name Type Description
unicode_only Boolean

Whether emojis are rendered as unicode codepoints. If so, the returned result will be an array with containing one string, because the emojis themselves will also be strings. If set to false, emojis will be represented by lit TemplateResult objects.

add_title_wrapper Boolean

Whether unicode codepoints should be wrapped with a <span> element with a title, so that the shortname is shown upon hovering with the mouse.

Source:
Returns:

An array of at least one string, or otherwise strings and lit TemplateResult objects.

Type
Array

(static) shortnamesToUnicode(str) → {String}

Replaces all shortnames in the passed in string with their unicode (emoji) representation.

Parameters:
Name Type Description
str String

String containing the shortname(s)

Source:
Returns:
Type
String

(static) shortnamesToUnicode(str) → {String}

Replaces all shortnames in the passed in string with their unicode (emoji) representation.

Parameters:
Name Type Description
str String

String containing the shortname(s)

Source:
Returns:
Type
String

u

The utils object

Source:

Methods

addClass(className, el)

Add a class to an element.

Parameters:
Name Type Description
className string
el Element
Source:

calculateElementHeight(el) → {number}

Return the height of the passed in DOM element, based on the heights of its children.

Parameters:
Name Type Description
el HTMLElement
Source:
Returns:
Type
number

(private) clearTimers(timeout, interval)

Clears the specified timeout and interval.

Parameters:
Name Type Description
timeout number

Id if the timeout to clear.

interval number

Id of the interval to clear.

License:
  • MIT
Source:

(private) clearTimers(timeout, interval)

Clears the specified timeout and interval.

Parameters:
Name Type Description
timeout number

Id if the timeout to clear.

interval number

Id of the interval to clear.

License:
  • MIT
Source:

(private) getCurrentWord(input, indexopt, delineatoropt)

Returns the current word being written in the input element

Parameters:
Name Type Attributes Description
input HTMLElement

The HTMLElement in which text is being entered

index number <optional>

An optional rightmost boundary index. If given, the text value of the input element will only be considered up until this index.

delineator string <optional>

An optional string delineator to differentiate between words.

Source:

(private) getCurrentWord(input, indexopt, delineatoropt)

Returns the current word being written in the input element

Parameters:
Name Type Attributes Description
input HTMLElement

The HTMLElement in which text is being entered

index number <optional>

An optional rightmost boundary index. If given, the text value of the input element will only be considered up until this index.

delineator string <optional>

An optional string delineator to differentiate between words.

Source:

getOOBURLMarkup(url) → {TemplateResult}

Returns the markup for a URL that points to a downloadable asset (such as a video, image or audio file).

Parameters:
Name Type Description
url String
Source:
Returns:
Type
TemplateResult

hasClass(className, el)

Has an element a class?

Parameters:
Name Type Description
className string
el Element
Source:

(private) matchesSelector(el, selector)

Checks whether the DOM element matches the given selector.

Parameters:
Name Type Description
el Element

The DOM element

selector String

The selector

Source:

(private) matchesSelector(el, selector)

Checks whether the DOM element matches the given selector.

Parameters:
Name Type Description
el Element

The DOM element

selector String

The selector

Source:

merge(dst, src)

Merge the second object into the first one.

Parameters:
Name Type Description
dst Object
src Object
Source:

merge(dst, src)

Merge the second object into the first one.

Parameters:
Name Type Description
dst Object
src Object
Source:

(private) nextUntil(el, selector)

Return the element's siblings until one matches the selector.

Parameters:
Name Type Description
el HTMLElement
selector String
Source:

(private) onMultipleEvents(events:, callback:)

Call the callback once all the events have been triggered

Parameters:
Name Type Description
events: Array

An array of objects, with keys object and event, representing the event name and the object it's triggered upon.

callback: function

The function to call once all events have been triggered.

Source:

(private) onMultipleEvents(events:, callback:)

Call the callback once all the events have been triggered

Parameters:
Name Type Description
events: Array

An array of objects, with keys object and event, representing the event name and the object it's triggered upon.

callback: function

The function to call once all events have been triggered.

Source:

(private) queryChildren(el, selector)

Returns a list of children of the DOM element that match the selector.

Parameters:
Name Type Description
el Element

the DOM element

selector String

the selector they should be matched against

Source:

(private) queryChildren(el, selector)

Returns a list of children of the DOM element that match the selector.

Parameters:
Name Type Description
el Element

the DOM element

selector String

the selector they should be matched against

Source:

removeClass(className, el)

Remove a class from an element.

Parameters:
Name Type Description
className string
el Element
Source:

removeElement(el)

Remove an element from its parent

Parameters:
Name Type Description
el Element
Source:

(private) stringToElement(s)

Converts an HTML string into a DOM element. Expects that the HTML string has only one top-level element, i.e. not multiple ones.

Parameters:
Name Type Description
s String

The HTML string

Source:

(private) stringToElement(s)

Converts an HTML string into a DOM element. Expects that the HTML string has only one top-level element, i.e. not multiple ones.

Parameters:
Name Type Description
s String

The HTML string

Source:

(private) unescapeHTML(string)

Helper method that replace HTML-escaped symbols with equivalent characters (e.g. transform occurrences of '&' to '&')

Parameters:
Name Type Description
string String

a String containing the HTML-escaped symbols.

Source:

waitUntil(func, max_waitopt, check_delayopt) → {Promise}

Creates a Promise that resolves if the passed in function returns a truthy value. Rejects if it throws or does not return truthy within the given max_wait.

Parameters:
Name Type Attributes Default Description
func function

The function called every check_delay, and the result of which is the resolved value of the promise.

max_wait number <optional>
300

The time to wait before rejecting the promise.

check_delay number <optional>
3

The time to wait before each invocation of {func}.

License:
  • MIT
Source:
Returns:

A promise resolved with the value of func, or rejected with the exception thrown by it or it times out.

Type
Promise

waitUntil(func, max_waitopt, check_delayopt) → {Promise}

Creates a Promise that resolves if the passed in function returns a truthy value. Rejects if it throws or does not return truthy within the given max_wait.

Parameters:
Name Type Attributes Default Description
func function

The function called every check_delay, and the result of which is the resolved value of the promise.

max_wait number <optional>
300

The time to wait before rejecting the promise.

check_delay number <optional>
3

The time to wait before each invocation of {func}.

License:
  • MIT
Source:
Returns:

A promise resolved with the value of func, or rejected with the exception thrown by it or it times out.

Type
Promise

(private) webForm2xForm(field)

Takes an HTML DOM and turns it into an XForm field.

Parameters:
Name Type Description
field Element

the field to convert

Source:

xForm2TemplateResult(field, stanza, options) → {TemplateResult}

Takes an XML field in XMPP XForm (XEP-004: Data Forms) format returns a TemplateResult.

Parameters:
Name Type Description
field Element

the field to convert

stanza Element

the containing stanza

options Object
Source:
Returns:
Type
TemplateResult

(static) getEmojisByAtrribute(attr) → {Object}

Parameters:
Name Type Description
attr 'category' | 'cp' | 'sn'

The attribute according to which the returned map should be keyed.

Source:
Returns:

Map of emojis with the passed in attr used as key and a list of emojis as values.

Type
Object

(static) getEmojisByAtrribute(attr) → {Object}

Parameters:
Name Type Description
attr 'category' | 'cp' | 'sn'

The attribute according to which the returned map should be keyed.

Source:
Returns:

Map of emojis with the passed in attr used as key and a list of emojis as values.

Type
Object

(static) isOnlyEmojis(text) → {Boolean}

Determines whether the passed in string is just a single emoji shortname;

Parameters:
Name Type Description
text String

A string which migh be just an emoji shortname

Source:
Returns:
Type
Boolean

(static) isOnlyEmojis(text) → {Boolean}

Determines whether the passed in string is just a single emoji shortname;

Parameters:
Name Type Description
text String

A string which migh be just an emoji shortname

Source:
Returns:
Type
Boolean

(static) shortnamesToEmojis(str, options) → {Array}

Returns an emoji represented by the passed in shortname. Scans the passed in text for shortnames and replaces them with emoji unicode glyphs or alternatively if it's a custom emoji without unicode representation then a lit TemplateResult which represents image tag markup is returned.

The shortname needs to be defined in emojis.json and needs to have either a cp attribute for the codepoint, or an url attribute which points to the source for the image.

Parameters:
Name Type Description
str String

String containg the shortname(s)

options Object
Properties
Name Type Description
unicode_only Boolean

Whether emojis are rendered as unicode codepoints. If so, the returned result will be an array with containing one string, because the emojis themselves will also be strings. If set to false, emojis will be represented by lit TemplateResult objects.

add_title_wrapper Boolean

Whether unicode codepoints should be wrapped with a <span> element with a title, so that the shortname is shown upon hovering with the mouse.

Source:
Returns:

An array of at least one string, or otherwise strings and lit TemplateResult objects.

Type
Array

(static) shortnamesToUnicode(str) → {String}

Replaces all shortnames in the passed in string with their unicode (emoji) representation.

Parameters:
Name Type Description
str String

String containing the shortname(s)

Source:
Returns:
Type
String

(static) shortnamesToUnicode(str) → {String}

Replaces all shortnames in the passed in string with their unicode (emoji) representation.

Parameters:
Name Type Description
str String

String containing the shortname(s)

Source:
Returns:
Type
String