forked from pavpanchekha/keylogger.el
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbulk_data.js
44 lines (37 loc) · 1.11 KB
/
bulk_data.js
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
function secs_to_time(secs) {
var hours = 0;
var minutes = 0;
if (secs > 60 * 60) {
hours = Math.floor(secs / 60 / 60);
secs -= hours * 60 * 60;
}
if (secs > 60) {
minutes = Math.floor(secs / 60);
secs -= minutes * 60;
}
secs = Math.round(secs);
if (hours > 24) {
return hours + " h";
} else if (hours) {
return hours + " h" + (minutes ? ", " + minutes + " m" : "");
} else if (minutes) {
return minutes + " m" + (secs ? ", " + secs + " s" : "");
} else {
return secs + " s";
}
}
function bulk_data(data) {
var sec = document.getElementById("bulk_data");
var total = 0;
var time = 0.0;
var transitions = 0;
for (var i in data) {
total += data[i][1];
time += data[i][0];
transitions += 1;
}
sec.getElementsByClassName("total")[0].innerHTML = total;
sec.getElementsByClassName("time")[0].innerHTML = secs_to_time(time);
sec.getElementsByClassName("transitions")[0].innerHTML =
transitions + " (" + Math.round(100 * transitions / 96 / 96) + "%)";
}