Namespace: utils

vef.utils

A super module that collects available sub-modules.
Source:

Namespaces

template
universal

Methods

(static) exports.capitalizeString(str)

Method for capitalizing a string
Parameters:
Name Type Description
str string
Source:

(static) exports.createElement(html)

Creates the elements defined by the given HTML string and returns these elements as array or the element, if it is only one.
Parameters:
Name Type Description
html string
Source:
replaces URLs starting with http or https and replaces them with a link tag leading to their location
Parameters:
Name Type Description
text string
Source:
Returns:
text with added link tags
Type
string

(static) exports.debounceCallback(callback, milliseconds) → {function}

Helper method to only execute a callback after the event has not been dispatched for the given amount of milliseconds
Parameters:
Name Type Description
callback function
milliseconds number
Source:
Returns:
add this as event listener
Type
function

(static) exports.displayMessage()

Display a temporary message banner on top of the page
Source:

(static) exports.generateUniqueId() → {string}

Generates an identifier based on time and a random number
Source:
Returns:
Type
string

(static) exports.getHash(list, separator, seed) → {string}

Function to get a hash for a list of strings. If the list argument contains only one string, the hash calculation is applied directly to the string without using the separator. For multiple strings in the list, the strings are merged into one string via the separator, and the hash is calculated. Inspired by: https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js (2023-02-01, public domain license)
Parameters:
Name Type Description
list Array.<String> list containing one or multiple strings
separator string delimiter to join strings in list
seed Number parameter to randomize the hash function
Source:
Returns:
hash
Type
string

(static) exports.getQueryParams(uri) → {object}

Get query params from current document.location or optional URI
Parameters:
Name Type Description
uri string (optional)
Source:
Returns:
URI params
Type
object

(static) exports.isFunction(fn)

Returns true if fn is a function.
Parameters:
Name Type Description
fn object
Source:

(static) exports.isNullorUndefined(value) → {boolean}

Method to check if a value is null or undefined
Parameters:
Name Type Description
value *
Source:
Returns:
Type
boolean

(static) exports.roundNumber(num, decimals)

round a number to the given decimals
Parameters:
Name Type Description
num number
decimals number
Source:

(static) exports.sanitizeHTML(html, returnAsString) → {HTMLElement}

Method to remove script tags to prevent some forms of XSS attacks. This method might note be safe to cover all possible XSS attacks. Inspired by: https://gomakethings.com/how-to-sanitize-html-strings-with-vanilla-js-to-reduce-your-risk-of-xss-attacks/ (2022-10-29)
Parameters:
Name Type Description
html string
returnAsString boolean
Source:
Returns:
parsed element
Type
HTMLElement

(static) exports.saveAsFile(blob, fileName)

Download a Blob as a file Triggers the browsers "save file" dialouge
Parameters:
Name Type Description
blob Blob
fileName string
Source:

(static) exports.setCSSProperties(properties)

iterates through the object and sets the mathing CSS properties. The prefix "--" will automaticalle be added to the property names
Parameters:
Name Type Description
properties object
Source:

(static) exports.setQueryParams(params) → {string}

Create a query params string from a given object
Parameters:
Name Type Description
params object
Source:
Returns:
query string
Type
string