Developer Tips & Tricks - Inactivity Timeouts in Multi-Page Presentations

February 08, 2012

If you have ever built a multi-page Presentation for a touchscreen using our free digital signage software, you might have wondered if there was a way to return to the home page after a predetermined period of inactivity. You'll be happy to know that there is, and that we've done this in templates such as the Tradeshow Presentation.

To implement this, we leverage the jQuery idleTimer plugin. The plugin works by starting a timer; if the timer expires without someone interacting with the Presentation, a custom event is fired. All you need to do is handle this event by navigating to the home page.

Get started with Rise Vision

The plugin is available for download on GitHub. After including it in your Presentation, you start the timer with this line of code:

$.idleTimer(60000);

The parameter that is passed to this function is the timeout value in milliseconds. In this case the timer will expire after 60000 milliseconds (60 seconds).

You also need to add code to handle the idle.idleTimer event that the plugin fires when the timer expires:

$(document).bind("idle.idleTimer", function() {
//Show the home page.
});

It's a good idea to destroy the timer before starting a new one. You can do that like this:

$.idleTimer('destroy');

To see the code that we used in the Tradeshow Presentation, click here and then select Copy Template from the Preview bar.