Class: Utility

Utility

Contains common util functions used across different classes.

new Utility()

Methods

formatDate(date, format) → {String}

Returns a date string in the format set by user in preferences or as specified. Supported date formats are:
  • DATE_FORMAT_SHORT
  • DATE_FORMAT_MEDIUM
  • DATE_FORMAT_LONG
  • DATE_FORMAT_FULL
Parameters:
Name Type Argument Description
date Date Date object to be formatted
format String <optional>
Date format
Returns:
Date string in the format set by user in preferences or as specified.
Type
String

formatStringForHtml(data) → {String}

Formats input data string to be dispayed in HTML UI. Strings containing '<' and '>' characters needs to be processed using this method for displaying in HTML UI.
Parameters:
Name Type Description
data String String to be formatted
Returns:
Formatted string to display in HTML UI.
Type
String

formatTime(date, format) → {String}

Returns time string in the format set by user in preferences or as specified. Time formats are:
  • TIME_FORMAT_SHORT
  • TIME_FORMAT_MEDIUM
  • TIME_FORMAT_LONG
Parameters:
Name Type Argument Description
date Date Date object to be formatted
format String <optional>
Time format
Returns:
Time string in the format set by user in preferences or as specified.
Type
String

getProcessStatus(status) → {String}

Returns a process status string corresponding to the process status integer.
Parameters:
Name Type Description
status Number Process status to be formatted
Returns:
Process status string corresponding to the process status integer.
Type
String

getTaskPriority(priority) → {String}

Returns a task priority string corresponding to the task priority integer.
Parameters:
Name Type Description
priority Number Task priority to be formatted
Returns:
Task priority string corresponding to the task priority integer.
Type
String

getTaskStatus(status) → {String}

Returns a task status string corresponding to the task status integer.
Parameters:
Name Type Description
status Number Task status to be formatted
Returns:
Task status string corresponding to the task status integer.
Type
String

hideBusyState(view)

Hides awaiting screen.
Parameters:
Name Type Argument Description
view Object <optional>
Backbone view object calling this method

hideTaskForm(view) → {Boolean}

Hides task form when a popup needs to be shown above a form.
Parameters:
Name Type Argument Description
view Object <optional>
Backbone view object calling this method
Returns:
true, if form is hidden; false Otherwise.
Type
Boolean

isInternetExplorer() → {boolean}

Checks if the browser is Internet Explorer.
Returns:
true, if the browser is Internet Explorer; false otherwise.
Type
boolean

isSafariOnMac() → {boolean}

Checks if the browser is Safari on Mac.
Returns:
true, if the browser is Safari on Mac; false otherwise.
Type
boolean

searchCollection(collection, criteria) → {Object}

Searches collection of models and returns a collection of models fulfilling the criteria. The criteria is a boolean expression given in the form of OR (|) of ANDs (&) or of the form (criteria)&(criteria) to support an AND of two OR expressions in parentheses. Each criterion is a concatenation of attributes, operator, and value, and holds true if the attribute of the model evaluates to true for a given value. Supported operators are == for exact match, ~= for substring match, !=, <=, >=, <, and >.
Parameters:
Name Type Description
collection Object Backbone collection to be searched
criteria String Boolean expression to seach the collection
Returns:
Collection of models fulfilling the criteria.
Type
Object

showBusySate(view)

Grays out HTML Workspace and displays the awaiting screen.
Parameters:
Name Type Argument Description
view Object <optional>
Backbone view object calling this method

showTaskForm(openedPreviously, view) → {Boolean}

Displays task form if the form is hidden to show any popup.
Parameters:
Name Type Argument Description
openedPreviously boolean true, if the form was open before displaying the popup; false otherwise
view Object <optional>
Backbone view object calling this method
Returns:
true, if the form is displayed; false Otherwise.
Type
Boolean

subTemplate(classTag, template) → {String}

Extracts part of HTML template based on the class tag.
Parameters:
Name Type Description
classTag String Class tag indentifier
template String HTML template
Returns:
Part of the template starting and ending with the specified class tag.
Type
String

xmlToJson(xml) → {Object}

Converts XML to JSON.
Parameters:
Name Type Description
xml String Valid XML string to be converted into a JSON Object
Returns:
JSON object corresponding to XML.
Type
Object