The Timer Module is used to set a timer and register an action to perform when that timer expires. Once the timer is started the interval time can not be changed without stopping the timer and restarting it.
timer (Module) <META> Syntax |
---|
<META HTTP-Equiv="Timer" content="[method / parameter]"> |
<META HTTP-Equiv="Timer" content="Timeout:url('[jsFunction | url]')"> |
Timer JavaScript Object Syntax: |
---|
By default the JavaScript Object 'timer' will exist on the current page and can be used to interact directly with the timer. |
To Invoke timer methods via JavaScript use the following syntax: timer.method(); e.g. timer.start(); |
To Set timer parameters via JavaScript use the following syntax: timer.parameter = 'value'; remembering to enclose your value in quotes where appropriate. e.g. timer.interval = 'value'; |
To Set timer return events via JavaScript use the following syntax: timer.event = JavaScript Function; e.g. timer.timeout = '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: timer.setEMML("[Your EMML Tags]"); e.g. timer.setEMML("interval:value;timeout:url('JavaScript:doFunction(%json)');start"); |
Timer Ruby Object Syntax: |
---|
By default the Ruby Object 'Timer' will exist on the current page and can be used to interact directly with the Timer. All Methods, Parameters and Events are the same as JavaScript, however, notice 'Timer' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()' |
To Invoke Timer methods via Ruby use the following syntax: Timer.method() e.g. Timer.start |
To Set Timer parameters via Ruby use the following syntax: Timer.parameter = 'value' remembering to enclose your value in quotes where appropriate. e.g. Timer.interval = 'value' |
To Set Timer return events via Ruby use the following syntax: Timer.event = url_for(:action => :event_callback)
e.g. Timer.timeout = url_for(:action => :timer_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", ...} |
Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.
Name | Description | Default Value |
---|---|---|
start | Starts the timer. The timer will expire after an interval as specified in the 'Interval' parameter | Not Started |
stop | Stops the timer if there is currently one running | Not Started |
Items listed in this section indicate parameters, or attributes which can be set.
Name | Possible Values | Description | Default Value |
---|---|---|---|
interval:[Value] | Values greater than or equal to 500 milliseconds | The duration the timer should run for, specified in milliseconds. This must be specified before the timer is started. | 1000 milliseconds (1 second) |
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.
The Timeout event is triggered when the timer expires and returns the current time.
ID | Name | Description |
---|---|---|
1 | time | The current time from the device clock. Format is DD/MM/YY HH:MM:SS |
RhoElements Version | 1.0.0 or above |
---|---|
Supported Devices | All supported devices. |
Minimum Requirements | None. |
Persistence | Partially Persistent - Changes to this module will persist when navigating to a new page with the exception of timeout event. |
The following example sets the timerinterval to 5 seconds:
<META HTTP-EQUIV="Timer" CONTENT="Interval:5000; Timeout:url('JavaScript:doTimer('%s');'); Start">
The following example shows a JavaScript alert at 10 second intervals:
<HTML> <HEAD> <META HTTP-EQUIV="Timer" CONTENT="Interval:10000; Timeout:url('JavaScript:doTimer('%s');'); Start"> </HEAD> <SCRIPT LANGUAGE="javascript"> function doTimer(time) { divTimer.innerHTML = 'Time: ' + time; } </SCRIPT> <BODY><DIV ID="divTimer"></DIV></BODY> </HTML>