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:
var mytimer = new pui.Timer();
Then, you can set the timer’s properties and use its methods: For example:
mytimer.timeout = 600; mytimer.action = function() { alert("Hello") }; mytimer.start();
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: