-
Notifications
You must be signed in to change notification settings - Fork 3
/
log.js.php
34 lines (28 loc) · 945 Bytes
/
log.js.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
<?php
header('Content-type: application/x-javascript');
include("todo-core.php"); ?>
var logItems = new Array('<?php echo(TodoLang::_("STARTING_LOG"));?>');
var logLines = 3; /* const, but IE doesn't support that keyword */
var logVisible = true;
function updateLog(element, maxCount) {
var logOutput = '';
var start = Math.max(0, logItems.length-maxCount);
var end = Math.min(start+maxCount, logItems.length);
for (var i=start; i<end; ++i) {
logOutput += '' + i + ': ' + logItems[i];
if (i<end-1) {
logOutput += '<br />';
}
}
$(element).html(logOutput);
}
function toggleLog() {
$('#smallLog').css('display', (logVisible)? 'none': 'block');
$('#logLink').css('display', (logVisible)? 'block': 'none');
logVisible = !logVisible;
}
function log(logStr) {
logItems.push(logStr);
updateLog('#smallLog', logLines);
$('#smallLog').css('display', 'block');
}