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

no_pager/jquery-log.js revision 32 by dpavlin, Fri Aug 18 13:09:28 2006 UTC jquery/jquery-log.js revision 40 by dpavlin, Fri Aug 18 17:13:13 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;
8    
9  $.log = {  $.log = {
10    
# Line 17  $.log = { Line 17  $.log = {
17                  return m;                  return m;
18          },          },
19    
20          counter: function() {          insert: function(class, m) {
21                  $('#debug-counter').html(                  if (! _jql) this.create();
                         '<span class="log-info">'+_log_count.info+'</span> ' +  
                         '<span class="log-debug">'+_log_count.debug+'</span> ' +  
                         '<span class="log-error">'+_log_count.error+'</span>'  
                 );  
         },  
22    
23          toggle: function() {                  _jql.count[ class ]++;
24                  $('#debug').toggle();  
25                  $('#debug_show').toggle();                  var html = '<div class="jql-' + class + '"'
26                  return false;                  if ( ! _jql.on[class] ) html += ' style="display:none"';
27                    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          /* public functions */          /* public functions */
# Line 36  $.log = { Line 41  $.log = {
41          create: function() {          create: function() {
42    
43                  $('body').append(                  $('body').append(
44                  '<div id="debug" class="debug">' +                  '<div id="jql" class="jql"><div id="jql-bar">' +
45                  '<a class="hide" href="#" onclick="javascript:return $.log.toggle();">X</a>' +                  '<a href="#" onclick="javascript:return $.log.clean();">clean</a> | ' +
46                  '</div>' +                  '<a href="#" class=".jql-info" onclick="javascript:return $.log.toggle(\'info\');">info</a> ' +
47                  '<div id="debug_show" class="debug">' +                  '<a href="#" class=".jql-debug" onclick="javascript:return $.log.toggle(\'debug\');">debug</a> ' +
48                  '<a class="hide" href="#" onclick="javascript:return $.log.toggle();"><span id="debug-counter">?</span></a>' +                  '<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>'                  '</div>'
54                  );                  );
55    
56                  _log_count = {                  _jql = {
57                          info: 0,                          count: {
58                          debug: 0,                                  info: 0,
59                          error: 0                                  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');                  this.debug('created logger');
70          },          },
71    
72          info: function() {          /* onclick events */
73                  if (arguments) {  
74                          if (! _log_count) this.create();          toggle: function( what ) {
75                          _log_count.info++;                  if (what) {
76                          $('#debug').append( '<div class="log-info">'+this.join(arguments)+'</div>' );                          $.log.debug('toggle '+what);
77                          this.counter();                          $('.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) );
                         if (! _log_count) this.create();  
                         _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) );
                         if (! _log_count) this.create();  
                         _log_count.error++;  
                         $('#debug').append( '<div class="log-error">'+this.join(arguments)+'</div>' );  
                         this.counter();  
                 }  
101          }          }
102  };  };
103    

Legend:
Removed from v.32  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26