Last active
August 29, 2015 14:15
-
-
Save trevershick/6d9364085a1e566b2e18 to your computer and use it in GitHub Desktop.
Simple, easy to use console replacement script for use in JsFiddle...
This file contains hidden or 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
if (typeof($) === 'undefined') { | |
alert('jquery is required'); | |
} | |
$("body").append($('<div id="console-log"></div>').css({ | |
backgroundColor:'black', | |
color:'#33FF00', | |
padding:3 | |
})); | |
var consoleLineCss = { | |
fontFamily: 'monospace', | |
margin: 2, | |
marginBottom:10, | |
padding:2 | |
}; | |
if (!window._console) { | |
window._console = console; | |
} | |
console = { | |
group: function(nm) { | |
_console.group(nm); | |
}, | |
groupCollapsed: function(nm) { | |
_console.groupCollapsed(nm); | |
}, | |
groupEnd: function() { | |
_console.groupEnd(); | |
}, | |
table: function(data) { | |
_console.table(data); | |
}, | |
log: function (text, obj) { | |
_console.log(text,obj); | |
var objText = obj ? JSON.stringify(obj) : ""; | |
$("#console-log").append( | |
$("<p/>") | |
.html("<b>" + text + "</b> " + objText) | |
.css(consoleLineCss)); | |
}, | |
reset: function() { $("#console-log").html(""); } | |
}; | |
console.reset(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment