Module: utility_js

Methods

(inner) arrayToLines(a) → {string}

Joins an array to a multi-line string
Parameters:
Name Type Description
a Array array to join
Source:
Returns:
joined array
Type
string

(inner) basename(uri, removeQuery) → {string}

Gets the filename from the given uri
Parameters:
Name Type Description
uri string the uri
removeQuery boolean true = remove query string or hash
Source:
Returns:
filename part of the uri
Type
string

(inner) checkMediaSessionSupport() → {boolean}

Checks for support of the media session api
Source:
Returns:
true if media session api is supported, else false
Type
boolean

(inner) checkTargetClick(target) → {boolean}

Checks if event should be executed
Parameters:
Name Type Description
target EventTarget triggering event target
Source:
Returns:
true if target is clickable else false
Type
boolean

(inner) concatArrays(c1, c2) → {Array}

Concatenates two arrays and checks if second array is defined
Parameters:
Name Type Description
c1 Array first array
c2 Array second array, can be undefined
Source:
Returns:
concatenated array
Type
Array

(inner) convertType(str) → {string|number|boolean}

Tries to convert a strint to number or bool
Parameters:
Name Type Description
str string string to convert
Source:
Returns:
parsed string
Type
string | number | boolean

(inner) cuesheetTrack(uri) → {string}

Returns the cuesheet track name
Parameters:
Name Type Description
uri string uri to check
Source:
Returns:
the track part
Type
string

(inner) cuesheetUri(uri) → {string}

Returns the cuesheet name
Parameters:
Name Type Description
uri string uri to check
Source:
Returns:
the uri part
Type
string

(inner) dirname(uri) → {string}

Gets the directory from the given uri
Parameters:
Name Type Description
uri string the uri
Source:
Returns:
directory part of the uri
Type
string

(inner) escapeMPD(str) → {string}

Escape a MPD filter value
Parameters:
Name Type Description
str string value to escape
Source:
Returns:
escaped value
Type
string

(inner) filetype(uri, long) → {string}

Returns a description of the filetype from uri
Parameters:
Name Type Description
uri string the uri
long boolean return long description?
Source:
Returns:
description of filetype
Type
string

(inner) focusSearch() → {void}

View specific focus of the search input
Source:
Returns:
Type
void

(inner) getFunctionByName(functionName) → {function}

Returns the function by name
Parameters:
Name Type Description
functionName string name of the function
Source:
Returns:
the function
Type
function

(inner) getMyMPDuri(protoopt) → {string}

Returns the myMPD uri calculated from the window location
Parameters:
Name Type Attributes Description
proto string <optional>
protocol to return, allowed: http or ws
Source:
Returns:
myMPD uri
Type
string

(inner) getTimestamp() → {number}

Gets a unix timestamp
Source:
Returns:
the unix timestamp
Type
number

(async, inner) httpGet(uri, callback, json) → {Promise.<void>}

Generic http get request (async function)
Parameters:
Name Type Description
uri string uri for the request
callback function callback function
json boolean true = parses the response as json, else pass the plain text response
Source:
Returns:
Type
Promise.<void>

(inner) ignoreKeys(event) → {boolean}

Ignore keys for inputs
Parameters:
Name Type Description
event KeyboardEvent triggering key event
Source:
Returns:
true if key event should be ignored, else false
Type
boolean
Initializes elements with data-href attribute
Parameters:
Name Type Description
root Node root of the elements to initialize
Source:
Returns:
Type
void

(inner) joinArray(a) → {string}

Joins an array to a comma separated text
Parameters:
Name Type Description
a Array array to join
Source:
Returns:
joined array
Type
string

(inner) myEncodeURI(str) → {string}

Custom encoding function, works like encodeURIComponent but - does not escape / - escapes further reserved characters
Parameters:
Name Type Description
str string string to encode
Source:
Returns:
the encoded string
Type
string

(inner) myEncodeURIComponent(str) → {string}

Custom encoding function, works like encodeURIComponent but escapes further reserved characters
Parameters:
Name Type Description
str string string to encode
Source:
Returns:
the encoded string
Type
string

(inner) parseCmd(event, cmd) → {void}

Executes a javascript command object
Parameters:
Name Type Description
event Event triggering event
cmd object cmd object
Source:
Returns:
Type
void

(inner) parseCmdFromJSON(event, str) → {void}

Parses a string to a javascript command object
Parameters:
Name Type Description
event Event triggering event
str string string to parse
Source:
Returns:
Type
void

(inner) parseDateFromText(value) → {number}

Parses a YYYY-MM-DD string to unix timestamp
Parameters:
Name Type Description
value string string to parses
Source:
Returns:
unix timestamp
Type
number

(inner) parseToSeconds(value) → {number}

Parses a string to seconds
Parameters:
Name Type Description
value string [hh:]mm:ss value to parse
Source:
Returns:
value in seconds
Type
number

(inner) setMobileView() → {void}

Enables the mobile view for specific user agents
Source:
Returns:
Type
void

(inner) setScrollViewHeight(container) → {void}

Sets the height of the container for scrolling
Parameters:
Name Type Description
container HTMLElement scrolling container element
Source:
Returns:
Type
void

(inner) setUpdateView(el) → {void}

Sets the updating indicator(s) for the element
Parameters:
Name Type Description
el Element element
Source:
Returns:
Type
void

(inner) setUpdateViewId(id) → {void}

Sets the updating indicator(s) for a view with the given id
Parameters:
Name Type Description
id string element id
Source:
Returns:
Type
void

(inner) setViewport() → {void}

Sets the viewport tag scaling option
Source:
Returns:
Type
void

(inner) splitFilename(filename) → {object}

Splits a string in path + filename and extension
Parameters:
Name Type Description
filename string filename to split
Source:
Returns:
object with file and ext keys
Type
object

(inner) ucFirst(word) → {string}

Uppercases the first letter of a word
Parameters:
Name Type Description
word string word to uppercase first letter
Source:
Returns:
changed word
Type
string

(inner) unescapeMPD(str) → {string}

Unescape a MPD filter value
Parameters:
Name Type Description
str string value to unescape
Source:
Returns:
unescaped value
Type
string

(inner) unsetUpdateView(el) → {void}

Removes the updating indicator(s) for the element
Parameters:
Name Type Description
el Element | ParentNode element
Source:
Returns:
Type
void

(inner) unsetUpdateViewId(id) → {void}

Removes the updating indicator(s) for a view with the given id
Parameters:
Name Type Description
id string element id
Source:
Returns:
Type
void

(inner) zeroPad(num, places) → {string}

Pads a number with zeros
Parameters:
Name Type Description
num number number to pad
places number complete width
Source:
Returns:
padded number
Type
string