Skip to content

Instantly share code, notes, and snippets.

@wwqrd
Created May 3, 2012 17:41
Show Gist options
  • Save wwqrd/2587525 to your computer and use it in GitHub Desktop.
Save wwqrd/2587525 to your computer and use it in GitHub Desktop.
Simple debug hud
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