4 |
2006-08-18 Dobrica Pavlinusic <dpavlin@rot13.org> |
2006-08-18 Dobrica Pavlinusic <dpavlin@rot13.org> |
5 |
*/ |
*/ |
6 |
|
|
7 |
var _log_count = { |
var _log_count; |
|
info: 0, |
|
|
debug: 0, |
|
|
error: 0 |
|
|
}; |
|
8 |
|
|
9 |
$.log = { |
$.log = { |
10 |
|
|
11 |
|
/* semi-private functions */ |
12 |
|
|
13 |
join: function(a) { |
join: function(a) { |
14 |
var m = ''; |
var m = ''; |
15 |
for (var i=0; i<a.length; i++) |
for (var i=0; i<a.length; i++) |
17 |
return m; |
return m; |
18 |
}, |
}, |
19 |
|
|
20 |
|
insert: function(class, m) { |
21 |
|
if (! _log_count) this.create(); |
22 |
|
|
23 |
|
_log_count[ class ]++; |
24 |
|
|
25 |
|
var html = '<div class="jql-' + class + '">' + m + '</div>'; |
26 |
|
$('#jql').append( html ); |
27 |
|
//$('#jql').prepend( html ); |
28 |
|
|
29 |
|
// refresh count |
30 |
|
$('#jql-counter').html( |
31 |
|
'<span class="jql-info">'+_log_count.info+'</span> ' + |
32 |
|
'<span class="jql-debug">'+_log_count.debug+'</span> ' + |
33 |
|
'<span class="jql-error">'+_log_count.error+'</span>' |
34 |
|
); |
35 |
|
}, |
36 |
|
|
37 |
|
/* public functions */ |
38 |
|
|
39 |
|
create: function() { |
40 |
|
|
41 |
counter: function() { |
$('body').append( |
42 |
$('#debug-counter').html( |
'<div id="jql" class="jql">' + |
43 |
'<span class="log-info">'+_log_count.info+'</span> ' + |
'<a class="hide" href="#" onclick="javascript:return $.log.toggle();">X</a>' + |
44 |
'<span class="log-debug">'+_log_count.debug+'</span> ' + |
'</div>' + |
45 |
'<span class="log-error">'+_log_count.error+'</span>' |
'<div id="jql-show" class="jql">' + |
46 |
|
'<a class="hide" href="#" onclick="javascript:return $.log.toggle();"><span id="jql-counter">?</span></a>' + |
47 |
|
'</div>' |
48 |
); |
); |
49 |
|
|
50 |
|
_log_count = { |
51 |
|
info: 0, |
52 |
|
debug: 0, |
53 |
|
error: 0 |
54 |
|
}; |
55 |
|
|
56 |
|
this.debug('created logger'); |
57 |
|
}, |
58 |
|
|
59 |
|
toggle: function() { |
60 |
|
$('#jql').toggle(); |
61 |
|
$('#jql-show').toggle(); |
62 |
|
return false; |
63 |
}, |
}, |
64 |
|
|
65 |
info: function() { |
info: function() { |
66 |
if (arguments) { |
if (arguments) this.insert( 'info', this.join(arguments) ); |
|
_log_count.info++; |
|
|
$('#debug').append( '<div class="log-info">'+this.join(arguments)+'</div>' ); |
|
|
this.counter(); |
|
|
} |
|
67 |
}, |
}, |
68 |
debug: function() { |
debug: function() { |
69 |
if (arguments) { |
if (arguments) this.insert( 'debug', this.join(arguments) ); |
|
_log_count.debug++; |
|
|
$('#debug').append( '<div class="log-debug">'+this.join(arguments)+'</div>' ); |
|
|
this.counter(); |
|
|
} |
|
70 |
}, |
}, |
71 |
error: function() { |
error: function() { |
72 |
if (arguments) { |
if (arguments) this.insert( 'error', this.join(arguments) ); |
73 |
_log_count.error++; |
} |
|
$('#debug').append( '<div class="log-error">'+this.join(arguments)+'</div>' ); |
|
|
this.counter(); |
|
|
} |
|
|
}, |
|
74 |
}; |
}; |
75 |
|
|