-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (54 loc) · 2.24 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>AutoLogOut.js</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body class="container">
<h1>autoLogOut.js</h1>
<p>Use localstorage for update the last user activity with unix-timestamp</p>
<p><a href="https://stackoverflow.com/questions/6585112/javascript-performance-when-running-in-an-unfocused-tab">Browser Issue</a></p>
<p>
<strong>autoLogOut.js</strong> implements the event listener on following events:-
<ol >
<li>Document ready</li>
<li>Document unload</li>
<li>Mouse movement</li>
<li>Scroll event</li>
<li>Window resize</li>
<li>Storage change</li>
</ol>
All events are throttle with setTimeout approach, except storage change.
</p>
<p>For implementation: </p>
<pre class="alert alert-dark">
var signOut = autoLogOut.init({ timeout: 1, sessionKey: 'Key', debug: true});
signOut.onSignOut = function () {
alert("Called Timeout");
console.log("Timeout Called");
};</pre>
<p> <strong>autoLogOut.init()</strong> function take intial configuration object, each key description mentioned below:-</p>
<ul>
<li>timeout: number of minutes after that session will auto logout</li>
<li>sessionKey: name of the localstorage key</li>
<li>debug: console.log on event and timeout registration.</li>
</ul>
<p>
<strong>autoLogOut.js</strong> have three methods:-
<ul>
<li>init : initial configuration function</li>
<li>signOut: manual call the onSignOut callback</li>
<li>onSignOut: this callback callback on logout</li>
</ul>
</p>
<script src="autoLogOut.js"></script>
<script>
var signOut = autoLogOut.init({ timeout: 1, sessionKey: 'Key', debug: true })
signOut.onSignOut = function () {
alert("Called Timeout");
console.log("Timeout Called");
};
</script>
</body>
</html>