Created
July 12, 2013 22:59
-
-
Save brianswisher/5988485 to your computer and use it in GitHub Desktop.
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
// shim layer with setTimeout fallback | |
window.requestAnimFrame = (function(){ | |
return window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
function( callback ){ | |
window.setTimeout(callback, 1000 / 60); | |
}; | |
})(); | |
var persistConsole = (function(){ | |
var index = localStorage.getItem('index') || '', | |
ary = index.split('+'), | |
div = document.createElement('div'), | |
htm = div.innerHTML = '', | |
update = function(){ | |
var i, | |
item, | |
mm_urid = persist.get('mm_urid', true), | |
jt_reqid = persist.get('jt-reqid', true); | |
htm = div.innerHTML = ''; | |
for (i in ary){ | |
var obj = persist.get(ary[i], true); | |
if (obj) { | |
htm += | |
'<div style="padding:2px"><span style="color:aqua">'+ary[i]+':</span> ' + | |
obj.value + ' <a id="'+ary[i]+'" onclick="var x=persist.get(\''+ary[i]+'\',1);if(x)persist.set(\''+ary[i]+'\',x.value,persist.duration(.001,\'second\'));this.innerHTML=\'expired\'" style="color:#0088cc;font-weight:bold;"></a>' + | |
'<div>'; | |
} | |
} | |
div.innerHTML = htm; | |
(function animloop(){ | |
requestAnimFrame(animloop); | |
render(); | |
})(); | |
function render(){ | |
for (i in ary){ | |
var obj = persist.get(ary[i], true), | |
elem = document.getElementById(ary[i]); | |
if (obj) { | |
htm += | |
elem.innerHTML = ((obj.expire - (new Date().getTime().toString() - obj.timestamp))/(persist.day)).toString().substring(0,9); | |
} | |
} | |
} | |
}; | |
ary.shift(); | |
div.style.textAlign = 'left'; | |
div.style.position = 'absolute'; | |
div.style.whiteSpace = 'nowrap'; | |
div.style.top = 0; | |
div.style.left = 0; | |
div.style.background = '#222'; | |
div.style.color = 'white'; | |
div.style.fontSize = '11px'; | |
document.body.appendChild(div); | |
update(); | |
return { | |
update:update | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment