Skip to content

Instantly share code, notes, and snippets.

@trevershick
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevershick/6d9364085a1e566b2e18 to your computer and use it in GitHub Desktop.
Save trevershick/6d9364085a1e566b2e18 to your computer and use it in GitHub Desktop.
Simple, easy to use console replacement script for use in JsFiddle...
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