function load() {
let intervalID = window.setInterval(get_active_torrents, 20000);
}
function get_active_torrents() {
let httpRequest;
httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState !== XMLHttpRequest.DONE) { return; }
if (httpRequest.status !== 200) { return; }
torrents = JSON.parse(httpRequest.responseText);
let html_str = '';
for (let i = 0; i < torrents.length; i++) {
html_str += '
'
html_str += '' + torrents[i].name + ' | ';
html_str += '' + torrents[i].total_size_str + ' | ';
html_str += '' + torrents[i].state + ' | ';
html_str += '' + torrents[i].downrate_str + ' | ';
html_str += '' + torrents[i].down_percent + '% | ';
html_str += '' + torrents[i].eta_str + ' | ';
html_str += '' + torrents[i].uprate_str + ' | ';
html_str += '' + torrents[i].tracker + ' | ';
html_str += '
';
}
document.getElementById('torrents').children[1].innerHTML = html_str;
};
httpRequest.open('GET', get_torrents_uri, true);
httpRequest.send();
}