Namespace: OrionSystem

OrionSystem

Various system wide functions.

Source:

Methods

<static> copyToClipboard(data)

Copies data to the system clipboard.

Parameters:
Name Type Description
data String

Text to copy to clipboard.

Source:
Example
OrionSystem.copyToClipboard('This text will be put on the clipboard');

<static> createLogBundle(objectName, callbackName)

Zips up the current star2star logs, and returns the path on disk to the zip file via a callback.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
Fires:
Example
OrionSystem.createLogBundle('', 'bundleCallback');

function bundleCallback(path)
{
   // path is the fully qualified path on disk to the zip bundle
}

<static> doesCameraExist(objectName, callbackName)

Detects the presence of a webcam.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
  • OrionFramework.doesMicrophoneExist
Fires:
Example
OrionSystem.doesCameraExist('', 'cameraCallback');

function cameraCallback(result)
{
   if (result)
   {
       // camera exists
   }
}

<static> doesMicrophoneExist(objectName, callbackName)

Detects the presence of a microphone.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
  • OrionFramework.doesCameraExist
Fires:
Example
OrionSystem.doesMicrophoneExist('', 'microphoneCallback');

function microphoneCallback(result)
{
   if (result)
   {
       // microphone exists
   }
}

<static> executeMailTo(mailTo)

Executes the mailTo string on the shell to open the default mail program. This needs to be a full mailto string, including the 'mailto:' prefix.

Parameters:
Name Type Description
mailTo String

Recipient for a new mail message opened in the System's default client.

Source:
Example
OrionSystem.executeMailTo('mailto:dgooden@star2star.com');

<static> generateUniqueKey(identifier, objectName, callbackName)

Generates a unique id (UUID/GUID). Returns identifier in the callback so you can keep track of which unique id is for what.

Parameters:
Name Type Argument Default Description
identifier String

For tracking which key was generated by which call to this method.

objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
Fires:
Example
OrionSystem.generateUniqueKey('test', '', 'keyCallback');

function keyCallback(event)
{
   if (event.eventName == 'generateUniqueKey')
   {
       var identifier = event.identifier,
           key        = event.key;
   }
}

<static> getClipboardData(objectName, callbackName)

Copies (string only) data from the system clipboard and returns it to the specified callback.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
Fires:
Example
OrionSystem.getClipboardData('', 'clipboardData');

function clipboardData(text)
{
   // text is the data from the clipboard
}

<static> getFlashVersion(objectName, callbackName)

Retrieves the Flash version installed on the system.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
Fires:
Example
OrionSystem.getFlashVersion('', 'flashVersionCallback');

function flashVersionCallback(flashVersion)
{
   OrionSystem.logToConsole('installed flash version : ' + flashVersion);
}

<static> getLocalFileURL(path, objectName, callbackName)

Returns a file:/// URL for a local file path.

Parameters:
Name Type Argument Default Description
path String

Unqualified local path.

objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
Fires:
Example
OrionSystem.getLocalFileURL('/Users/dgooden/test pdf file.pdf', '', 'fileCallback');

function fileCallback(url)
{
   // url is the local file path converted to "file:///Users/dgooden/test%20pdf%20file%20.pdf"
}

<static> getSystemIdleTime(objectName, callbackName)

Returns the current system idle time in seconds to the callback you specify. The idle time is the amount of time that has passed without any keyboard or mouse activity.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
Fires:
Example
OrionSystem.getSystemIdleTime('', 'systemIdleTimeCallback');

function systemIdleTimeCallback(seconds)
{
   OrionSystem.logToConsole('seconds idle : ' + seconds);
}

<static> launchExternalProgram(path, args, takeFocus)

The framework will can an external program at path, passing in args. If takeFocus is set to false, the program will not come to the top. (On windows, this is merely a suggestion, a program needs to specifically handle this to work). Each element of the array is one of the arguments. If your argument needs to contain a space, it must be enclosed in double quotes.

Parameters:
Name Type Description
path String

Location of program to launch.

args Array

Parameters to pass to program.

takeFocus Boolean

Whether the newly opened program should take focus from the Framework.

Source:
Example
var args = [];

args[0] = '-foo';
args[1] = '--bar';
args[2] = 'spam';

// launches program with arguments: -foo --bar spam

var args = [];

args[0] = '"this is a single argument with spaces"';

// launches program with argument: "this is a single argument with spaces"

var args = [];

args[0] = '-v';
args[1] = '/tmp/test.txt';

OrionSystem.launchExternalProgram('/Users/dgooden/testProgram', args, false);

<static> logToConsole(logLevel, message)

Logs message to the star2star.log file. Javascript console errors are automatically written there as well. The log message will be tagged with the logLevel passed in.

Parameters:
Name Type Description
logLevel Number

Significance of message. 0 = debug, 1 = info, 2 = warning, 3 = error.

