Created
May 3, 2012 17:41
-
-
Save wwqrd/2587525 to your computer and use it in GitHub Desktop.
Simple debug hud
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
var hud = function(msg, length) { | |
var length = length || 2; | |
window.hudBuffer = window.hudBuffer || []; | |
window.hudBuffer.push(msg); | |
if(window.hudBuffer.length > length) { | |
window.hudBuffer.shift(); | |
} | |
hudString = ""; | |
for(var i in window.hudBuffer) { | |
hudString = new String(new Date().getTime()).substr(9)+": "+window.hudBuffer[i]+"<br />"+hudString; | |
} | |
var hudDom = document.getElementById('hud'); | |
if(hudDom == null) { | |
var hudDom = document.createElement('div'); | |
hudDom.setAttribute('id','hud'); | |
hudDom.setAttribute('style','position:fixed;top:10;left:10px;padding:10px;color:#fff;background:#000;z-index:10000;'); | |
document.body.appendChild(hudDom); | |
} | |
hudDom.innerHTML = hudString; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment