Last active
December 19, 2015 19:08
-
-
Save zhester/6003709 to your computer and use it in GitHub Desktop.
Function for adding a very primitive debug console to any page for development.
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
/** | |
* dbg | |
* Debug message printer. Drop-in debug console. | |
* | |
* @param message Message to display in console | |
*/ | |
function dbg( message ) { | |
var ul = document.getElementById( 'message' ); | |
if( ul == null ) { | |
ul = document.createElement( 'ul' ); | |
ul.id = 'message'; | |
ul.style.position = 'absolute'; | |
ul.style.right = '0'; | |
ul.style.bottom = '0'; | |
ul.style.maxHeight = '90%'; | |
ul.style.overflow = 'auto'; | |
ul.style.margin = '0'; | |
ul.style.padding = '2px 5px'; | |
ul.style.border = 'solid 1px #EEEEEE'; | |
ul.backgroundColor = '#FFFFFF'; | |
document.getElementsByTagName( 'body' )[ 0 ].appendChild( ul ); | |
} | |
var li = document.createElement( 'li' ); | |
li.appendChild( document.createTextNode( message ) ); | |
ul.appendChild( li ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment