-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
105 lines (79 loc) · 2.45 KB
/
index.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post">
<label>
<h2>Please input something to test!</h2>
<textarea id="in"></textarea>
</label>
<input type="button" name="next" value="next" id="next" />
</form>
<script type="text/javascript">
var inid=5;
function duration(timestamps) {
var last = timestamps.pop();
var durations = [];
while (timestamps.length) {
durations.push(last - (last = timestamps.pop()));
}
return durations.reverse();
}
function display(mills) {
if (mills > 1000)
return (mills / 1000) + ' s';
return mills + ' ms';
}
var durations = [];
var ftime;
var ctime;
var totalt = 0;
$('#in').keydown(function (e) {
durations.push($.now());
}).keyup(function (e) {
var current = durations;
current.push($.now());
durations = [];
var timeElapsed = current[current.length - 1] - current[0];
totalt = totalt + timeElapsed;
/* console.log([
['time elapsed:', display(timeElapsed)].join(' '),['time total:', display(totalt)].join(' ')
].join(' --- '));*/
// for-> key press time ,
// ['keys duration:', duration(current).map(display)].join(' ')
});
var ftime=0;
var date1=0;
var date2=0;
$('#in').click(function(event){
ftime = event.timeStamp;
date1 = ftime.toFixed();
//console.log(date1);
//console.log("ftime");
});
var ctime =0;
var cftime=0;
$('#next').click(function(event){
ctime = event.timeStamp;
date2 = ctime.toFixed();
cftime = date2-date1;
var secondsDifference1;
function cf(timestamp1, timestamp2) {
var difference = timestamp1 - timestamp2;
secondsDifference1 = Math.floor(difference/1000);
console.log("Total key press Time :");
console.log(secondsDifference1);
return secondsDifference1;
}
cf(date2,date1);
var dataString = 'secondsDifference1=' + secondsDifference1 + '&totalt=' + totalt + '&inid=' + inid;
$.ajax({
type: "POST",
url: "data.php",
data: dataString,
cache: false,
success: function(result) {
window.location = "ind2.php";
}
});
});
</script>
</html>