Application Module

RhoElements 2.x API

Overview

The Application class is used for accessing or setting app-level configuration settings.

application (Module) <META> Syntax

<META HTTP-Equiv="Application" content="[method]">

Application JavaScript Object Syntax:
By default the JavaScript Object 'application' will exist on the current page and can be used to interact directly with the application.
To Invoke application methods via JavaScript use the following syntax: application.method();

e.g. application.quit();
To Set application return events via JavaScript use the following syntax: application.event = JavaScript Function;

e.g. application.applicationEvent = 'doFunction(%json)';

To set multiple EMML parameters / events on a single line use the following syntax: application.setEMML("[Your EMML Tags]");

e.g. application.setEMML("applicationEvent:url('JavaScript:doFunction(%json)');quit");

Methods

Items listed in this section indicate methods and/or parameters that will be retrieved.

Name Description Default Value
quit Quits RhoElements. Quitting the application while license screen is shown will be slightly delayed. N/A
minimize Minimizes RhoElements N/A
restore Restores RhoElements to full screen N/A
getVersion Returns the version of all installed components via a 'VersionEvent' N/A

Events

Values are returned to the caller in RhoElements via Events. Most modules contain events and those returned from this module are given below along with the event parameters. Events can cause a navigation to a new URL or a JavaScript function on the page to be invoked. Each event will in most cases have a number of parameters associated with it which will either be strings or JavaScript arrays. Event parameters can be accessed either directly or via JSON objects.

applicationEvent

The ApplicationEvent is triggered when a RhoElements application is minimized or restored.

ID Name Description
1 applicationState "Minimized" or "Restored"

versionEvent

The version of RhoElements installed on the device.

ID Name Description
1 productVersion A string defining the released version running on the device, this will be in the form v.w.x.y. E.g. 1.0.0.0.
2 hotFixes A JavaScript array of strings containing the hot fixes applied. There may have been multiple hot fixes applied, e.g. ['1','3'].
3 componentVersions (module, version) A 2 dimensional array of strings which defined a mapping between each of the installed plugins' name and their version. See remarks for more details.

Remarks

ComponentVersions Array Format

The ComponentVersions parameter in the VersionEvent is defined as a 2D array:

    
    (
    (                       //  Array for Component 1
    module,     //  The name of the module (string).
    version,    //  The version of the module (string) in the form v.w.x.y.z.
    )
    (                       //  Array for Component 2
    module,
    version,
    )
    )

Requirements

RhoElements Version 1.0.0 or above
Supported Devices All supported devices except: Enterprise Tablet - does not support "Restore" method.
Minimum Requirements None.
Persistence Immediate - These methods are actioned immediately.

HTML/JavaScript Examples

The following example causes RhoElements to exit when the page is loaded:

    
    <META HTTP-Equiv="Application" Content="Quit">

The following example minimizes RhoElements when the enter key is pressed and reports its state in a message box:

    
    <META HTTP-EQUIV="OnKey0x0d" content="javascript:doTest();">
    <META HTTP-EQUIV="Application" content="ApplicationEvent:url('JavaScript:receivedEvent('%s');')">

    <SCRIPT>
        function doTest(){
            application.minimize();
        }
        function doEvent(currentState){
            alert('RhoElements has been ' + currentState);
        }
    </SCRIPT>

The following example retrieves component version numbers:

    
    <META HTTP-EQUIV="Application" content="VersionEvent:url('javascript:fnVerJSON(%json);')">

    <SCRIPT>
        function fnVerJSON(jsonObject){
            var theOutput = "<B>Product Version:</b> " + jsonObject.productVersion + "<P>";
            theOutput = theOutput + "<b>Hot Fixes:</b><P>";

            for (var i=0; i<jsonObject.hotFixes.length; i = i + 1){
                theOutput = theOutput + "  Hot Fix: " + jsonObject.hotFixes[i] + "<BR>";
            }

            theOutput = theOutput + "<P>";
            theOutput = theOutput + "<b>Installed Components:</b><P>";

            for (var j=0; j<jsonObject.componentVersions.length; j = j + 1){
                theOutput = theOutput + "  Module: " + jsonObject.componentVersions[j].module + ', Version: ' + jsonObject.componentVersions[j].version + "<BR>";
            }
            outputDiv.innerHTML = theOutput;
        }
    </SCRIPT>
    <div id="outputDiv">Version Goes Here</div>
    <P>
        <INPUT align="center" type="button" value="Retrieve Version" onclick="application.getVersion()"><br>