@linkorb/idle

0.1.1 • Public • Published

idle.js

A simple javascript library to detect browser idle and perform actions.

Installation

npm install @linkorb/idle

Demo

Check the demo/ directory for an demonstration + example on how to use idle.js

How to use

To support idle.js in your application, you'll need to include a script tag in your html:

<script type="text/javascript" src="../idle.js"></script>

You may specify some global variables to tweak the behaviors.

// set redirect url (relative) after idle timeout
_idle('url', '/demo/logout.html');

// set escaped urls that no need to detect idle, e.g. logout page
_idle('escape', ['/demo/logout.html']);

// specifying a callback to replace the default redirect action
_idle('callback', function(){console.log('timeout')});

// customize idle time interval, in ms.
_idle('interval', 2000);

// enable debug mode
_idle('debug', true);

Build from source

To change the source file and build, simply use webpack.

# generates dist/tweak.js
webpack -d
# generates dist/tweak.min.js
webpack -p

License

MIT (see LICENSE)

Brought to you by the LinkORB Engineering team


Check out our other projects at linkorb.com/engineering.

Btw, we're hiring!

Readme

Keywords

Package Sidebar

Install

npm i @linkorb/idle

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

19.9 kB

Total Files

9

Last publish

Collaborators

  • jfaassen