panic-shack/js/getLog.js

22 lines
536 B
JavaScript
Raw Normal View History

2017-11-30 21:07:27 +00:00
var output = document.getElementById('server-log');
function reqListener() {
var autoScroll = document.getElementById('auto-scroll');
output.textContent = xhr.responseText;
if (autoScroll.checked) {
output.scrollTop = output.scrollHeight;
}
}
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', reqListener);
xhr.open('GET', '/server.log');
xhr.send();
setInterval(function() {
xhr = new XMLHttpRequest();
xhr.addEventListener('load', reqListener);
xhr.open('GET', '/server.log');
xhr.send();
}, 10000);