-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_output.html
59 lines (47 loc) · 1.47 KB
/
log_output.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
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<title>SCORM Log</title>
<script>
var o = window.opener;
var logListener = {
update:function(logger) {
printLog();
}
};
function printLog() {
var log = o.Logger.getInstance().getEntries();
var colours = ["#ffffff", "#00ffff", "#ffffe0", "#ffffff"];
var str = "</table>", ts;
for (var i = log.length - 1; i >= 0; i--) {
ts = new Date(log[i].time);
ts = pad(ts.getHours(), 2) + ':' + pad(ts.getMinutes(), 2) + ':' + pad(ts.getSeconds(), 2) + '.' + pad(ts.getMilliseconds(), 3);
str = "<tr><td style=\"background-color:" + colours[log[i].type] + ";\">" + ts + ' ' + log[i].str + "</td></tr>" + str;
}
str = "<table>" + str;
document.getElementById("logDiv").innerHTML = str;
}
function pad(numToPad, padBy) {
var len = padBy;
while(--len){ numToPad = "0" + numToPad; }
return numToPad.slice(-padBy);
}
function onLoad() {
if (o && o.Logger) {
o.Logger.getInstance().registerView(logListener);
printLog();
}
}
function onUnload() {
if (o && o.Logger) {
o.Logger.getInstance().unregisterView(logListener);
}
}
</script>
</head>
<body onload="onLoad();" onunload="onUnload();">
<div id="logDiv"></div>
</body>
</html>