--- no_pager/jquery-log.js 2006/08/18 11:54:32 30 +++ no_pager/jquery-log.js 2006/08/18 16:53:11 38 @@ -4,13 +4,12 @@ 2006-08-18 Dobrica Pavlinusic */ -var _log_count = { - info: 0, - debug: 0, - error: 0 -}; +var _jql; $.log = { + + /* semi-private functions */ + join: function(a) { var m = ''; for (var i=0; i'+_log_count.info+' ' + - ''+_log_count.debug+' ' + - ''+_log_count.error+'' + _jql.count[ class ]++; + + var html = '
'; + $('#jql-log').append( html ); + //$('#jql-log').prepend( html ); + + // refresh count + $('#jql-counter').html( + ''+_jql.count.info+' ' + + ''+_jql.count.debug+' ' + + ''+_jql.count.error+'' ); }, - info: function() { - if (arguments) { - _log_count.info++; - $('#debug').append( '
'+this.join(arguments)+'
' ); - this.counter(); + /* public functions */ + + create: function() { + + $('body').append( + '
' + + 'clean | ' + + 'info ' + + 'debug ' + + 'error | ' + + 'close' + + '
' + + '
' + + '?' + + '
' + ); + + _jql = { + count: { + info: 0, + debug: 0, + error: 0 + }, + on: { + info: true, + debug: true, + error: true + } + }; + + this.debug('created logger'); + }, + + /* 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) { - _log_count.debug++; - $('#debug').append( '
'+this.join(arguments)+'
' ); - this.counter(); - } + if (arguments) this.insert( 'debug', this.join(arguments) ); }, error: function() { - if (arguments) { - _log_count.error++; - $('#debug').append( '
'+this.join(arguments)+'
' ); - this.counter(); - } - }, + if (arguments) this.insert( 'error', this.join(arguments) ); + } }; +