Class: Helper

Helper()

new Helper()

static Helper methods
Source:

Members

(private, static) baseUri :string|null

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

(private, static, readonly) day :number

number of seconds in a day = 60 * 60 * 24 seconds
Type:
  • number
Source:

(private, static, readonly) entityMap :Object

character to HTML entity lookup table
Type:
  • Object
Source:
See:

(private, static, readonly) minute :number

number of seconds in a minute
Type:
  • number
Source:

(private, static, readonly) minute :number

number of seconds in an hour = 60 * 60 seconds
Type:
  • number
Source:

(private, static, readonly) month :number

number of seconds in a month (30 days, an approximation) = 60 * 60 * 24 * 30 seconds
Type:
  • number
Source:

(private, static, readonly) year :number

number of seconds in a non-leap year = 60 * 60 * 24 * 365 seconds
Type:
  • number
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) durationToSeconds(duration) → {number}

converts a duration string into seconds The string is expected to be optional digits, followed by a time. Supported times are: min, hour, day, month, year, never Examples: 5min, 13hour, never
Parameters:
Name Type Description
duration String
Source:
Returns:
Type
number

(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(str) → {string}

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

(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 in the provided element. 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
element HTMLElement
Source: