Class Index | File Index

Classes


Class finesse.utilities.Utilities


Extends finesse.restservices.RestBase.
Utilities is collection of utility methods.
Defined in: finesse.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
<static>  
finesse.utilities.Utilities.ampRegEx
Regular expressions used in translating HTML and XML entities
Fields borrowed from class finesse.restservices.RestBase:
restResponseStatus
Method Summary
Method Attributes Method Name and Description
<static>  
finesse.utilities.Utilities.b64Decode(input)
Decodes the given base64 string.
<static>  
finesse.utilities.Utilities.b64Encode(input)
Encodes the given string into base64.
<static>  
finesse.utilities.Utilities.buildElapsedTimeString(adjustedServerTimeInMs, stateStartTimeInMs)
Builds a string which specifies the amount of time user has been in this state (e.g.
<static>  
finesse.utilities.Utilities.buildElapsedTimeStringWithOptionalHours(adjustedServerTimeInMs, startTimeInMs)
Builds a string which specifies the amount of time user has been in this state with optional hours (e.g.
<static>  
finesse.utilities.Utilities.buildHoldTimeString(adjustedServerTimeInMs, holdStartTimeInMs)
Builds a string which displays the hold time in minutes and seconds.
<static>  
finesse.utilities.Utilities.buildTimeString(timeInMs)
Given a specified timeInMs, this method will builds a string which displays minutes and seconds.
<static>  
finesse.utilities.Utilities.buildTimeStringWithOptionalHours(timeInMs)
Given a specified timeInMs, this method will builds a string which displays minutes and seconds (and optionally hours)
<static>  
finesse.utilities.Utilities.buildTotalTimeString(adjustedServerTimeInMs, callStartTimeInMs)
Builds a string which displays the total call time in minutes and seconds.
<static>  
finesse.utilities.Utilities.buildWrapupTimeString(adjustedServerTimeInMs, wrapupStartTimeInMs)
Builds a string which displays the elapsed time the call has been in wrap up.
<static>  
finesse.utilities.Utilities.convertDateToISODateString(aDate)
Converts a date to an ISO date string.
<static>  
finesse.utilities.Utilities.convertNullToEmptyString(str)
Checks if the string is null.
<static>  
finesse.utilities.Utilities.convertToServerTimeMillis(clientTime)
Converts the specified clientTime to server time by adjusting by the current drift.
<static>  
finesse.utilities.Utilities.convertTsToDuration(timestamp, now)
Utility method to render a timestamp string (of format YYYY-MM-DDTHH:MM:SSZ) into a duration of HH:MM:SS format.
<static>  
finesse.utilities.Utilities.convertTsToDurationWithFormat(timestamp, forFormat, now)
Utility method to render a timestamp string (of format YYYY-MM-DDTHH:MM:SSZ) into a duration of HH:MM:SS format, with optional -1 for null or negative times.
<static>  
finesse.utilities.Utilities.currentServerTimeMillis()
Utility method for getting the current time, adjusted by the calculated "drift" to closely approximate the server time.
<static>  
finesse.utilities.Utilities.currentTimeMillis()
Utility method for getting the current time in milliseconds.
<static>  
finesse.utilities.Utilities.dateToISOString(aDate)
Get the date in ISO date format.
<static>  
finesse.utilities.Utilities.encodeNodeName(node)
Encodes the node name
<static>  
finesse.utilities.Utilities.escapeSpaces(text)
Escapes spaces as encoded " " characters so they can be safely rendered by jQuery.text(string) in all browsers.
<static>  
finesse.utilities.Utilities.extractTime(timeStr)
Extracts a time from the timeStr.
<static>  
finesse.utilities.Utilities.getAuthHeaderString(configObj)
The authorization header based on SSO or non SSO deployment.
<static>  
finesse.utilities.Utilities.getAuthModes()
Can be used as a constant for auth modes Can be "SSO" , "NON_SSO" or "HYBRID"
<static>  
finesse.utilities.Utilities.getAuthTokenObj()
Return the user access token as JSON Object.
<static>  
finesse.utilities.Utilities.getCurrentDrift()
Gets the current drift (between client and server)
<static>  
finesse.utilities.Utilities.getDisplayTime(time)
Utility method to render a timestamp value (in seconds) into HH:MM:SS format.
<static>  
finesse.utilities.Utilities.getEquals(obj1, obj2)
Compares two objects for equality.
<static>  
finesse.utilities.Utilities.getParameterByName(str, name)
Takes a string (typically from window.location) and finds the value which corresponds to a name.
<static>  
finesse.utilities.Utilities.getToken()
Returns the user access token as String.
<static>  
finesse.utilities.Utilities.getUserAuthString()
Returns the base64 encoded user authorization String.
<static>  
finesse.utilities.Utilities.isArray(obj)
Takes an Object and determines whether it is an Array or not.
<static>  
finesse.utilities.Utilities.padWithWidth(num, padWidth)
Pad with zeros based on a padWidth.
<static>  
finesse.utilities.Utilities.parseDateStringISO8601(s)
Parse string (which is formated as ISO8601 date) into Javascript Date object.
<static>  
finesse.utilities.Utilities.removeSpaces(string)
Takes a string and removes any spaces within the string.
<static>  
finesse.utilities.Utilities.trim(str)
Trims leading and trailing whitespace from a string.
<static>  
finesse.utilities.Utilities.validateHandler(handler)
Returns the passed in handler, if it is a function.
<static>  
finesse.utilities.Utilities.whenAllDone()
Use JQuery's implementation of Promises (Deferred) to execute code when multiple async processes have finished.
Methods borrowed from class finesse.restservices.RestBase:
addHandler, getData, getId, getProperty, hasProperty, isLoaded, refresh, removeHandler
Class Detail
finesse.utilities.Utilities()
See:
finesse.restservices.Contacts
Field Detail
<static> finesse.utilities.Utilities.ampRegEx
Regular expressions used in translating HTML and XML entities
Method Detail
<static> {String} finesse.utilities.Utilities.b64Decode(input)
Decodes the given base64 string.
NOTE: output is assumed to be UTF-8; only the first 8 bits of each output element are significant.
Parameters:
{String} input
The base64 encoded string
Returns:
{String} Decoded string

<static> {String} finesse.utilities.Utilities.b64Encode(input)
Encodes the given string into base64.
NOTE: {input} is assumed to be UTF-8; only the first 8 bits of each input element are significant.
Parameters:
{String} input
The string to convert to base64.
Returns:
{String} The converted string.

<static> {String} finesse.utilities.Utilities.buildElapsedTimeString(adjustedServerTimeInMs, stateStartTimeInMs)
Builds a string which specifies the amount of time user has been in this state (e.g. 11:23).
Parameters:
adjustedServerTimeInMs
is integer argument which specifies the expected server time (accounting for clientdrift)
stateStartTimeInMs
is integer argument which specifies time call entered current state
Returns:
{String} which is the elapsed time (MINUTES:SECONDS)

<static> {String} finesse.utilities.Utilities.buildElapsedTimeStringWithOptionalHours(adjustedServerTimeInMs, startTimeInMs)
Builds a string which specifies the amount of time user has been in this state with optional hours (e.g. 01:11:23 or 11:23).
Parameters:
adjustedServerTimeInMs
is integer argument which specifies the expected server time (accounting for clientdrift)
startTimeInMs
is integer argument which specifies the start time
Returns:
{String} which is the elapsed time (MINUTES:SECONDS) or (HOURS:MINUTES:SECONDS)

<static> {String} finesse.utilities.Utilities.buildHoldTimeString(adjustedServerTimeInMs, holdStartTimeInMs)
Builds a string which displays the hold time in minutes and seconds.
Parameters:
adjustedServerTimeInMs
is integer argument which specifies the expected server time (accounting for clientdrift)
holdStartTimeInMs
is integer argument which specifies time the hold started
Returns:
{String} which is the elapsed time [MINUTES:SECONDS]

<static> {String} finesse.utilities.Utilities.buildTimeString(timeInMs)
Given a specified timeInMs, this method will builds a string which displays minutes and seconds.
Parameters:
timeInMs
is the time in milliseconds
Returns:
{String} which corresponds to minutes and seconds (e.g. 11:23)

<static> {String} finesse.utilities.Utilities.buildTimeStringWithOptionalHours(timeInMs)
Given a specified timeInMs, this method will builds a string which displays minutes and seconds (and optionally hours)
Parameters:
timeInMs
is the time in milliseconds
Returns:
{String} which corresponds to hours, minutes and seconds (e.g. 01:11:23 or 11:23)

<static> {String} finesse.utilities.Utilities.buildTotalTimeString(adjustedServerTimeInMs, callStartTimeInMs)
Builds a string which displays the total call time in minutes and seconds.
Parameters:
adjustedServerTimeInMs
is integer argument which specifies the expected server time (accounting for clientdrift)
callStartTimeInMs
is integer argument which specifies time the call started
Returns:
{String} which is the elapsed time [MINUTES:SECONDS]

<static> {String} finesse.utilities.Utilities.buildWrapupTimeString(adjustedServerTimeInMs, wrapupStartTimeInMs)
Builds a string which displays the elapsed time the call has been in wrap up.
Parameters:
adjustedServerTimeInMs
is integer argument which specifies the expected server time (accounting for clientdrift)
wrapupStartTimeInMs
is integer argument which specifies time call entered wrapup state
Returns:
{String} which is the elapsed wrapup time

<static> {String} finesse.utilities.Utilities.convertDateToISODateString(aDate)
Converts a date to an ISO date string.
Parameters:
aDate
Returns:
{String} in ISO date format Note: Some browsers don't support this method (e.g. IE8).

<static> {String} finesse.utilities.Utilities.convertNullToEmptyString(str)
Checks if the string is null. If it is, return empty string; else return the string itself.
Parameters:
{String} str
The string to check
Returns:
{String} Empty string or string itself

<static> {int} finesse.utilities.Utilities.convertToServerTimeMillis(clientTime)
Converts the specified clientTime to server time by adjusting by the current drift.
Parameters:
clientTime
is the time in milliseconds
Returns:
{int} serverTime in milliseconds

<static> {String} finesse.utilities.Utilities.convertTsToDuration(timestamp, now)
Utility method to render a timestamp string (of format YYYY-MM-DDTHH:MM:SSZ) into a duration of HH:MM:SS format.
Parameters:
{String} timestamp
The timestamp to render
{Date} now Optional
Optional argument to provide the time from which to calculate the duration instead of using the current time
Returns:
{String} Duration string in HH:MM:SS format.

<static> {String} finesse.utilities.Utilities.convertTsToDurationWithFormat(timestamp, forFormat, now)
Utility method to render a timestamp string (of format YYYY-MM-DDTHH:MM:SSZ) into a duration of HH:MM:SS format, with optional -1 for null or negative times.
Parameters:
{String} timestamp
The timestamp to render
{Boolean} forFormat
If True, if duration is null or negative, return -1 so that the duration can be formated as needed in the Gadget.
{Date} now Optional
Optional argument to provide the time from which to calculate the duration instead of using the current time
Returns:
{String} Duration string in HH:MM:SS format.

<static> {String} finesse.utilities.Utilities.currentServerTimeMillis()
Utility method for getting the current time, adjusted by the calculated "drift" to closely approximate the server time. This is used when calculating durations based on a server timestamp, which otherwise can produce unexpected results if the times on client and server are off.
Returns:
{String} The current server time in milliseconds

<static> {String} finesse.utilities.Utilities.currentTimeMillis()
Utility method for getting the current time in milliseconds.
Returns:
{String} The current time in milliseconds

<static> {String} finesse.utilities.Utilities.dateToISOString(aDate)
Get the date in ISO date format.
Parameters:
aDate
is the date
Returns:
{String} date in ISO format Note: see convertDateToISODateString() above.

<static> finesse.utilities.Utilities.encodeNodeName(node)
Encodes the node name
Parameters:
node

<static> finesse.utilities.Utilities.escapeSpaces(text)
Escapes spaces as encoded " " characters so they can be safely rendered by jQuery.text(string) in all browsers. (Although IE behaves as expected, Firefox collapses spaces if this function is not used.)
Parameters:
text
The string whose spaces should be escaped
Returns:
The string with spaces escaped

<static> {long} finesse.utilities.Utilities.extractTime(timeStr)
Extracts a time from the timeStr. Note: The timeStr could be empty. In this case, the time returned will be 0.
Parameters:
timeStr
is a time string in ISO8601 format (note: could be empty)
Returns:
{long} is the time

<static> {String} finesse.utilities.Utilities.getAuthHeaderString(configObj)
The authorization header based on SSO or non SSO deployment. Can be "Bearer " or "Basic "
Parameters:
configObj
Returns:
{String} The authorization header string.

<static> {String} finesse.utilities.Utilities.getAuthModes()
Can be used as a constant for auth modes Can be "SSO" , "NON_SSO" or "HYBRID"
Returns:
{String} The authorization header string.

<static> {Object} finesse.utilities.Utilities.getAuthTokenObj()
Return the user access token as JSON Object.
Returns:
{Object} the access token JSON object

<static> {integer} finesse.utilities.Utilities.getCurrentDrift()
Gets the current drift (between client and server)
Returns:
{integer} which is the current drift (last calculated; 0 if we have not calculated yet)

<static> {String} finesse.utilities.Utilities.getDisplayTime(time)
Utility method to render a timestamp value (in seconds) into HH:MM:SS format.
Parameters:
{Number} time
The timestamp in ms to render
Returns:
{String} Time string in HH:MM:SS format.

<static> finesse.utilities.Utilities.getEquals(obj1, obj2)
Compares two objects for equality.
Parameters:
{Object} obj1
First of two objects to compare.
{Object} obj2
Second of two objects to compare.

<static> finesse.utilities.Utilities.getParameterByName(str, name)
Takes a string (typically from window.location) and finds the value which corresponds to a name. For example: http://www.company.com/?param1=value1¶m2=value2
Parameters:
str
is the string to search
name
is the name to search for

<static> {String} finesse.utilities.Utilities.getToken()
Returns the user access token as String.
Returns:
{String} the access token

<static> {String} finesse.utilities.Utilities.getUserAuthString()
Returns the base64 encoded user authorization String.
Returns:
{String} the Authorization String

<static> {Boolean} finesse.utilities.Utilities.isArray(obj)
Takes an Object and determines whether it is an Array or not.
Parameters:
{Object} obj
The Object in question
Returns:
{Boolean} true if the object is an Array, else false.

<static> {String} finesse.utilities.Utilities.padWithWidth(num, padWidth)
Pad with zeros based on a padWidth.
Parameters:
num
padWidth
Returns:
{String} with padded zeros (based on padWidth)

<static> {Date} finesse.utilities.Utilities.parseDateStringISO8601(s)
Parse string (which is formated as ISO8601 date) into Javascript Date object.
Parameters:
s
ISO8601 string
Returns:
{Date} Note: Some browsers don't support Date constructor which take ISO8601 date (e.g. IE 8).

<static> {String} finesse.utilities.Utilities.removeSpaces(string)
Takes a string and removes any spaces within the string.
Parameters:
{String} string
The string to remove spaces from
Returns:
{String} The string without spaces

<static> {String} finesse.utilities.Utilities.trim(str)
Trims leading and trailing whitespace from a string.
Parameters:
{String} str
The string to trim
Returns:
{String} The trimmed string

<static> {Function} finesse.utilities.Utilities.validateHandler(handler)
Returns the passed in handler, if it is a function.
Parameters:
{Function} handler
The handler to validate
Throws:
Error If the handler provided is invalid
Returns:
{Function} The provided handler if it is valid

<static> {Object} finesse.utilities.Utilities.whenAllDone()
Use JQuery's implementation of Promises (Deferred) to execute code when multiple async processes have finished. An example use: var asyncProcess1 = $.Deferred(), asyncProcess2 = $.Deferred(); finesse.utilities.Utilities.whenAllDone(asyncProcess1, asyncProcess2) // WHEN both asyncProcess1 and asyncProcess2 are resolved or rejected ... .then( // First function passed to then() is called when all async processes are complete, regardless of errors function () { console.log("all processes completed"); }, // Second function passed to then() is called if any async processed threw an exception function (failures) { // Array of failure messages console.log("Number of failed async processes: " + failures.length); }); Found at: http://stackoverflow.com/a/15094263/1244030 Pass in any number of $.Deferred instances.
Returns:
{Object}

Documentation generated by JsDoc Toolkit 2.3.2 on Mon Nov 06 2017 08:00:56 GMT-0500 (EST)