/[jquery]/jquery/jquery-log.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /jquery/jquery-log.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 37 - (show annotations)
Fri Aug 18 15:35:54 2006 UTC (17 years, 8 months ago) by dpavlin
Original Path: no_pager/jquery-log.js
File MIME type: application/javascript
File size: 1510 byte(s)
refactor logging to be more concise
1 /*
2 jquery logging plugin
3
4 2006-08-18 Dobrica Pavlinusic <dpavlin@rot13.org>
5 */
6
7 var _log_count;
8
9 $.log = {
10
11 /* semi-private functions */
12
13 join: function(a) {
14 var m = '';
15 for (var i=0; i<a.length; i++)
16 m += a[i] + '<br/>';
17 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 $('body').append(
42 '<div id="jql" class="jql">' +
43 '<a class="hide" href="#" onclick="javascript:return $.log.toggle();">X</a>' +
44 '</div>' +
45 '<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() {
66 if (arguments) this.insert( 'info', this.join(arguments) );
67 },
68 debug: function() {
69 if (arguments) this.insert( 'debug', this.join(arguments) );
70 },
71 error: function() {
72 if (arguments) this.insert( 'error', this.join(arguments) );
73 }
74 };
75

  ViewVC Help
Powered by ViewVC 1.1.26