message String

Information to record in log file.

Source:
See:
Example
var num = 3;

OrionSystem.logToConsole(1, 'This message brought to you by the number ' + num);

<static> openExternalURL(url)

Opens the specified location using the System's default browser.

Parameters:
Name Type Description
url String

Location to open externally.

Source:
Example
OrionSystem.openExternalURL('http://www.star2star.com');

<static> saveBinaryDataToFile(path, data)

Creates/overwrites a binary file located at path with the contents of data. You must base64 encode the binary data before sending it to the Framework. The Framework will decode the data and save the result as a binary file.

Parameters:
Name Type Description
path String

Location to create file.

data String

Base64 encoded data to write to file.

Source:
See:
Example
var base64EncodedData = getDataFromSomewhere();

OrionSystem.saveBinaryDataToFile('/tmp/test.bin', base64EncodedData);

<static> saveTextDataToFile(path, data)

Creates/overwrites a text file located at path with the contents of data.

Parameters:
Name Type Description
path String

Location to create file.

data String

Characters to write to file.

Source:
See:
Example
OrionSystem.saveTextDataToFile('/tmp/test.txt', 'This is some text data to save');

<static> setSleepCallback(objectName, callbackName)

Sets a callback for the framework to call when the system goes to sleep. You can only have 1 sleep callback active per starlet. If you call this function a second time the new callback will be used.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionSystem.setSleepCallback('', 'sleepCallback');

function sleepCallback(event)
{
   if (event.eventName == 'systemSleep')
   {
       OrionSystem.logToConsole('System is going to sleep!');
   }
}

<static> setWakeCallback(objectName, callbackName)

Sets a callback for the framework to call when the system wakes from sleep. You can only have 1 wake callback active per starlet. If you call this function a second time the new callback will be used.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionSystem.setWakeCallback('', 'wakeCallback');

function wakeCallback(event)
{
   if (event.eventName == 'systemWake')
   {
       OrionSystem.logToConsole('System is waling from sleep!');
   }
}

<static> showDevTools()

Opens a dev tools window for the Starlet in which the method is called.

Source:

<static> showDirectoryDialog(objectName, callbackName, starletName)

Shows the native directory dialog and sends chosen path to the callback specified. The path returned will be empty if there is an error, or if the user cancels the dialog. Passing something for starletName will open it in that starlet's window, passing blank will use the current starlet window.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

starletName String <optional>
<frontmost>

Starlet to associate dialog with.

Source:
See:
Fires:
Example
OrionSystem.showDirectoryDialog('', 'directoryCallback', '');

function directoryCallback(path)
{
   path
       ? OrionSystem.logToConsole('User chose directory : ' + path)
       : OrionSystem.logToConsole('Error or user cancel');
   }
}

<static> showOpenFileDialog(objectName, callbackName, starletName)

Shows the native open file dialog, and will call your callback with the path the user chooses. The return path will be empty if there is an error, or if the user cancels the dialog. Passing something for starletName will open it in that starlet's window, passing blank will use the current starlet window.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

starletName String <optional>
<frontmost>

Starlet to associate dialog with.

Source:
Fires:
Example
OrionSystem.showOpenFileDialog('', 'openFileCallback', '');

function openFileCallback(path)
{
   path
       ? OrionSystem.logToConsole('User chose file : ' + path)
       : OrionSystem.logToConsole('Error or user cancel');
}

<static> showPDF(path)

Opens the PDF located at path using the default system PDF reader. If one is not installed, this will do nothing.

Parameters:
Name Type Description
path String

Location of PDF to open externally.

Source:
Example
OrionSystem.showPDF('/Users/dgooden/foo.pdf');

<static> showSaveFileDialog(objectName, callbackName, starletName, defaultFilename, defaultFileExtension)

Shows the native save file dialog and will send the user's chosen path to the callback specified. The path returned will be empty if there is an error, or if the user cancels the dialog. Passing something for starletName will open it in that starlet's window, passing blank will use the current starlet window. Defaults are not enforced, the user may still choose any path or extension.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

starletName String <optional>
<frontmost>

Starlet to associate dialog with.

defaultFilename String

Suggested filename to show in dialog, including extension.

defaultFileExtension String

Suggested filetype to show in dialog, excluding dot.

Source:
See:
Fires:
Example
OrionSystem.showSaveFileDialog('', 'saveFileCallback', '', 'test.txt', 'txt');

function saveFileCallback(path)
{
   path
       ? OrionSystem.logToConsole('User wants to save file at : ' + path)
       : OrionSystem.logToConsole('Error or user cancel');
   }
}

<static> unsetSleepCallback()

Clears the callback set for sleep notifications.

Source:
See:

<static> unsetWakeCallback()

Clears the callback set for wake notifications.

Source:
See: