Skip to end of metadata
Go to start of metadata

pui.Timer simplifies running JavaScript repeatedly on a timer.  It is a more robust alternative to JavaScript’s native functions like setTimeout(), clearTimeout(), setInterval(), and clearInterval().

Usage

To use pui.Timer, you must first instantiate it using the new keyword. For example:

Then, you can set the timer’s properties and use its methods: For example:

pui.Timer is available for use in Genie and Rich Display File applications.  You can also use it in other environments, such as custom HTML pages or within Atrium, by including the Timer.js script file located in /www/[Instance Name]/htdocs/profoundui/proddata/js.

Properties

  • timeout - timeout value in seconds
  • showDebugInfo - when set to true, shows the elapsed time in the browser's title bar
  • action - action to take when the timeout occurs, specified as a JavaScript function
  • checkFrequency - how often to check whether the timeout occurred, specified in milliseconds; default value is 1000
  • resetOnUserActivity - when set to true, resets timer if user moves the mouse or uses the keyboard

Methods

  • start() - starts the timer
  • stop() - stops the timer
  • reset() - resets the timer

Example:

Profound UI has some built-in user/session inactivity timeout features. However, these can be overridden with a custom implementation by setting the pui["client side timeout"] flag to false and creating your own timers.

To be complete, the custom implementation should have something that keeps the server alive by "pinging" it once in a while. This is because the user could be active (moving mouse around or typing) on the screen, but in the meanwhile the server side could time out.

The following example implements custom timeout and keepalive timers for Profound UI applications.

The code looks for a hidden button on your screens with an id of "timeout". This can be bound to a response indicator to let the RPG program know that the screen has timed out. This element should also have the timeout value specified in seconds in the "user defined data" property. When there is no activity, the hidden button is "pressed" by the code. 

To implement this, you can put the code into an external JavaScript file. It could go into your /www/[Instance Name]/htdocs/profoundui/userdata/custom/js directory, for example. Then, on the screen’s onload event, use timeoutMonitor.start(). And on the screen’s onsubmit event, use timeoutMonitor.end().

Labels
  • No labels