2014-12-08 21:00:00 +01:00
|
|
|
var clearData = function() {
|
|
|
|
$('time_elapsed').set('html', '');
|
2015-07-08 15:27:33 +02:00
|
|
|
$('eta').set('html', '');
|
2014-12-08 21:00:00 +01:00
|
|
|
$('nb_connections').set('html', '');
|
2015-07-08 15:27:33 +02:00
|
|
|
$('total_downloaded').set('html', '');
|
|
|
|
$('total_uploaded').set('html', '');
|
|
|
|
$('dl_speed').set('html', '');
|
|
|
|
$('up_speed').set('html', '');
|
|
|
|
$('dl_limit').set('html', '');
|
|
|
|
$('up_limit').set('html', '');
|
|
|
|
$('total_wasted').set('html', '');
|
|
|
|
$('seeds').set('html', '');
|
|
|
|
$('peers').set('html', '');
|
2014-12-08 21:00:00 +01:00
|
|
|
$('share_ratio').set('html', '');
|
2015-07-08 15:27:33 +02:00
|
|
|
$('reannounce').set('html', '');
|
|
|
|
$('last_seen').set('html', '');
|
|
|
|
$('total_size').set('html', '');
|
|
|
|
$('pieces').set('html', '');
|
|
|
|
$('created_by').set('html', '');
|
|
|
|
$('addition_date').set('html', '');
|
|
|
|
$('completion_date').set('html', '');
|
|
|
|
$('creation_date').set('html', '');
|
|
|
|
$('torrent_hash').set('html', '');
|
|
|
|
$('save_path').set('html', '');
|
|
|
|
$('comment').set('html', '');
|
2014-12-08 21:00:00 +01:00
|
|
|
}
|
|
|
|
|
2014-12-11 00:01:04 +01:00
|
|
|
var loadTorrentDataTimer;
|
|
|
|
var loadTorrentData = function() {
|
2015-06-13 14:15:49 +02:00
|
|
|
if ($('prop_general').hasClass('invisible') ||
|
|
|
|
$('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
|
2014-12-08 21:00:00 +01:00
|
|
|
// Tab changed, don't do anything
|
|
|
|
return;
|
|
|
|
}
|
2015-11-11 22:58:30 +03:00
|
|
|
var current_hash = torrentsTable.getCurrentTorrentHash();
|
2014-12-08 21:00:00 +01:00
|
|
|
if (current_hash == "") {
|
|
|
|
clearData();
|
2014-12-11 21:22:23 +01:00
|
|
|
clearTimeout(loadTorrentDataTimer);
|
2014-12-08 22:00:00 +01:00
|
|
|
loadTorrentDataTimer = loadTorrentData.delay(5000);
|
2014-12-08 21:00:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Display hash
|
|
|
|
$('torrent_hash').set('html', current_hash);
|
2015-01-23 01:37:12 +03:00
|
|
|
var url = 'query/propertiesGeneral/' + current_hash;
|
2014-12-11 00:01:04 +01:00
|
|
|
var request = new Request.JSON({
|
|
|
|
url: url,
|
|
|
|
noCache: true,
|
|
|
|
method: 'get',
|
|
|
|
onFailure: function() {
|
2014-12-17 14:58:32 +03:00
|
|
|
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR');
|
2014-12-11 21:22:23 +01:00
|
|
|
clearTimeout(loadTorrentDataTimer);
|
2014-12-08 22:00:00 +01:00
|
|
|
loadTorrentDataTimer = loadTorrentData.delay(10000);
|
2014-12-11 00:01:04 +01:00
|
|
|
},
|
|
|
|
onSuccess: function(data) {
|
|
|
|
$('error_div').set('html', '');
|
|
|
|
if (data) {
|
|
|
|
var temp;
|
|
|
|
// Update Torrent data
|
2015-07-08 15:27:33 +02:00
|
|
|
if (data.seeding_time > 0)
|
2015-08-08 15:21:41 +02:00
|
|
|
temp = "QBT_TR(%1 (%2 this session))QBT_TR"
|
|
|
|
.replace("%1", friendlyDuration(data.time_elapsed))
|
|
|
|
.replace("%2", friendlyDuration(data.seeding_time))
|
|
|
|
else
|
|
|
|
temp = friendlyDuration(data.time_elapsed)
|
2014-12-11 00:01:04 +01:00
|
|
|
$('time_elapsed').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('eta').set('html', friendlyDuration(data.eta));
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 max))QBT_TR"
|
|
|
|
.replace("%1", data.nb_connections)
|
2015-08-08 16:23:30 +02:00
|
|
|
.replace("%2", data.nb_connections_limit < 0 ? "∞" : data.nb_connections_limit)
|
2014-12-11 00:01:04 +01:00
|
|
|
$('nb_connections').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 this session))QBT_TR"
|
|
|
|
.replace("%1", friendlyUnit(data.total_downloaded))
|
|
|
|
.replace("%2", friendlyUnit(data.total_downloaded_session))
|
2015-07-08 15:27:33 +02:00
|
|
|
$('total_downloaded').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 this session))QBT_TR"
|
|
|
|
.replace("%1", friendlyUnit(data.total_uploaded))
|
|
|
|
.replace("%2", friendlyUnit(data.total_uploaded_session))
|
2015-07-08 15:27:33 +02:00
|
|
|
$('total_uploaded').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 avg.))QBT_TR"
|
|
|
|
.replace("%1", friendlyUnit(data.dl_speed, true))
|
|
|
|
.replace("%2", friendlyUnit(data.dl_speed_avg, true));
|
2015-07-08 15:27:33 +02:00
|
|
|
$('dl_speed').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 avg.))QBT_TR"
|
|
|
|
.replace("%1", friendlyUnit(data.up_speed, true))
|
|
|
|
.replace("%2", friendlyUnit(data.up_speed_avg, true));
|
2015-07-08 15:27:33 +02:00
|
|
|
$('up_speed').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
temp = (data.dl_limit == -1 ? "∞" : friendlyUnit(data.dl_limit, true));
|
|
|
|
$('dl_limit').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
temp = (data.up_limit == -1 ? "∞" : friendlyUnit(data.up_limit, true));
|
|
|
|
$('up_limit').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('total_wasted').set('html', friendlyUnit(data.total_wasted));
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 total))QBT_TR"
|
|
|
|
.replace("%1", data.seeds)
|
|
|
|
.replace("%2", data.seeds_total);
|
2015-07-08 15:27:33 +02:00
|
|
|
$('seeds').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
|
|
|
temp = "QBT_TR(%1 (%2 total))QBT_TR"
|
|
|
|
.replace("%1", data.peers)
|
|
|
|
.replace("%2", data.peers_total);
|
2015-07-08 15:27:33 +02:00
|
|
|
$('peers').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2014-12-11 00:01:04 +01:00
|
|
|
$('share_ratio').set('html', data.share_ratio.toFixed(2));
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('reannounce').set('html', friendlyDuration(data.reannounce));
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
if (data.last_seen != -1)
|
|
|
|
temp = new Date(data.last_seen * 1000).toLocaleString();
|
|
|
|
else
|
|
|
|
temp = "QBT_TR(Never)QBT_TR";
|
|
|
|
$('last_seen').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('total_size').set('html', friendlyUnit(data.total_size));
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
if (data.pieces_num != -1)
|
2015-08-08 15:21:41 +02:00
|
|
|
temp = "QBT_TR(%1 x %2 (have %3))QBT_TR"
|
|
|
|
.replace("%1", data.pieces_num)
|
|
|
|
.replace("%2", friendlyUnit(data.piece_size))
|
|
|
|
.replace("%3", data.pieces_have);
|
2015-07-08 15:27:33 +02:00
|
|
|
else
|
|
|
|
temp = "QBT_TR(Unknown)QBT_TR";
|
|
|
|
$('pieces').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('created_by').set('html', data.created_by);
|
|
|
|
if (data.addition_date != -1)
|
|
|
|
temp = new Date(data.addition_date * 1000).toLocaleString();
|
|
|
|
else
|
|
|
|
temp = "QBT_TR(Unknown)QBT_TR";
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('addition_date').set('html', temp);
|
|
|
|
if (data.completion_date != -1)
|
|
|
|
temp = new Date(data.completion_date * 1000).toLocaleString();
|
|
|
|
else
|
|
|
|
temp = "";
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('completion_date').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
if (data.creation_date != -1)
|
|
|
|
temp = new Date(data.creation_date * 1000).toLocaleString();
|
|
|
|
else
|
|
|
|
temp = "QBT_TR(Unknown)QBT_TR";
|
|
|
|
$('creation_date').set('html', temp);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('save_path').set('html', data.save_path);
|
2015-08-08 15:21:41 +02:00
|
|
|
|
2015-07-08 15:27:33 +02:00
|
|
|
$('comment').set('html', parseHtmlLinks(data.comment));
|
2014-12-08 21:00:00 +01:00
|
|
|
}
|
2014-12-11 00:01:04 +01:00
|
|
|
else {
|
|
|
|
clearData();
|
|
|
|
}
|
2014-12-11 21:22:23 +01:00
|
|
|
clearTimeout(loadTorrentDataTimer);
|
2014-12-08 22:00:00 +01:00
|
|
|
loadTorrentDataTimer = loadTorrentData.delay(5000);
|
2014-12-11 00:01:04 +01:00
|
|
|
}
|
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
|
|
|
var updateTorrentData = function() {
|
|
|
|
clearTimeout(loadTorrentDataTimer);
|
|
|
|
loadTorrentData();
|
2015-05-17 15:47:37 +02:00
|
|
|
}
|