2019-02-15 10:01:33 -05:00
|
|
|
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++) {
|
2019-02-18 15:54:49 -05:00
|
|
|
html_str += '<tr>'
|
|
|
|
html_str += '<td class="name">' + torrents[i].name + '</td>';
|
|
|
|
html_str += '<td class="totalSize">' + torrents[i].total_size_str + '</td>';
|
|
|
|
html_str += '<td class="state">' + torrents[i].state + '</td>';
|
|
|
|
html_str += '<td class="downrate">' + torrents[i].downrate_str + '</td>';
|
2019-02-20 16:09:11 -05:00
|
|
|
html_str += '<td class="downPercent">' + torrents[i].down_percent + '%</td>';
|
2019-02-19 13:18:05 -05:00
|
|
|
html_str += '<td class="eta">' + torrents[i].eta_str + '</td>';
|
2019-02-18 15:54:49 -05:00
|
|
|
html_str += '<td class="uprate">' + torrents[i].uprate_str + '</td>';
|
|
|
|
html_str += '<td class="tracker">' + torrents[i].tracker + '</td>';
|
2019-08-31 21:43:41 -04:00
|
|
|
html_str += '<td class="rt_id">' + torrents[i].rtorrent_id + '</td>';
|
2019-02-18 15:54:49 -05:00
|
|
|
html_str += '</tr>';
|
2019-02-15 10:01:33 -05:00
|
|
|
}
|
|
|
|
document.getElementById('torrents').children[1].innerHTML = html_str;
|
|
|
|
};
|
|
|
|
httpRequest.open('GET', get_torrents_uri, true);
|
|
|
|
httpRequest.send();
|
|
|
|
}
|