Module: siteKiosk.activityTracker

This module offers functions related to the idle state of SiteKiosk. With this module information about the idle state can be obtained and the idle state can be prevented or forced.
It also provides information about the source of activities and allows registering listeners to activity related events such as user activity.

Example

// set the idle timeout to 10 minutes
siteKiosk.activityTracker.setIdleTimeout(60 * 10);

// When the user is idle, provide some meaningful hint about it.
siteKiosk.onUserIdle(function() {
    console.log("Hey, wake up!");
});

Methods

<static> acquireLock() → {siteKiosk.activityTracker~lock}

Acquires a lock, which will prevent the idle state.
Returns:
A lock, which will prevent the idle state
Type
siteKiosk.activityTracker~lock

<static> getActivitySources() → {Array}

Gets an array of all available activity sources.
Returns:
An array of all available activity sources
Type
Array

<static> getEnabledActivitySources() → {Array}

Gets the enabled activity sources, used to detect activity.
Returns:
An array of currently enabled activity sources
Type
Array

<static> handleUserActivity()

Reports user activity which resets the idle timeout.

<static> handleUserIdle()

Reports user inactivity, which will force idle status until the next user activity event occurs.

<static> isUserActive() → {boolean}

Returns whether the user is considered to be active or not.
Returns:
true if the user is active or false he is idle
Type
boolean

<static> onUserActive(callback) → {eventSubscription}

Registers a callback which will be raised when the user is considered to be active. This will be the case when an user activity event happens after the user was idle.
Parameters:
Name Type Description
callback Callback which will be invoked when the user is active
Returns:
Type
eventSubscription

<static> onUserActivity(activitySource, callback) → {eventSubscription}

Registers a callback which will be invoked when the specified activity source detects user activity
Parameters:
Name Type Description
activitySource The activity source to watch
callback Callback which will be invoked when user activity occurs
Returns:
Type
eventSubscription

<static> onUserIdle(callback) → {eventSubscription}

Registers a callback which will be raised when the user is considered to be idle. This will be the case either because the inactivity exceeds the idle timeout or forced by a user inactivity event.
Parameters:
Name Type Description
callback Callback which will be invoked when the user is idle
Returns:
Type
eventSubscription

<static> releaseLock(lock)

Releases a lock, which will no longer prevent the idle state.
Parameters:
Name Type Description
lock siteKiosk.activityTracker~lock A lock, which should not prevent the idle state anymore

<static> reset()

Resets the inactivity timer and reverts the activity tracker to an indeterminate state where the user activity is unknown and any new information on this subject will trigger the corresponding event.

<static> setEnabledActivitySources(sources)

Sets the enabled activity sources, which will being used to detect activity.
Parameters:
Name Type Description
sources Array An array of activity sources, which should being enabled

<static> setIdleTimeout(idleTimeout)

Sets the idle timeout.
Parameters:
Name Type Description
idleTimeout number The amount of inactivity in seconds required to consider the user as inactive

Type Definitions

eventSubscription

Type:
  • Object
Properties:
Name Type Description
unbind function Unsubscribes the event

lock

A lock, which will prevent the idle state.
Type:
  • Object
Properties:
Name Type Description
id number The locks ID
release function Releases the lock