-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathindex.html
71 lines (71 loc) · 1.99 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<html>
<head>
<title>jQuery Idle</title>
<style>
#status, #visibility, #myElement {
background-color: #E6EFC2;
border-color: #C6D880;
color: #264409;
padding:20px;
text-align: center;
width:100px;
}
#status.idle, #visibility.idle, #myElement.idle {
background-color: #FFF6BF;
border-color: #FFD324;
color: #514721;
}
</style>
</head>
<body>
<h1>jQuery Idle</h1>
<p>This is a simple example that will print in the box below the user status (active or idle). In this example, after 5 seconds idle, it will be displayed... "Idle!", of course :)</p>
<div id="status">Active!</div>
<div id="visibility">Visible!</div>
<div id="myElement" >Event!</div>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script type="text/javascript" src="jquery.idle.js"></script>
<script type="text/javascript">
$(document).idle({
onIdle: function() {
$('#status').toggleClass('idle').html('Idle!');
},
onActive: function() {
$('#status').toggleClass('idle').html('Active!');
},
onHide: function() {
$('#visibility').toggleClass('idle').html('Hidden!');
},
onShow: function() {
// Add a slight pause so you can see the change
setTimeout(function() {
$('#visibility').toggleClass('idle').html('Visible!');
}, 250);
},
idle: 2000,
keepTracking: true
});
$("div#myElement").idle({
onActive: function(instance, event) {
event.preventDefault(); // stop the timer
let node = $(this);
console.log("onActive.node", node);
node.text("(ACTIVE) Timer | DELAYED");
let timeId = setTimeout(function() {
clearTimeout(timeId);
event.restoreDefault(); // re-start the timer
node.text("(ACTIVE) Timer | STARTED");
}, 10000)
},
onIdle: function(instance) {
let node = $(this);
node.text("(IDLE) Timer - USER AFK");
},
idle: 2000,
});
</script>
</body>
</html>