Takazudo
10/21/2010 - 4:39 PM

dom console

dom console

/**
 * $.fixedConsole
 * dom console
 */
$.FixedConsole = function(){
	this.element = null;
	this.max = 20;
};
$.FixedConsole.prototype = {
	init: function(){
		var $el = this.element = $('<ul />')
			.css({
				margin: 0,
				padding: 0,
				listStyleType: 'none',
				position: 'fixed',
				right: 0,
				top: 0,
				opacity: 0.8,
				padding: '1em 1em 0.5em',
				background: '#000',
				color: '#fff',
				fontFamily: 'monospace',
				minWidth: 300
			})
			.appendTo('body');
		return this;
	},
	log: function(text){
		$('<li />')
			.text(text)
			.appendTo(this.element);
		var lis = $('li', this.element).toArray();
		while(lis.length > this.max){
			$(lis.shift()).remove();
		}
		return this;
	}
};
$.fixedConsole = new $.FixedConsole();

/* go */

$(function(){
	$.fixedConsole.init();
	$.fixedConsole.log('loglog yeah');
});