-
Notifications
You must be signed in to change notification settings - Fork 59
/
index.htm
62 lines (56 loc) · 1.46 KB
/
index.htm
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
<html>
<head>
<title>Idle.Js Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="./build/idle.js"></script>
<script>
$(function() {
function setMessage(msg) {
$('#ActivityList').append("<li>" + new Date().toTimeString() + ": " + msg + "</li>");
}
var awayCallback = function() {
setMessage("away");
};
var awayBackCallback = function() {
setMessage("back");
};
var hiddenCallback = function() {
setMessage("User is not looking at page");
};
var visibleCallback = function(){
setMessage("User started looking at page again")
};
var idle = new Idle({
onHidden : hiddenCallback,
onVisible : visibleCallback,
onAway : awayCallback,
onAwayBack : awayBackCallback,
awayTimeout : $('#Timeout').val() //away with default value of the textbox
}).start();
$('#Timeout').keydown(function(e) {
if(e.keyCode == 13) {
var timeout = $(this).val();
setMessage("Timeout changed to: " + timeout);
idle.setAwayTimeout(timeout);
}
})
});
</script>
<style>
#ActivityList {
border: 1px solid #ccc;
padding: 5px;
width: 400px;
}
#ActivityList li {
border-bottom: 1px solid #eee;
margin: 5px 0;
}
</style>
</head>
<body>
<label for="Timeout">Set timeout</label>
<input id="Timeout" type="text" value="5000" />
<ul id="ActivityList"></ul>
</body>
</html>