|
2 | 2 |
|
3 | 3 | autoLogOut.js is small utility javascript, which helps us to manage the auto-logout state in multiple tabs if the user is not active. This relies on localstorage and localstorage change event for synchronizing the setTimeout between tabs.
|
4 | 4 |
|
5 |
| -autoLogOut.js expose only two methods:- |
6 |
| -- onExpires |
7 |
| -- onWarning |
| 5 | +<strong>autoLogOut.js</strong> implements the event listener on following events:- |
| 6 | + <ol > |
| 7 | + <li>Document ready</li> |
| 8 | + <li>Document unload</li> |
| 9 | + <li>Mouse movement</li> |
| 10 | + <li>Scroll event</li> |
| 11 | + <li>Window resize</li> |
| 12 | + <li>Storage change</li> |
| 13 | + </ol> |
| 14 | + All events are throttle with setTimeout approach, except storage change. |
| 15 | +</p> |
| 16 | +<p>For implementation: </p> |
8 | 17 |
|
9 |
| -**onExpires** method called when a timeout for specified minutes of inactive of user. |
10 |
| - |
11 |
| -**onWarning** method called before, at the specified time, auto log |
12 |
| - |
13 |
| -# TODO |
14 |
| - - Add mannual logout functionality |
15 |
| - - rename the expose the api object |
16 |
| - - rename the methods name |
17 |
| - - create a different versions for watcher and setTimeout |
| 18 | +``` |
| 19 | +var signOut = autoLogOut.init({ timeout: 1, sessionKey: 'Key', debug: true}); |
| 20 | +signOut.onSignOut = function () { |
| 21 | + alert("Called Timeout"); |
| 22 | + console.log("Timeout Called"); |
| 23 | +}; |
| 24 | +``` |
| 25 | +<p> <strong>autoLogOut.init()</strong> function take intial configuration object, each key description mentioned below:-</p> |
| 26 | +<ul> |
| 27 | + <li>timeout: number of minutes after that session will auto logout</li> |
| 28 | + <li>sessionKey: name of the localstorage key</li> |
| 29 | + <li>debug: console.log on event and timeout registration.</li> |
| 30 | +</ul> |
| 31 | +<p> |
| 32 | + <strong>autoLogOut.js</strong> have three methods:- |
| 33 | + <ul> |
| 34 | + <li>init : initial configuration function</li> |
| 35 | + <li>signOut: manual call the onSignOut callback</li> |
| 36 | + <li>onSignOut: this callback callback on logout</li> |
| 37 | + </ul> |
| 38 | +</p> |
18 | 39 |
|
0 commit comments