Created
September 30, 2011 14:25
-
-
Save pete-otaqui/1253892 to your computer and use it in GitHub Desktop.
EG-Console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var div; | |
var divId = 'eg-console'; | |
var noop = function () {}; | |
var echo = function (fn, args) { | |
if (!div) { | |
div = document.createElement('div'); | |
div.setAttribute('id', divId); | |
div.setAttribute('style', 'position:absolute;top:0px;right:0px;width:200px;z-index:999;border:1px solid #000;background-color:#fff'); | |
setTimeout(function() { | |
document.body.appendChild(div); | |
}, 100); | |
} | |
var html = fn + ' : '; | |
for (var i = 0, ii = args.length; i < ii; i++) { | |
html += args[i]; | |
if (i < ii - 1) html += ', '; | |
} | |
div.innerHTML += '<div>' + html + '</div>'; | |
}, | |
fncs = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'clear', 'dir', 'dirxml', 'trace', 'group', 'groupCollapsed', 'groupEnd', 'time', 'timeEnd', 'profile', 'profileEnd', 'count', 'exception', 'table']; | |
console = {}; | |
for ( i in fncs ) addConsoleFunc(fncs[i]); | |
function addConsoleFunc(fName) { | |
console[fName] = function() { | |
echo(fName, arguments); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment