Last active
April 5, 2017 20:54
-
-
Save camous/7456d36f328684afe9a890b4ec9b091c to your computer and use it in GitHub Desktop.
create infinite console for azure stream with limited memory leaks
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 count = 0; | |
var consoleMaxLines = 0; | |
function writeLog(text){ | |
var div = document.getElementById("result"); | |
var datetime = moment.utc(text,'YYYY-MM-DDTHH:mm:ss'); | |
if(datetime.isValid()){ | |
text = text.replace(datetime.format('YYYY-MM-DDTHH:mm:ss'),datetime.local().format('HH:mm:ss')); | |
} | |
if($("#l1").position() === undefined || $("#l1").position().top >= 0 && consoleMaxLines==0){ | |
count++; | |
div.innerHTML += '<div id="l' + count.toString() + '">' + text + '</div>'; | |
} else { | |
if(consoleMaxLines==0){ | |
consoleMaxLines = document.getElementById("result").children.length; | |
} | |
for(var i=1;i<consoleMaxLines;i++){ | |
$("#l" + i.toString()).html($("#l" + (i+1).toString()).html()); | |
} | |
$("#l" + consoleMaxLines.toString()).html(text); | |
} | |
div.scrollTop = div.scrollHeight; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment