/[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 34 by dpavlin, Fri Aug 18 13:20:53 2006 UTC jquery/jquery-log.js revision 43 by dpavlin, Fri Aug 18 18:01:02 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                    if (! _jql) this.create();
22    
23                    _jql.count[ class ]++;
24    
25                    var html = '<div class="jql-' + class + '"'
26                    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(                  $('#jql-counter').html(
33                          '<span class="jql-info">'+_log_count.info+'</span> ' +                          '<span class="jql-info">'+_jql.count.info+'</span> ' +
34                          '<span class="jql-debug">'+_log_count.debug+'</span> ' +                          '<span class="jql-debug">'+_jql.count.debug+'</span> ' +
35                          '<span class="jql-error">'+_log_count.error+'</span>'                          '<span class="jql-error">'+_jql.count.error+'</span>'
36                  );                  );
37    
38                    this.scroll();
39          },          },
40    
41          toggle: function() {          scroll: function() {
42                  $('#jql').toggle();                  // poor man's scroll to bottom
43                  $('#jql-show').toggle();                  var e = document.getElementById('jql-log');
44                  return false;                  e.scrollTop = e.scrollHeight - e.clientHeight;
45          },          },
46    
47          /* public functions */          /* public functions */
# Line 36  $.log = { Line 49  $.log = {
49          create: function() {          create: function() {
50    
51                  $('body').append(                  $('body').append(
52                  '<div id="jql" class="jql">' +                  '<div id="jql" class="jql"><div id="jql-bar">' +
53                  '<a class="hide" href="#" onclick="javascript:return $.log.toggle();">X</a>' +                  '<a href="#" onclick="javascript:return $.log.clean();">clean</a> | ' +
54                  '</div>' +                  '<a href="#" class=".jql-info" onclick="javascript:return $.log.toggle(\'info\');">info</a> ' +
55                    '<a href="#" class=".jql-debug" onclick="javascript:return $.log.toggle(\'debug\');">debug</a> ' +
56                    '<a href="#" class=".jql-error" onclick="javascript:return $.log.toggle(\'error\');">error</a> | ' +
57                    '<a href="#" onclick="javascript:return $.log.toggle();">close</a>' +
58                    '</div><div id="jql-log"></div></div>' +
59                  '<div id="jql-show" class="jql">' +                  '<div id="jql-show" class="jql">' +
60                  '<a class="hide" href="#" onclick="javascript:return $.log.toggle();"><span id="jql-counter">?</span></a>' +                  '<a href="#" onclick="javascript:return $.log.toggle();"><span id="jql-counter">?</span></a>' +
61                  '</div>'                  '</div>'
62                  );                  );
63    
64                  _log_count = {                  _jql = {
65                          info: 0,                          count: {
66                          debug: 0,                                  info: 0,
67                          error: 0                                  debug: 0,
68                                    error: 0
69                            },
70                            on: {
71                                    info: true,
72                                    debug: true,
73                                    error: true
74                            }
75                  };                  };
76    
77                  this.debug('created logger');                  this.debug('created logger');
78          },          },
79    
80          info: function() {          /* onclick events */
81                  if (arguments) {  
82                          if (! _log_count) this.create();          toggle: function( what ) {
83                          _log_count.info++;                  if (what) {
84                          $('#jql').append( '<div class="jql-info">'+this.join(arguments)+'</div>' );                          $.log.debug('toggle '+what);
85                          this.counter();                          $('.jql-'+what).toggle();
86                            _jql.on[what] = ! _jql.on[what];
87                    } else {
88                            $.log.debug('toggle logger');
89                            $('#jql').toggle();
90                            $('#jql-show').toggle();
91                  }                  }
92                    this.scroll();
93                    return false;
94            },
95    
96            clean: function() {
97                    $('#jql-log').html('');
98            },
99    
100            /* public methods to call from your code */
101    
102            info: function() {
103                    if (arguments) this.insert( 'info', this.join(arguments) );
104          },          },
105          debug: function() {          debug: function() {
106                  if (arguments) {                  if (arguments) this.insert( 'debug', this.join(arguments) );
                         if (! _log_count) this.create();  
                         _log_count.debug++;  
                         $('#jql').append( '<div class="jql-debug">'+this.join(arguments)+'</div>' );  
                         this.counter();  
                 }  
107          },          },
108          error: function() {          error: function() {
109                  if (arguments) {                  if (arguments) this.insert( 'error', this.join(arguments) );
                         if (! _log_count) this.create();  
                         _log_count.error++;  
                         $('#jql').append( '<div class="jql-error">'+this.join(arguments)+'</div>' );  
                         this.counter();  
                 }  
110          }          }
111  };  };
112    

Legend:
Removed from v.34  
changed lines
  Added in v.43

  ViewVC Help
Powered by ViewVC 1.1.26