Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

Alarm Module

The Alarm Module is used to set an alarm and register an action to perform when that alarm fires.

Syntax

alarm (Module) <META> Syntax

<META HTTP-Equiv="Alarm" content="[method / parameter]">

<META HTTP-Equiv="Alarm" content="AlarmTriggered:url('[jsFunction | url]')">

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

e.g. alarm.clear();
To Set alarm parameters via JavaScript use the following syntax: alarm.parameter = 'value'; remembering to enclose your value in quotes where appropriate.

e.g. alarm.interval = 'value';
To Set alarm return events via JavaScript use the following syntax: alarm.event = JavaScript Function;

e.g. alarm.alarmTriggered = 'doFunction(%json)';

For more details on the event syntax and parameters see the Retrieval Events page.
To set multiple EMML parameters / events on a single line use the following syntax: alarm.setEMML("[Your EMML Tags]");

e.g. alarm.setEMML("interval:value;alarmTriggered:url('JavaScript:doFunction(%json)');clear");
Alarm Ruby Object Syntax:
By default the Ruby Object 'Alarm' will exist on the current page and can be used to interact directly with the Alarm. All Methods, Parameters and Events are the same as JavaScript, however, notice 'Alarm' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()'
To Invoke Alarm methods via Ruby use the following syntax: Alarm.method()

e.g. Alarm.clear
To Set Alarm parameters via Ruby use the following syntax: Alarm.parameter = 'value' remembering to enclose your value in quotes where appropriate.

e.g. Alarm.interval = 'value'
To Set Alarm return events via Ruby use the following syntax: Alarm.event = url_for(:action => :event_callback)

e.g. Alarm.alarmTriggered = url_for(:action => :alarm_event_callback)

For more details on the event syntax and parameters see the Retrieval Events page.

To access the event parameters in a Ruby callback function, you reference the @params object within the callback function. This object is simply a ruby hash {"parameter1 name" => "parameter1 value", "parameter2 name" => "parameter2 value", ...}

Methods

Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.

Name Description Default Value
clear Clears the currently set alarm N/A
set Sets the alarm. The alarm will fire after the specified interval or at the specified time (see the parameters section). You can only have one active alarm at a time. N/A

Parameters

Items listed in this section indicate parameters, or attributes which can be set.

Name Possible Values Description Default Value
interval:[Value] Alarm Interval in the format HH-MM-SS Sets a time after which the Alarm will fire. The delay cannot be set to less that 30 seconds, if a value of less than 30 seconds is supplied, the delay will be defaulted to 30 seconds. N/A
repeat:[Value] 'true' or 'false' Provided the alarm has been set using the Interval parameter the alarm will be reset once fired. If the alarm is set using the 'Time' parameter then this value is ignored. False
time:[Value] Time in the format "YYYY-MM-DDtHH-MM-SStzd" (e.g. "2009-11-19t11-56-00+01-00"), See Remarks Sets the alarm to trigger at the specified time. 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.

alarmTriggered

The alarm triggered event will be fired when either the alarm time reaches that specified in the ‘Time’ parameter or the period specified in ‘Interval’ expires. There are no parameters associated with the AlarmTriggered event.

Remarks

Validity of registered action on Alarm Triggered

Uniquely for a RhoElements event the registered action for the AlarmTriggered event does not get cleared when you navigate away from the current page. If using a JavaScript function, you must ensure the script is still valid when the alarm fires or alternatively you can clear the alarm.

Minimum Time Interval

The Alarm is not designed to be triggered for intervals less than 30 seconds, if you require a shorter delay then consider using the JavaScript function ‘SetTimeout’.

Explanation of Time Format

You must specify the time in GMT and then the device’s timezone offset from that. E.g. a time expressed as 2012-07-27t08-30-00-05-00 breaks down as follows:

//  Assuming a device with timezone offset -5 hours
//  This alarm will fire at 8:30am (local time) on 27th July 2012

Year: 2012
Month: July
Day: 27th
Time: 13:30 exactly (GMT)
Timezone: -5 (Eastern Time, 8:30am local time)

Requirements

RhoElements Version 1.0.0 or above
Supported Devices All supported devices except kiosk devices.
Minimum Requirements None.
Persistence Persistent - Changes to this module will persist when navigating to a new page.

HTML/JavaScript Examples

The following example sets the alarm to display an alert box at a repeated interval of 1 hour:

<META HTTP-Equiv="Alarm-Set" Content="Interval:01-00-00; Repeat:True; AlarmTriggered:url('javascript:alert('Alarm Fired');')">

The following example sets the alarm to display an alert box at 8am GMT on 27th July 2012:

<META HTTP-Equiv="Alarm-Set" Content="Time:2012-07-27t08-00-00+00-00; AlarmTriggered:url('javascript:alert('London Olympics Start Today');')">
Back to Top