front_idill/extern/fajran-tuiojs/examples/log.js
author bastiena
Fri, 06 Apr 2012 18:32:13 +0200
changeset 25 a7b0e40bcab0
permissions -rw-r--r--
Front IDILL : Basic JS TUIO lib loaded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     1
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     2
var logs = [];
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     3
var max = 20;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     4
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     5
function updateLog() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     6
	if (logs.length > max) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     7
		logs = logs.splice(logs.length - max);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     8
	}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     9
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    10
	var text = logs.join("\n");
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    11
	document.getElementById('log').innerHTML = text;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    12
}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    13
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    14
function log(msg) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    15
	if (console.log) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    16
		console.log(msg);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    17
	}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    18
	else {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    19
		logs.push(msg);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    20
		updateLog();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    21
	}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    22
}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    23