/[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

Diff of /jquery/jquery-log.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Fri Aug 18 11:54:32 2006 UTC revision 38 by dpavlin, Fri Aug 18 16:53:11 2006 UTC
# Line 4  Line 4 
4          2006-08-18 Dobrica Pavlinusic <dpavlin@rot13.org>          2006-08-18 Dobrica Pavlinusic <dpavlin@rot13.org>
5  */  */
6    
7  var _log_count = {  var _jql;
         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++)
# Line 18  $.log = { Line 17  $.log = {
17                  return m;                  return m;
18          },          },
19    
20            insert: function(class, m) {
21                    if (! _jql) this.create();
22    
23          counter: function() {                  _jql.count[ class ]++;
24                  $('#debug-counter').html(  
25                          '<span class="log-info">'+_log_count.info+'</span> ' +                  var html = '<div class="jql-' + class + '"'
26                          '<span class="log-debug">'+_log_count.debug+'</span> ' +                  if ( ! _jql.on[class] ) html += ' style="display:none"';
27                          '<span class="log-error">'+_log_count.error+'</span>'                  html += '>' + m + '</div>';
28                    $('#jql-log').append( html );
29                    //$('#jql-log').prepend( html );
30    
31                    // refresh count
32                    $('#jql-counter').html(
33                            '<span class="jql-info">'+_jql.count.info+'</span> ' +
34                            '<span class="jql-debug">'+_jql.count.debug+'</span> ' +
35                            '<span class="jql-error">'+_jql.count.error+'</span>'
36                  );                  );
37          },          },
38    
39          info: function() {          /* public functions */
40                  if (arguments) {  
41                          _log_count.info++;          create: function() {
42                          $('#debug').append( '<div class="log-info">'+this.join(arguments)+'</div>' );  
43                          this.counter();                  $('body').append(
44                    '<div id="jql" class="jql"><div id="jql-bar">' +
45                    '<a href="#" onclick="javascript:return $.log.clean();">clean</a> | ' +
46                    '<a href="#" class=".jql-info" onclick="javascript:return $.log.toggle(\'info\');">info</a> ' +
47                    '<a href="#" class=".jql-debug" onclick="javascript:return $.log.toggle(\'debug\');">debug</a> ' +
48                    '<a href="#" class=".jql-error" onclick="javascript:return $.log.toggle(\'error\');">error</a> | ' +
49                    '<a href="#" onclick="javascript:return $.log.toggle();">close</a>' +
50                    '</div><div id="jql-log"></div></div>' +
51                    '<div id="jql-show" class="jql">' +
52                    '<a href="#" onclick="javascript:return $.log.toggle();"><span id="jql-counter">?</span></a>' +
53                    '</div>'
54                    );
55    
56                    _jql = {
57                            count: {
58                                    info: 0,
59                                    debug: 0,
60                                    error: 0
61                            },
62                            on: {
63                                    info: true,
64                                    debug: true,
65                                    error: true
66                            }
67                    };
68    
69                    this.debug('created logger');
70            },
71    
72            /* onclick events */
73    
74            toggle: function( what ) {
75                    if (what) {
76                            $.log.debug('toggle '+what);
77                            $('.jql-'+what).toggle();
78                            _jql.on[what] = ! _jql.on[what];
79                    } else {
80                            $.log.debug('toggle logger');
81                            $('#jql').toggle();
82                            $('#jql-show').toggle();
83                  }                  }
84                    return false;
85            },
86    
87            clean: function() {
88                    $('#jql-log').html('');
89            },
90    
91            /* public methods to call from your code */
92    
93            info: function() {
94                    if (arguments) this.insert( 'info', this.join(arguments) );
95          },          },
96          debug: function() {          debug: function() {
97                  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();  
                 }  
98          },          },
99          error: function() {          error: function() {
100                  if (arguments) {                  if (arguments) this.insert( 'error', this.join(arguments) );
101                          _log_count.error++;          }
                         $('#debug').append( '<div class="log-error">'+this.join(arguments)+'</div>' );  
                         this.counter();  
                 }  
         },  
102  };  };
103    

Legend:
Removed from v.30  
changed lines
  Added in v.38

  ViewVC Help
Powered by ViewVC 1.1.26