SC.util.js
SC.util.formatString(format, args)
Converts objects to their string representations and inserts these strings into the string to be formatted at the specified locations.
Parameters
| Name | Type | Description |
| format | String | The string to be formatted |
| args | variable length object arguments | A group of object arguments to be converted into their string representations and inserted into the string to be formatted |
Return type
String
Example
SC.util.formatString(
'The {0} jumped through the {1}',
'jungle cat',
'sun'
);
SC.util.getCookieValue(name)
Looks up and returns a cookie value by name
Parameters
| Name | Type | Description |
| name | String | The name of the cookie whose value is to be returned |
Return type
String
Example
var stringValue = SC.util.getCookieValue('settings');
SC.util.setCookieValue(name, value, days)
Sets a particular cookie's value and expiration
Parameters
| Name | Type | Description |
| name | String | The name of the cookie whose value is to be set |
| value | String | value to assign to the specified cookie |
| days | number | Number of days that must elapse before the cookie expires |
Return type
void
Example
SC.util.setCookieValue('settings', stringValue, 3650);
SC.util.loadSettings()
Tries to get an object representation of the site's settings cookie value
Parameters
| Name | Type | Description |
| None |
Return type
object
Example
var settings = SC.util.loadSettings();
SC.util.saveSettings(settings)
Updates the value of the settings cookie and sets it to expire in 3650 days
Parameters
| Name | Type | Description |
| settings | object | Object to be stringified and saved as the value for the settings cookie |
Return type
void
Example
var settings = SC.util.loadSettings(); settings.joinPath = eventArgs.commandArgument; SC.util.saveSettings(settings);
SC.util.parseQueryString(queryString)
Converts a query string into its object representation
Parameters
| Name | Type | Description |
| queryString | String | the query string to be parsed into an object |
Return type
Object
Example
newQueryStringMap[SC.context.loginReturnUrlParameterName] = SC.util.parseQueryString(window.location.search)[SC.context.loginReturnUrlParameterName] || window.location.href.substring(0, window.location.href.length - window.location.hash.length);
SC.util.getQueryString(map)
Converts an object into its query string representation
Parameters
| Name | Type | Description |
| map | object | The object to convert into a query string |
Return type
String
Example
var url = SC.context.guestUrl + SC.util.getQueryString({ Session: sessions[0].SessionID });
SC.util.launchUrl(url)
Attempt to launch the specified url in the current window
Parameters
| Name | Type | Description |
| url | String | The URL to attempt to launch in the current window |
Return type
void
Example
SC.util.launchUrl('mailto:' + (to == null ? '' : to) + SC.util.getQueryString({ subject: subject, body: body }));
SC.util.selectOrDefault(item, selector)
If selector is an instance of Function, then this function returns selector(item); if selector is an instance of String, then this function returns item[selector]; if neither is true, this function returns item
Parameters
| Name | Type | Description |
| item | varied | The item from which to select |
| selector |
function
string |
a function that selects and returns some property of the item a string key used to look up the corresponding value in item |
Return type
typeof item
Example
returns 'Machinist'
SC.util.selectOrDefault({ Name: 'Joe', Job: 'Machinist' }, function (employee) { return employee.Job })
returns 'Joe'
var testEmployee = { Name: 'Joe', Job: 'Machinist' }
SC.util.selectOrDefault(testEmployee, new String('Name'))
SC.util.areArraysEqual(x, y)
Returns true if array x is equal to array y, and returns false otherwise
Parameters
| Name | Type | Description |
| x | array | An array of items to be compared with array parameter y |
| y | array | an array of items to be compared with array parameter x |
Return type
Boolean
Example
Returns true:
SC.util.areArraysEqual(['a'], ['a']);
SC.util.createArray()
If the first argument has type function, createArray populates a new array with values based on the functionality of the first argument, i.e. arguments[0](array). If the first argument has type number and the second argument has type function, createArray populates a new array with values in such a way that the item at index i is assigned value arguments[1](i). This function returns the array resulting from completing one of the aforementioned operations.
Parameters
| Name | Type | Description |
| arguments[0] | function or number | if function, this function is used to populate the array; if number, this number is the length of the resulting array |
| arguments[1] | function | a function used to generate the values of items in an array of length arguments[0] |
Return type
array
Example
var names = SC.util.createArray(sessions.length, function () { return value; });
SC.util.createRangeArray(start, count)
Create an array of numbers where the the first element has value start and the last element has value (start + count - 1)
Parameters
| Name | Type | Description |
| start | number | the number at which to begin assigning values in the array |
| count | number | the length of the array to be returned |
Return type
array
Example
rangeArray will have value [3, 4, 5, 6]
var rangeArray = SC.util.createRangeArray(3, 4);
SC.util.createEnum(names)
Create an object with key names and string values specified by the input array
Parameters
| Name | Type | Description |
| names | array of strings | an array of strings from which to create an enum object |
Return type
object
Example
var bigCats = SC.util.createEnum([
'Tiger',
'Panther',
'Lion'
]);
SC.util.getTrimmedOrNull(text)
Trim a string input and return the trimmed string or null if the trimmed string is empty
Parameters
| Name | Type | Description |
| text | String | the string to trim, which can be null or undefined |
Return type
string or null
Example
var sessionCode = SC.util.getTrimmedOrNull(SC.event.getElement(eventArgs).value);
SC.util.isVersion(minVersionInclusive, maxVersionExclusive, actualVersion)
Returns true if the actualVersion is greater than or equal to minVersionInclusive and less than maxVersionExclusive; returns false if the actual version is less than minVersionInclusive or greater than or equal to maxVersionInclusive, or if actualVersion.major equals 0.
Parameters
| Name | Type | Description |
| minVersionInclusive | object | An object of the form { major: majorVersion, minor: minorVersion } to compare with the actualVersion parameter |
| maxVersionInclusive | object | an object of the form { major: majorVersion, minor: minorVersion } to compare with the actualVersion parameter |
| actualVersion | object | an object of the form { major: majorVersion, minor: minorVersion }, to compare with the minVersionInclusive and maxVersionInclusive parameters |
Return type
boolean
Example
var supported = SC.util.isVersion({ major: 8, minor: 0 }, { major: 11, minor: 1 }, { major: 10, minor: 3 });
SC.util.getVersionString(version)
Formats a version string from a version object of the form { major: majorVersionNumber, minor: minorVersionNumber }, e.g. 10.1
Parameters
| Name | Type | Description |
| version | object | an object of the form { major: majorVersionNumber, minor: minorVersionNumber } |
Return type
String
Example
// versionString will have value '10.1'
var versionString = SC.util.getVersionString({ major: 10, minor: 1 });
SC.util.Caps
This is an object containing the following function name keys: WindowsModern, WindowsDesktop, MacOSX, Android, iOS, iPad, InternetExplorer, Chrome, Firefox, Safari, WebKit, NativeClient, ClickOnce, WebStart. Each function returns an object describing the major and minor version of the corresponding capability (or zero/zero if the client does not support the capability).
For example, executing SC.util.Caps.WebKit() in the latest version of Chrome returns the following object:
{
major: 537,
minor: 36
}
Similarly, executing SC.util.Caps.InternetExplorer() in Chrome returns the following object:
{
major: 0,
minor: 0
}
Parameters
| Name | Type | Description |
| None |
Return type
Object
Example
Each of the functions described within the SC.util.Caps object returns a version object of the form { major: majorVersionNumber, minor: minorVersionNumber }; if the device is not capable, the returned version object equals { major: 0, minor: 0 }
SC.util.isCapable(capability, minVersionInclusive, maxVersionExclusive)
Returns true if the device supports the specified capability within the specified range of versions; returns false otherwise
Parameters
| Name | Type | Description |
| capability | function | a capability function that returns a version object of the form { major: majorVersionNumber, minor: minorVersionNumber }, where { major: 0, minor: 0 } indicates that the device is not capable |
| minVersionInclusive | object | an object of the form { major: majorVersion, minor: minorVersion } to compare with the version returned by the capability function parameter |
| maxVersionInclusive | object | an object of the form { major: majorVersion, minor: minorVersion } to compare with the version returned by the capability function parameter |
Return type
boolean
Example
returns true if the device is using IE 9.0+
SC.util.isCapable(SC.util.Caps.InternetExplorer, { major: 9 })
SC.util.getUserAgent()
Returns the user agent string in the current context, e.g. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
Parameters
| Name | Type | Description |
| None |
Return type
String
Example
Search for a particular pattern in a user agent string:
SC.util.getUserAgent().match(/\.NET/);
SC.util.getUserAgentVersion(pattern)
Try to get the user agent version by searching the user agent string for the specified pattern. Returns a version object, e.g. { major: 537, minor: 36 }
Parameters
| Name | Type | Description |
| pattern | regex | a regex pattern used to find version matches in the user agent string |
Return type
Object
Example
returns { major: 61, minor: 0 } on a newer version of Chrome
SC.util.getUserAgentVersion(/Chrome\/([0-9]+)\.([0-9]+)/);
SC.util.copyProperties(source, destination)
Copies the source object's key-value pairs to the destination object
Parameters
| Name | Type | Description |
| source | object | the object from which to copy keys and values |
| destination | object | the object that receives copies of key-value pairs from the source object |
Return type
void
Example
Copies the properties object's key-value pairs to SC.context:
SC.util.copyProperties(properties, SC.context);
SC.util.combineObjects()
Copies all key-value pairs from all objects into a new object and returns the new object
Parameters
| Name | Type | Description |
| arguments | variable number of objects | a variable number of objects; all key-value pairs from all objects will be copied to a new object |
Return type
Object
Example
returns {key1: "1", key2: "2", key3: "3"}
SC.util.combineObjects({ key1: '1' }, { key2: '2' }, { key3: '3' });
SC.util.mergeIntoContext(properties)
Copy the key-value pairs from the properties argument into the SC.context object
Parameters
| Name | Type | Description |
| properties | object | an object whose key-value pairs will be added to the SC.context object |
Return type
void
Example
adds { myInfo: 'info' } to the SC.context object
SC.util.mergeIntoContext({ myContextInfo: 'info' });
SC.util.openClientEmail(to, subject, body)
Opens the client's email application and creates an email message with the specified values for the to address, subject, and body
Parameters
| Name | Type | Description |
| to | String | "to" email address |
| subject | String | The email subject |
| body | String | The email body |
Return type
void
Example
SC.util.openClientEmail('example@connectwise.com', 'Good morning', 'Please call me ASAP');
SC.util.formatDomainMember
Returns a formatted string that includes the specified domain and member information, e.g. 'connectwise\jdoe'
Parameters
| Name | Type | Description |
| domain | String | the domain (can be null or empty) |
| member | String | the member (can be null or empty) |
Return type
String
Example
returns 'connectwise\jdoe'
SC.util.formatDomainMember('connectwise', 'jdoe');
SC.util.formatSecondsDuration(originalSeconds, additionalSeconds)
Returns a formatted string that describes a unit of time in terms of days, hours, and minutes, e.g. '3d 22h 28m'
Parameters
| Name | Type | Description |
| originalSeconds | number | the starting duration in seconds |
| additionalSeconds | number | seconds to add to the originalSeconds to get the total duration in seconds (optional) |
Return type
String
Example
returns '3d 22h 28m'
SC.util.formatSecondsDuration(120, 340000);
SC.util.formatDateTime(dateTime)
Returns a string represention of a Date object in the form MM-dd HH:mm:ss
Parameters
| Name | Type | Description |
| dateTime | Date | a Date object to format |
Return type
string
Example
returns, for example '10-10 15:21:20'
SC.util.formatDateTime(new Date());
SC.util.getMillisecondCount()
Returns the millisecond count of the current time, i.e., returns new Date().getTime();
Parameters
| Name | Type | Description |
| None |
Return type
number
Example
var currentMillisecondCount = SC.util.getMillisecondCount();
SC.util.addDateMilliseconds(millisecondsSinceEpoch, millisecondsToAdd)
Returns a new Date object created by passing (millisecondsSinceEpoch + millisecondsToAdd) to the date constructor
Parameters
| Name | Type | Description |
| millisecondsSinceEpoch | number | number to which to add millisecondsToAdd to initialize a new Date object |
| millisecondsToAdd | number | add this number to millisecondsSinceEpoch to initialize a new Date object |
Return type
Date
Example
Returns 50:
var newTime = SC.util.addDateMilliseconds(100, -50).getTime();
SC.util.addDateSeconds(millisecondsSinceEpoch, secondsToAdd)
Returns a new Date object created by passing (millisecondsSinceEpoch + 1000 * secondsToAdd) to the Date constructor
Parameters
| Name | Type | Description |
| millisecondsSinceEpoch | number | number to which to add (1000 * secondsToAdd) to initialize a new Date object |
| secondsToAdd | number | multiply this number of seconds by 1000 and add to millisecondsSinceEpoch to initialize a new Date object |
Return type
Date
Example
returns 50,000
var newTime = SC.util.addDateSeconds(10000, -50).getTime();
SC.util.addDateDays(millisecondsSinceEpoch, daysToAdd)
Returns a new Date object created by passing (millisecondsSinceEpoch + 86,400,000 * daysToAdd to the Date constructor
Parameters
| Name | Type | Description |
| millisecondsSinceEpoch | number | number to which to add (86,400,000 * daysToAdd) to initialize a new Date object |
| daysToAdd | number | multiply this number of days by 86,400,000 and add to millisecondsSinceEpoch to initialize a new Date object |
Return type
Date
Example
returns 0
var newTime = SC.util.addDateDays(86400000, -1).getTime();
SC.util.padToTwoDigits(number)
Prepends '0' to numbers less than 10 and returns a string representation of the provided number.
Parameters
| Name | Type | Description |
| number | number | a positive number to pad to two digits |
Return type
string
Example
returns '01'
var paddedNumber = SC.util.padToTwoDigits(1);
SC.util.getHashParameters()
Returns an array of decoded URI parameters that follow the URI hash: [session type, session group and subgroup names, session filter string, selected session id]
Parameters
| Name | Type | Description |
| None |
Return type
array of strings
Example
Suppose this is the current host page URI: https://example.screenconnect.com/Ho...a-24cc2968cde5
The variable parameterArray is assigned the following array value: ["Access", "All Machines elsitech", "carth", "288f4722-b069-4438-824a-24cc2968cde5"]
var parameterArray = SC.util.getHashParameters();
SC.util.getHashStringFromParameters(parameters)
Returns a hash string generated by URI encoding the given parameters and building a string of the form '#{param1}/{param2}/…/{paramN}'
Parameters
| Name | Type | Description |
| parameters | array of strings | an array of strings used to create the hash string |
Return type
string
Example
returns "#Access/Control"
SC.util.getHashStringFromParameters(["Access", "Control"])
SC.util.getWindowHashString()
Returns the current window's hash string
Parameters
| Name | Type | Description |
| None |
Return type
string
Example
Suppose this is the current host page URI: https://example.screenconnect.com/Ho...a-24cc2968cde5
The variable windowHashString is assigned the following value: '#Access/All%20Machines%1Felsitech/carth/288f4722-b069-4438-824a-24cc2968cde5'
var windowHashString = SC.util.getWindowHashString();
SC.util.getHashParameter(index)
Returns the hash parameter at the given index or undefined
Parameters
| Name | Type | Description |
| index | number | the index of the hash parameter value to return |
Return type
string
Example
Suppose this is the current host page URI: https://example.screenconnect.com/Ho...a-24cc2968cde5
The variable hashParameter is assigned the following value: "288f4722-b069-4438-824a-24cc2968cde5"
var hashParameter = SC.util.getHashParameter(3);
SC.util.setHashParameter(index, value)
Updates the hash parameter at the specified index with the specified value and returns true if the existing hash string is different than the new hash string
Parameters
| Name | Type | Description |
| index | number | the index of the hash parameter value to change |
| value | string | the new value to assign to the hash parameter at the specified index |
Return type
Boolean
Example
Suppose this is the current host page URI: https://example.screenconnect.com/Ho...a-24cc2968cde5
After calling the function below, the new host page URI will be: https://example.screenconnect.com/Ho...0-a9554ee63be5 and the function will return true
SC.util.setHashParameter(3, 'ed66bc64-a35d-4e81-a3b0-a9554ee63be5');
SC.util.base64Encode(input)
Returns the base 64 encoding of the given string input
Parameters
| Name | Type | Description |
| input | string | the string to base64 encode |
Return type
string
Example
The following returns "QUJDRDpBQkNE", the base 64 encoded representation of the string 'ABCD:ABCD'
SC.util.base64Encode('ABCD:ABCD');
SC.util.isNullOrEmpty(string)
Returns true if the parameter value is not a string or is the empty string.
Parameters
| Name | Type | Description |
| string | varied | an object (typically a string) to check whether null or empty |
Return type
boolean
Example
Returns true:
SC.util.isNullOrEmpty(new Date(12345));
SC.util.getEnumValueName(enumType, value)
Returns the key in the provided enumType that corresponds to the provided value
Parameters
| Name | Type | Description |
| enumType | object | the enum object from which to return a value name |
| value | object | the value to look up in the given enum object |
Return type
string
Example
returns 'Support'
SC.util.getEnumValueName(SC.types.SessionType, 0);
returns 'Access'
SC.util.getEnumValueName(SC.types.SessionType, 2);
SC.util.getRandomStringFromMask(mask)
Returns a random string of length mask.length composed of digits and letters. Random digits are substituted for mask character '#' and random letters are substituted for mask character 'A'
Parameters
| Name | Type | Description |
| mask | String | string composed of the characters '#' and 'A', used to generate a random string of digits and letters |
Return type
String
Example
Returns a string of length 8, composed of four random letters prepended to four random digits, e.g. HGTY6289
SC.util.getRandomStringFromMask('AAAA####');
SC.util.getRandomChar(minCharCode, maxCharCode)
Returns a random character within the range [minCharCode, maxCharCode]
Parameters
| Name | Type | Description |
| minCharCode | number | The smallest possible value returned by the function |
| maxCharCode | number | The largest possible value returned by the function |
Return type
string
Example
The following function call returns a single uppercase letter in the range A to Z.
SC.util.getRandomChar(65, 91);
SC.util.stringToBoolean(string)
Returns true if the lowercase version of the provided string equals 'true' and false otherwise
Parameters
| Name | Type | Description |
| string | string | The string to be converted into a boolean value |
Return type
boolean
Example
The following function call returns true:
SC.util.stringToBoolean('True');
SC.util.getCacheEntry(key, version)
Returns the specified version of the cache entry for the specified key. Returns null if cache entry not found.
Parameters
| Name | Type | Description |
| key | string | String used to look up a particular cache entry in window._cache |
| version | number | The version of the cache entry to return |
Return type
object
Example
Suppose window._cache has an entry for 4350119b-64d1-4ce9-942f-a3b9a24100bdSessionDetails with version 133346957.
The call to SC.util.getCacheEntry('4350119b-64d1-4ce9-942f-a3b9a24100bdSessionDetails', 133346957) will return an object of the following form:
{
firstUsedTime: [number],
item: [object] (e.g., information about session with session id 4350119b-64d1-4ce9-942f-a3b9a24100bd),
lastUsedTime: [number],
version: [number]
}
The version parameter in this case (133346957) comes from the LastAlteredVersion property of the session with session id 4350119b-64d1-4ce9-942f-a3b9a24100bd.
SC.util.setCacheItem(key, version, item)
Look up the cache entry with the given key. If the cache entry does not exist, create a new cache entry. Set the cache entry's version, firstUsedTime, and item properties, and return the new or updated cache entry.
Parameters
| Name | Type | Description |
| key | string | string used to look up a particular cache entry in the window._cache map |
| version | number | the updated version to assign to the cache entry |
| item | object | the value to assign to the cache entry's item property |
Return type
object
Example
This method is used on the host page to update the session details cache, e.g.:
SC.util.setCacheItem(detailSession.SessionID + 'SessionDetails', detailSession.LastAlteredVersion, sessionDetails);
SC.util.tryGet(getter)
Try to return getter(); if the call to getter fails, catch the exception and return null.
Parameters
| Name | Type | Description |
| getter | function | A function that attempts to return a value |
Return type
various (can return null)
Example
var result = SC.util.tryGet(function () { return JSON.parse(xhr.responseText); });
SC.util.getParameterlessUrl(url)
Returns a url stripped of all parameters
Parameters
| Name | Type | Description |
| url | string | A URL from which to remove parameters |
Return type
string
Example
The following function call returns 'https://example.screenconnect.com/Host'
SC.util.getParameterlessUrl('https://example.screenconnect.com/Host#Access/All%20Machines//4350119b-64d1-4ce9-942f-a3b9a24100bd');
SC.util.getBaseUrl(url)
Returns the base url of the specified url
Parameters
| Name | Type | Description |
| url | STring | A URL from which to extract the base URL |
Return type
string
Example
The following function call returns 'https://example.screenconnect.com':
SC.util.getBaseUrl('https://example.screenconnect.com/Host#Access/All%20Machines//4350119b-64d1-4ce9-942f-a3b9a24100bd');
SC.util.getClientLaunchParameters(sessionID, sessionType, sessionTitle, participantName, accessToken, processTypeOverride, attributes)
Returns an object produced by combining SC.context.clp, which contains information about the relay URI and the public encryption key, and the provided parameter values
Parameters
| Name | Type | Description |
| sessionID | string | session ID to include in the client launch parameters object |
| sessionType | number | numerical value associated with a particular session type (0 for Support, 1 for Meeting, and 2 for Access) |
| sessionTitle | string | the title of the session associated with the client launch |
| participantName | string | the participant's name associated with the client launch; null allowed |
| accessToken | string | access token string returned by call to SC.service.GetAccessToken; can be null for guest client launch |
| processTypeOverride | number | access token string returned by call to SC.service.GetAccessToken; can be null for guest client launch |
| attributes | number | the attributes to associate with this client launch (0 for None, 1 for SuspendedInput) |
Return type
object
Example
Example from Host page:
SC.util.getClientLaunchParameters(
sessions[0].SessionID,
sessions[0].SessionType,
sessions[0].Name,
null,
accessTokenString,
null,
(isAdvanced ? SC.types.ClientLaunchAttributes.SuspendedInput : SC.types.ClientLaunchAttributes.None)
);
SC.util.getInstallerQueryString(nameCallbackFormat, customPropertyValueCallbackFormats)
Returns the query string for an installer with the given nameCallbackFormat and custom property values
Parameters
| Name | Type | Description |
| nameCallbackFormat | string | The name the guest machine uses to call back to the server |
| customPropertyValueCallbackFormats | array of strings | each element of the array represents the value of custom property (index + 1) |
Return type
string
Example
The following function call returns something like:
"?h=example.screenconnect.com&p=443&k=BgIAAACkAABSU0ExAAgBAAEAAQCDK3w9eMCNYJz59EvxPRwYAw1oTSgHAcyGIzxkGqHXYDMWemLDGtIBA2QaSjl%2BdNFVC66nBM967exp7FqY3ZqVDdUDP26F%2FlaWMda3RWoH1jX18jPrtGT7LuUW6yr2lHeycXz%2Bz%2BhYo3Pn%2B5v0G5LohqnlaHBc6bql8U5NGoB%2Fzc%2Bmh6MNhp3b4qk3CBrPq30zL7CMLTFjI7x0GEnrHq0KadaPTaRbFs2pDbn%2BYI7RdAUOBdlnEjBY31%2BkrZdLqgzopwi%2FxzbfUTeIzOLOgMzttK6LG%2BrtAQdvEIj%2Bcs4RcBdqo8myiBX%2MYwUJWSw5%2BMqX%2BSxXxPqzTl1yW7xSNeie&e=Access&y=Guest&t=Server%20007&c=Critical&c=&c=&c=&c=&c=&c="
SC.util.getInstallerQueryString('Server 007', ['Critical','','','','','','','']);
SC.util.getSessionTypeResource(resourceNameFormat, sessionType, varargs)
Returns the string value of the resource specified by the resourceNameFormat and provided sessionType and optional variable length arguments
Parameters
| Name | Type | Description |
| resourceNameFormat | string | The web resource string format, e.g. 'SessionProperty.{1}.{0}Visible' |
| sessionType | number | numerical value associated with a particular session type (0 for Support, 1 for Meeting, and 2 for Access) |
| varargs | string(s) | other string arguments used to populate placeholders in the resourceNameFormat string |
Return type
string
Example
The resource variable will be assigned the value 'true' if the web resource entitled SessionProperty.Custom3.AccessVisible has value true.
var resource = SC.util.getSessionTypeResource('SessionProperty.{1}.{0}Visible', 2, 'Custom3');
SC.util.getSessionTypeBooleanResource(resourceNameFormat, sessionType, varargs)
Returns the boolean value of the resource specified by the resourceNameFormat and provided sessionType and optional variable length arguments
Parameters
| Name | Type | Description |
| resourceNameFormat | string | the web resource string format, e.g. 'SessionProperty.{1}.{0}Visible' |
| sessionType | number | numerical value associated with a particular session type (0 for Support, 1 for Meeting, and 2 for Access) |
| varargs | string(s) | other string arguments used to populate placeholders in the resourceNameFormat string |
Return type
boolean
Example
The boolResource variable will be assigned the value true if the web resource entitled SessionProperty.Custom3.AccessVisible has value true.
var boolResource = SC.util.getSessionTypeBooleanResource('SessionProperty.{1}.{0}Visible', 2, 'Custom3');
SC.util.getBooleanResource(resourceName)
Converts the value of the resource with the specified name to a boolean value
Parameters
| Name | Type | Description |
| resourceName | string | the name of the resource to get as a boolean value |
Return type
boolean
Example
Suppose the web resource entitled InvitationPanel.CalendarTabVisible has value true. The following function call returns the value true:
SC.util.getBooleanResource('InvitationPanel.CalendarTabVisible');
SC.util.generatePhoneticText(string)
Returns the phonetic representation of a given string, e.g. 'string' becomes "Sierra-Tango-Romeo-India-November-Golf"
Parameters
| Name | Type | Description |
| string | string | the string from which to create a phonetic representation |
Return type
string
Example
The following function call returns "Sierra-Tango-Romeo-India-November-Golf":
SC.util.generatePhoneticText('string');
SC.util.getVisibleCustomPropertyIndices(sessionType)
Returns an array of visible custom property indices for a particular session type, e.g. [0, 1, 7]
Parameters
| Name | Type | Description |
| sessionType | number | the session type for which to return visible custom property indices (0 for Support, 1 for Meeting, 2 for Access) |
Return type
array of numbers
Example
If custom properties 1 and 8 are visible on support sessions, the following function call will return [0, 7]:
SC.util.getVisibleCustomPropertyIndices(0);
SC.util.getInstallerUrl(installerType, nameCallbackFormat, customPropertyValueCallbackFormats)
Returns the url used to download an installer of the specified type with the given nameCallbackFormat and custom property values
Parameters
| Name | Type | Description |
| installerType | string | the type of installer to download; the following strings are valid: 'exe', 'msi', 'pkg', 'deb', 'rpm', 'sh' |
| nameCallbackFormat | string | the name the guest machine uses to call back to the server |
| customPropertyValueCallbackFormats | array of strings | each element of the array represents the value of custom property (index+1) |
Return type
string
Example
The following function call returns the url to download an msi installer, which looks something like:
"https://example.screenconnect.com/Bi...c=&c=&c=&c=&c="
SC.util.getInstallerUrl('msi', 'Server 007', ['Critical','','','','','','','']);
SC.util.getVisibleCustomPropertyNames(sessionType)
Returns an array of visible custom property names for a particular session type, e.g. ['Custom1', 'Custom8']
Parameters
| Name | Type | Description |
| sessionType | number | The session type for which to return visible custom property names (0 for Support, 1 for Meeting, 2 for Access) |
Return type
array of strings
Example
If custom properties 1 and 8 are visible on support sessions, the following function call will return ['Custom1', 'Custom8']:
SC.util.getVisibleCustomPropertyNames(0);
SC.util.forEachVisibleCustomProperty(sessionType, proc)
Apply a function to each visible custom property for a particular session type
Parameters
| Name | Type | Description |
| sessionType | number | The session type for which to apply a function to all visible custom properties (0 for Support, 1 for Meeting, 2 for Access) |
| proc | function(visibleCustomPropertyIndex, visibleCustomPropertyName) | a function to be applied to each visible custom property for the specified session type |
Return type
void
Example
The following function call prints the text (below) to the browser console if CustomProperty1 and CustomProperty8 are visible for support sessions:
SC.util.forEachVisibleCustomProperty(0, function (cpIdx, cpName) { console.log(cpIdx + ' ' + cpName); })
| 0 | Custom1 |
| 7 | Custom8 |
SC.util.getCustomPropertyName(customPropertyIndex)
Returns the name of the custom property associated with the provided index, e.g. 'Custom1'
Parameters
| Name | Type | Description |
| customPropertyIndex | number | The index of the custom property for which to return a name |
Return type
string
Example
The following function call returns 'Custom1':
SC.util.getCustomPropertyName(0);
SC.util.getCustomPropertyIndex(customPropertyName)
Returns the index of the custom property associated with the provided name
Parameters
| Name | Type | Description |
| customPropertyName | string | The name of the custom property for which to return its index |
Return type
number
Example
The following function call returns 0
SC.util.getCustomPropertyIndex('Custom1');
SC.util.includeStyleSheet(styleSheetUrl)
Add a style sheet reference to the head element of the document
Parameters
| Name | Type | Description |
| styleSheetUrl | string | path to the style sheet to include in the page |
Return type
void
Example
Add a link to the ExtensionStyleComponent.css stylesheet to the document's head element
SC.util.includeStyleSheet('ExtensionStyleComponent.css');
SC.util.includeScript(scriptUrl, checkLoadedFunc, runWhenLoadedProc)
Add a script reference to the head element of the document and optionally run a procedure when the script has been loaded
Parameters
| Name | Type | Description |
| scriptUrl | string | path to the script to include in the page |
| checkLoadedFunc | function | a function that returns true if and only if the script is loaded |
| runWhenLoadedProc | function | a function to be executed immediately after the script is loaded (you must pass a checkLoadedFunc to use runWhenLoadedProc) |
Return type
void
Example
SC.util.includeScript(
'google\\chartsloader.js',
function () {return window.google; },
function () { // do something with charts }
);
SC.util.sendToLogin(loginReason, shouldReturn)
Navigate to the Login page and optionally include a ReturnUrl parameter, which is used to auto-navigate the current user back to the last visited non-Login page
Parameters
| Name | Type | Description |
| loginReason | number | a number that represents the reason for the logout; see SC.types.LoginReason for an enumeration of valid values |
| shouldReturn | boolean | should the new window location include a ReturnUrl parameter |
Return type
void
Example
The following function call sends the current user to the Login page for the specified reason; the new window location includes the ReturnUrl parameter.
- New window location: https://example.screenconnect.com/Lo...b%3D7&Reason=5 .
SC.util.sendToLogin(SC.types.LoginReason.Logout, true);
SC.util.copyToClipboard(successProc, failureProc)
Attempt to execute the function document.execCommand('copy'); if the copy command succeeds, execute the given successProc; if the copy command fails, execute the given failureProc
Parameters
| Name | Type | Description |
| successProc | function | an optional function to execute if the document.execCommand('copy') function succeeds |
| failureProc | function | an optional function to execute if the document.execCommand('copy') function fails for any reason; this function takes a single errorMessage parameter |
Return type
void
Example
SC.util.copyToClipboard(function () {
console.log('Copy success!');
}, function (errorMessage) {
console.log(SC.util.formatString('Copy failed: {0}', errorMessage));
});
SC.util.copyToClipboard(successProc, failureProc)
Attempt to execute the function document.execCommand('copy'); if the copy command succeeds, execute the given successProc; if the copy command fails, execute the given failureProc
Parameters
| Name | Type | Description |
| successProc | function | An optional function to execute if the document.execCommand('copy') function succeeds |
| failureProc | function | an optional function to execute if the document.execCommand('copy') function fails for any reason; takes a single errorMessage parameter |
Return type
void
Example
SC.util.copyToClipboard(function () {
console.log('Copy success!');
}, function (errorMessage) {
console.log(SC.util.formatString('Copy failed: {0}', errorMessage));
});
SC.util.range(start, count)
Create an array of numbers where the the first element has value start and the last element has value (start + count - 1)
Parameters
| Name | Type | Description |
| start | number | the number at which to begin assigning values in the array |
| count | number | the length of the array to be returned |
Return type
array of numbers
Example
The following function call returns the array [3, 4, 5, 6]:
SC.util.range(3, 4);
SC.util.groupBy(array, groupByFunc)
Returns an object with keys equal to the partition generated by the groupByFunc and values equal to an array of objects that contain a value that matches the associated key
Parameters
| Name | Type | Description |
| array | array | an array of objects to be grouped according to the groupByFunc |
| groupByFunc | function | the function used to group the provided array |
Return type
object
Example
Suppose you're working with the following array: [{Name : 'name1', Foo: 'foo1'}, {Name : 'name2', Foo : 'foo2'}, {Name : 'name3', Foo : 'foo2'}].
The following call to SC.util.groupBy will generate a new object with keys foo1 and foo2. Key foo1 will have an array value containing a single object, {Name : 'name1', Foo: 'foo1'}. Key foo2 will have an array value containing the objects {Name : 'name2', Foo : 'foo2'} and {Name : 'name3', Foo : 'foo2'}:
SC.util.groupBy([{Name : 'name1', Foo : 'foo1'}, {Name : 'name2', Foo : 'foo2'}, {Name : 'name3', Foo : 'foo2'}], function (_) { return _.Foo } );
SC.util.difference(array1, array2)
Returns an array of elements that are in either array1 or array2, but not in both array1 and array 2
Parameters
| Name | Type | Description |
| array1 | array | the first array from which to calculate the array difference |
| array2 | array | the second array from which to calculate the array difference |
Return type
array
Example
The following function call returns the array [2, 3]:
SC.util.difference([1, 2], [1, 3]);
SC.util.removeElementFromArray(array, element)
Modifies the given array by removing the specified element
Parameters
| Name | Type | Description |
| array | array | an array from which to remove an element |
| element | varied | the element to remove from the given array |
Return type
array
Example
Suppose arrayToRemove originally has the value [1, 2, 3]. The array arrayToRemove will have the value [1, 3] after the following function call:
SC.util.removeElementFromArray(arrayToRemove, 2);
SC.util.handleToggleAll(toggleAllCheckbox, checkboxes)
Toggles checked/unchecked on all checkboxes when the toggleAllCheckbox is checked/unchecked
Parameters
| Name | Type | Description |
| toggleAllCheckbox | HTML element | an HTML element representing a "Select All"-type checkbox |
| checkboxes | array of HTML elements | An array of HTML elements representing the checkboxes to be checked/unchecked when the toggleAllCheckbox is checked/unchecked |
Return type
void
Example
This function is used on the database tab to check/uncheck event types:
SC.util.handleToggleAll(SC.popout.getPanel().querySelector('.SelectAll>input'), SC.popout.getPanel().querySelectorAll('.EventTypesInput'));
SC.util.handleToggle(toggleCheckbox, toggleAllCheckbox, otherCheckboxes)
Toggles checked/unchecked on toggleAllCheckbox element when a particular toggleCheckbox is checked/unchecked
Parameters
| Name | Type | Description |
| toggleCheckbox | HTML element | A checkbox element that is checked or unchecked by a user |
| toggleAllCheckbox | HTML element | a checkbox element that represents whether or not all of our checkboxes are checked/unchecked |
| otherCheckboxes | array of HTML elements | an array of HTML elements representing all of the other checkboxes that might affect the checked/unchecked state of the toggleAllCheckbox |
Return type
void
Example
This function is used on the database tab to handle the checked/unchecked state of the toggleAllCheckbox:
SC.util.handleToggle(element, SC.popout.getPanel().querySelector('.SelectAll>input'), SC.popout.getPanel().querySelectorAll('.EventTypesInput'));
SC.util.moveElement(array, oldIndex, newIndex)
Modifies the given array by moving the element at index oldIndex to the position specified by newIndex
Parameters
| Name | Type | Description |
| array | array | The array for which to move elements according to the specified oldIndex and newIndex |
| oldIndex | number | the index of the original array element to move to position newIndex |
| newIndex | number | the index to which the element specified by oldIndex is to be moved |
Return type
void
Example
The following function call updates the array variable's value to [3, 1, 2, 4]:
var array = [1,2,3,4]; SC.util.moveElement(array, 2, 0);
SC.util.isTouchEnabled()
Returns true if document.documentElement.ontouchstart is not null
Parameters
| Name | Type | Description |
| None |
Return type
boolean
Example
Used to determine if touch capability is enabled
SC.util.compareVersion(x, y)
Returns a number that can be used to compare two version number objects, e.g. 2.5.4677.3332 and 2.5.7000.3332.
Parameters
| Name | Type | Description |
| x |
object |
An object of the form { major: majorVersion, minor: minorVersion, build: buildVersion, revision: revisionVersion } to compare |
| y | object | another object of the form { major: majorVersion, minor: minorVersion, build: buildVersion, revision: revisionVersion } to compare |
Return type
number
Example
if (minVersionInclusive != null && SC.util.compareVersion(actualVersion, minVersionInclusive) < 0)
return false;
SC.util.combinePath(path1, path2)
Returns the result of joining path1 to path2 using the '/' character
Parameters
| Name | Type | Description |
| path1 | string | The first part of the combined path |
| path2 | string | The second part of the combined path |
Return type
string
Example
The following function call returns 'connectwise/control':
SC.util.combinePath('connectwise', 'control');
