The PowerOn Module is used to register to receive an event when the device is resumed from suspend mode.
powerOn (Module) <META> Syntax |
---|
<META HTTP-Equiv="PowerOn" content="PowerOnEvent:url('[jsFunction | url]')"> |
PowerOn JavaScript Object Syntax: |
---|
By default the JavaScript Object 'powerOn' will exist on the current page and can be used to interact directly with the powerOn. |
To Set powerOn return events via JavaScript use the following syntax: poweron.event = Javascript Function; e.g. powerOn.powerOnEvent = '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: poweron.setEMML("[Your EMML Tags]"); e.g. powerOn.setEMML("powerOnEvent:url('JavaScript:doFunction(%json)')"); |
PowerOn Ruby Object Syntax: |
---|
By default the Ruby Object 'PowerOn' will exist on the current page and can be used to interact directly with the PowerOn. All Methods, Parameters and Events are the same as Javascript, however, notice 'PowerOn' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()' |
To Set PowerOn return events via Ruby use the following syntax: PowerOn.event = url_for(:action => :event_callback)
e.g. PowerOn.powerOnEvent = url_for(:action => :poweron_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", ...} |
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 PowerOnEvent is sent whenever the device is resumed from suspend mode. There is no data associated with this event.
This feature is very useful for security. Navigating to an offline page (file:// protocol) when the device is powered on can be used to request a pin number from the user.
Windows Power events will not always be generated when the device is connected to power and instructed to stand by / wake up, though this is dependant on the Operating System in use.
RhoElements Version | 1.0.0 or above |
---|---|
Supported Devices | All supported devices. |
Minimum Requirements | None |
Persistence | Transient - any changes made by changing parameters will be lost when navigating to a new page. |
The following example displays a message box when the device resumes:
<meta http-equiv="PowerOn" content="PowerOnEvent:url('javascript:alert('Powered Up');')">
The following example displays a custom text as a JavaScript alert when the device resumes from a suspended state:
def setPowerOnText $text = @params['text'] PowerOn.powerOnEvent = url_for(:action => powerOnEventListener) end
Here, ‘powerOnEventListner’ is the following function:
def powerOnEventListener Alert.show_popup $text end
The ‘setPowerOnText’ function takes an input from the user for a custom text to be displayed when the device powers on. This function is called from JavaScript as described below:
function setText() { text = document.getElementById('textToDisplay').value $.get('/app/PowerModule/setPowerOnText', {text: text}); return false; }