Class: Helper

Helper()

new Helper()

static Helper methods
Source:

Members

(private, static) baseUri :string|null

cache for script location
Type:
  • string | null
Source:

Methods

(static) baseUri() → {string}

get the current location (without search or hash part of the URL), eg. https://example.com/path/?aaaa#bbbb --> https://example.com/path/
Source:
Returns:
Type
string

(static) calculateExpirationDate(initialDate, expirationDisplayStringOrSecondsToExpire) → {Date}

calculate expiration date given initial date and expiration period
Parameters:
Name Type Description
initialDate Date may not be empty
expirationDisplayStringOrSecondsToExpire string | number may not be empty
Source:
Returns:
Type
Date

(static) CommentFactory(data) → {Comment}

wrap an object into a Comment, used for mocking in the unit tests
Parameters:
Name Type Description
data object
Source:
Returns:
Type
Comment

(static) getCookie(cname) → {string}

get value of cookie, if it was set, empty string otherwise
Parameters:
Name Type Description
cname string may not be empty
Source:
See:
Returns:
Type
string

(static) htmlEntities(string)

encode all applicable characters to HTML entities
Parameters:
Name Type Description
string str
Source:
See:
Returns:
string escaped HTML

(static) PasteFactory(data) → {Paste}

wrap an object into a Paste, used for mocking in the unit tests
Parameters:
Name Type Description
data object
Source:
Returns:
Type
Paste

(static) reset()

resets state, used for unit testing
Source:

(static) secondsToHuman(seconds) → {Array}

converts a duration (in seconds) into human friendly approximation
Parameters:
Name Type Description
seconds number
Source:
Returns:
Type
Array

(static) selectText(element)

text range selection
Parameters:
Name Type Description
element HTMLElement
Source:
See:

(static) sprintf(format, …args) → {string}

minimal sprintf emulation for %s and %d formats Note that this function needs the parameters in the same order as the format strings appear in the string, contrary to the original.
Parameters:
Name Type Attributes Description
format string
args * <repeatable>
one or multiple parameters injected into format string
Source:
See:
Returns:
Type
string
convert URLs to clickable links. URLs to handle:
    magnet:?xt.1=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C&xt.2=urn:sha1:TXGCZQTH26NL6OUQAJJPFALHG2LTGBC7
    https://example.com:8800/zero/?6f09182b8ea51997#WtLEUO5Epj9UHAV9JFs+6pUQZp13TuspAUjnF+iM+dM=
    http://user:example.com@localhost:8800/zero/?6f09182b8ea51997#WtLEUO5Epj9UHAV9JFs+6pUQZp13TuspAUjnF+iM+dM=
Parameters:
Name Type Description
html string
Source:
Returns:
Type
string