Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created October 21, 2010 16:39
Show Gist options
  • Save Takazudo/638827 to your computer and use it in GitHub Desktop.
Save Takazudo/638827 to your computer and use it in GitHub Desktop.
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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment