Last active
August 29, 2015 14:04
-
-
Save ralt/86662df4065f1c3788df to your computer and use it in GitHub Desktop.
Share your js console
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
| 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