Skip to content

Instantly share code, notes, and snippets.

@ralt
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save ralt/86662df4065f1c3788df to your computer and use it in GitHub Desktop.

Select an option

Save ralt/86662df4065f1c3788df to your computer and use it in GitHub Desktop.
Share your js console
jsfiddle: http://jsfiddle.net/FRsGS/2/
A sample of how this could work:
HTML:
<output id="output"></output>
<input type="text" id="input">
JS:
```
var input = document.getElementById('input');
var output = document.getElementById('output');
console.log = function(l) {
output.innerHTML += l + '<br>';
};
input.addEventListener('keyup', function(e) {
if (e.keyCode !== 13) return;
var val;
try {
val = eval(this.value);
window.$_ = val;
} catch (e) {
val = e.constructor.name + ': ' + e.message;
}
output.innerHTML += val + '<br>';
input.value = '';
}, false);
```
And of course a better UX, like up-arrow support, multi-line support, $_ support... basically chrome console.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment