--- no_pager/jquery-log.js 2006/08/18 13:20:53 34 +++ no_pager/jquery-log.js 2006/08/18 16:53:11 38 @@ -4,7 +4,7 @@ 2006-08-18 Dobrica Pavlinusic */ -var _log_count; +var _jql; $.log = { @@ -17,65 +17,87 @@ return m; }, - counter: function() { + insert: function(class, m) { + if (! _jql) this.create(); + + _jql.count[ class ]++; + + var html = '
'; + $('#jql-log').append( html ); + //$('#jql-log').prepend( html ); + + // refresh count $('#jql-counter').html( - ''+_log_count.info+' ' + - ''+_log_count.debug+' ' + - ''+_log_count.error+'' + ''+_jql.count.info+' ' + + ''+_jql.count.debug+' ' + + ''+_jql.count.error+'' ); }, - toggle: function() { - $('#jql').toggle(); - $('#jql-show').toggle(); - return false; - }, - /* public functions */ create: function() { $('body').append( - '
' + - 'X' + - '
' + + '
' + + 'clean | ' + + 'info ' + + 'debug ' + + 'error | ' + + 'close' + + '
' + '
' + - '?' + + '?' + '
' ); - _log_count = { - info: 0, - debug: 0, - error: 0 + _jql = { + count: { + info: 0, + debug: 0, + error: 0 + }, + on: { + info: true, + debug: true, + error: true + } }; this.debug('created logger'); }, - info: function() { - if (arguments) { - if (! _log_count) this.create(); - _log_count.info++; - $('#jql').append( '
'+this.join(arguments)+'
' ); - this.counter(); + /* onclick events */ + + toggle: function( what ) { + if (what) { + $.log.debug('toggle '+what); + $('.jql-'+what).toggle(); + _jql.on[what] = ! _jql.on[what]; + } else { + $.log.debug('toggle logger'); + $('#jql').toggle(); + $('#jql-show').toggle(); } + return false; + }, + + clean: function() { + $('#jql-log').html(''); + }, + + /* public methods to call from your code */ + + info: function() { + if (arguments) this.insert( 'info', this.join(arguments) ); }, debug: function() { - if (arguments) { - if (! _log_count) this.create(); - _log_count.debug++; - $('#jql').append( '
'+this.join(arguments)+'
' ); - this.counter(); - } + if (arguments) this.insert( 'debug', this.join(arguments) ); }, error: function() { - if (arguments) { - if (! _log_count) this.create(); - _log_count.error++; - $('#jql').append( '
'+this.join(arguments)+'
' ); - this.counter(); - } + if (arguments) this.insert( 'error', this.join(arguments) ); } };