2011-09-14 05:10:51 +00:00
|
|
|
/**
|
|
|
|
* Copyright © Mnemosyne LLC
|
|
|
|
*
|
|
|
|
* This file is licensed under the GPLv2.
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
2011-08-16 18:49:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
function TorrentRendererHelper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.getProgressInfo = function(controller, t)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2011-08-28 13:57:25 +00:00
|
|
|
var pct, extra,
|
|
|
|
s = t.getStatus(),
|
|
|
|
seed_ratio_limit = t.seedRatioLimit(controller);
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (t.needsMetaData())
|
2011-08-20 21:17:12 +00:00
|
|
|
pct = t.getMetadataPercentComplete() * 100;
|
2011-08-24 02:04:35 +00:00
|
|
|
else if (!t.isDone())
|
|
|
|
pct = Math.round(t.getPercentDone() * 100);
|
2011-08-25 03:27:33 +00:00
|
|
|
else if (seed_ratio_limit > 0 && t.isSeeding()) // don't split up the bar if paused or queued
|
2011-08-24 02:04:35 +00:00
|
|
|
pct = Math.round(t.getUploadRatio() * 100 / seed_ratio_limit);
|
2011-08-16 18:49:26 +00:00
|
|
|
else
|
|
|
|
pct = 100;
|
|
|
|
|
2011-09-05 07:46:55 +00:00
|
|
|
if (s === Torrent._StatusStopped)
|
2011-08-16 18:49:26 +00:00
|
|
|
extra = 'paused';
|
2011-09-05 07:46:55 +00:00
|
|
|
else if (s === Torrent._StatusDownloadWait)
|
2011-08-25 06:18:42 +00:00
|
|
|
extra = 'leeching queued';
|
2011-08-24 02:04:35 +00:00
|
|
|
else if (t.needsMetaData())
|
2011-08-16 18:49:26 +00:00
|
|
|
extra = 'magnet';
|
2011-08-25 06:18:42 +00:00
|
|
|
else if (s === Torrent._StatusDownload)
|
2011-08-16 18:49:26 +00:00
|
|
|
extra = 'leeching';
|
2011-09-05 07:46:55 +00:00
|
|
|
else if (s === Torrent._StatusSeedWait)
|
2011-08-25 06:18:42 +00:00
|
|
|
extra = 'seeding queued';
|
2011-09-05 07:46:55 +00:00
|
|
|
else if (s === Torrent._StatusSeed)
|
2011-08-25 06:18:42 +00:00
|
|
|
extra = 'seeding';
|
2011-08-28 13:57:25 +00:00
|
|
|
else
|
|
|
|
extra = '';
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
percent: pct,
|
|
|
|
complete: [ 'torrent_progress_bar', 'complete', extra ].join(' '),
|
|
|
|
incomplete: [ 'torrent_progress_bar', 'incomplete', extra ].join(' ')
|
|
|
|
};
|
2011-08-24 02:04:35 +00:00
|
|
|
};
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.createProgressbar = function(classes)
|
2011-08-20 15:31:34 +00:00
|
|
|
{
|
2011-08-28 13:57:25 +00:00
|
|
|
var complete, incomplete, progressbar;
|
|
|
|
|
|
|
|
complete = document.createElement('div');
|
2011-08-20 15:31:34 +00:00
|
|
|
complete.className = 'torrent_progress_bar complete';
|
2011-08-28 13:57:25 +00:00
|
|
|
|
|
|
|
incomplete = document.createElement('div');
|
2011-08-20 15:31:34 +00:00
|
|
|
incomplete.className = 'torrent_progress_bar incomplete';
|
2011-08-28 13:57:25 +00:00
|
|
|
|
|
|
|
progressbar = document.createElement('div');
|
2011-08-20 15:31:34 +00:00
|
|
|
progressbar.className = 'torrent_progress_bar_container ' + classes;
|
2011-08-24 02:04:35 +00:00
|
|
|
progressbar.appendChild(complete);
|
|
|
|
progressbar.appendChild(incomplete);
|
2011-08-28 13:57:25 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
return { 'element': progressbar, 'complete': complete, 'incomplete': incomplete };
|
|
|
|
};
|
2011-08-20 15:31:34 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.renderProgressbar = function(controller, t, progressbar)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2011-08-31 00:09:21 +00:00
|
|
|
var e, style, width, display,
|
|
|
|
info = TorrentRendererHelper.getProgressInfo(controller, t);
|
2011-08-26 23:30:07 +00:00
|
|
|
|
|
|
|
// update the complete progressbar
|
2011-08-20 15:31:34 +00:00
|
|
|
e = progressbar.complete;
|
2011-08-31 00:09:21 +00:00
|
|
|
style = e.style;
|
|
|
|
width = '' + info.percent + '%';
|
|
|
|
display = info.percent > 0 ? 'block' : 'none';
|
|
|
|
if (style.width!==width || style.display!==display)
|
|
|
|
$(e).css({ width: ''+info.percent+'%', display: display });
|
2011-08-28 14:57:13 +00:00
|
|
|
if (e.className !== info.complete)
|
|
|
|
e.className = info.complete;
|
2011-08-26 23:30:07 +00:00
|
|
|
|
|
|
|
// update the incomplete progressbar
|
2011-08-20 15:31:34 +00:00
|
|
|
e = progressbar.incomplete;
|
2011-08-26 23:30:07 +00:00
|
|
|
display = (info.percent < 100) ? 'block' : 'none';
|
|
|
|
if (e.style.display !== display)
|
|
|
|
e.style.display = display;
|
2011-08-28 14:57:13 +00:00
|
|
|
if (e.className !== info.incomplete)
|
|
|
|
e.className = info.incomplete;
|
2011-08-24 02:04:35 +00:00
|
|
|
};
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.formatUL = function(t)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2012-08-07 00:14:04 +00:00
|
|
|
return '↑ ' + Transmission.fmt.speedBps(t.getUploadSpeed());
|
2011-08-24 02:04:35 +00:00
|
|
|
};
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.formatDL = function(t)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2012-08-07 00:14:04 +00:00
|
|
|
return '↓ ' + Transmission.fmt.speedBps(t.getDownloadSpeed());
|
2011-08-24 02:04:35 +00:00
|
|
|
};
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
/****
|
|
|
|
*****
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
|
|
|
function TorrentRendererFull()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TorrentRendererFull.prototype =
|
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
createRow: function()
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2011-08-28 13:57:25 +00:00
|
|
|
var root, name, peers, progressbar, details, image, button;
|
|
|
|
|
|
|
|
root = document.createElement('li');
|
2011-08-16 18:49:26 +00:00
|
|
|
root.className = 'torrent';
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
name = document.createElement('div');
|
2011-08-16 18:49:26 +00:00
|
|
|
name.className = 'torrent_name';
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
peers = document.createElement('div');
|
2011-08-16 18:49:26 +00:00
|
|
|
peers.className = 'torrent_peer_details';
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
progressbar = TorrentRendererHelper.createProgressbar('full');
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
details = document.createElement('div');
|
2011-08-16 18:49:26 +00:00
|
|
|
details.className = 'torrent_progress_details';
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
image = document.createElement('div');
|
|
|
|
button = document.createElement('a');
|
2011-08-24 02:04:35 +00:00
|
|
|
button.appendChild(image);
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
root.appendChild(name);
|
|
|
|
root.appendChild(peers);
|
|
|
|
root.appendChild(button);
|
|
|
|
root.appendChild(progressbar.element);
|
|
|
|
root.appendChild(details);
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
root._name_container = name;
|
|
|
|
root._peer_details_container = peers;
|
|
|
|
root._progress_details_container = details;
|
2011-08-20 15:31:34 +00:00
|
|
|
root._progressbar = progressbar;
|
2011-08-16 18:49:26 +00:00
|
|
|
root._pause_resume_button_image = image;
|
|
|
|
root._toggle_running_button = button;
|
|
|
|
|
|
|
|
return root;
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getPeerDetails: function(t)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2012-10-07 17:51:56 +00:00
|
|
|
var err,
|
|
|
|
peer_count,
|
|
|
|
webseed_count,
|
|
|
|
fmt = Transmission.fmt;
|
2012-10-07 16:33:55 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if ((err = t.getErrorMessage()))
|
2011-08-16 18:49:26 +00:00
|
|
|
return err;
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (t.isDownloading())
|
2012-10-07 16:33:55 +00:00
|
|
|
{
|
2012-10-07 17:51:56 +00:00
|
|
|
peer_count = t.getPeersConnected();
|
2012-10-07 16:33:55 +00:00
|
|
|
webseed_count = t.getWebseedsSendingToUs();
|
|
|
|
|
2012-10-07 17:51:56 +00:00
|
|
|
if (webseed_count && peer_count)
|
2012-10-07 16:33:55 +00:00
|
|
|
{
|
2012-10-07 17:51:56 +00:00
|
|
|
// Downloading from 2 of 3 peer(s) and 2 webseed(s)
|
2012-10-07 16:33:55 +00:00
|
|
|
return [ 'Downloading from',
|
|
|
|
t.getPeersSendingToUs(),
|
|
|
|
'of',
|
2012-10-07 18:10:26 +00:00
|
|
|
fmt.countString('peer','peers',peer_count),
|
2012-10-07 17:51:56 +00:00
|
|
|
'and',
|
2012-10-25 03:56:57 +00:00
|
|
|
fmt.countString('web seed','web seeds',webseed_count),
|
|
|
|
'-',
|
|
|
|
TorrentRendererHelper.formatDL(t),
|
|
|
|
TorrentRendererHelper.formatUL(t) ].join(' ');
|
2012-10-07 17:51:56 +00:00
|
|
|
}
|
|
|
|
else if (webseed_count)
|
|
|
|
{
|
|
|
|
// Downloading from 2 webseed(s)
|
|
|
|
return [ 'Downloading from',
|
2012-10-25 03:56:57 +00:00
|
|
|
fmt.countString('web seed','web seeds',webseed_count),
|
|
|
|
'-',
|
|
|
|
TorrentRendererHelper.formatDL(t),
|
|
|
|
TorrentRendererHelper.formatUL(t) ].join(' ');
|
2012-10-07 16:33:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-07 17:51:56 +00:00
|
|
|
// Downloading from 2 of 3 peer(s)
|
2012-10-07 16:33:55 +00:00
|
|
|
return [ 'Downloading from',
|
|
|
|
t.getPeersSendingToUs(),
|
|
|
|
'of',
|
2012-10-25 03:56:57 +00:00
|
|
|
fmt.countString('peer','peers',peer_count),
|
|
|
|
'-',
|
|
|
|
TorrentRendererHelper.formatDL(t),
|
|
|
|
TorrentRendererHelper.formatUL(t) ].join(' ');
|
2012-10-07 16:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (t.isSeeding())
|
2011-08-16 18:49:26 +00:00
|
|
|
return [ 'Seeding to',
|
2011-08-20 21:17:12 +00:00
|
|
|
t.getPeersGettingFromUs(),
|
2011-08-16 18:49:26 +00:00
|
|
|
'of',
|
2012-10-07 18:10:26 +00:00
|
|
|
fmt.countString ('peer','peers',t.getPeersConnected()),
|
2011-08-16 18:49:26 +00:00
|
|
|
'-',
|
|
|
|
TorrentRendererHelper.formatUL(t) ].join(' ');
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (t.isChecking())
|
2011-08-16 18:49:26 +00:00
|
|
|
return [ 'Verifying local data (',
|
2011-08-24 02:04:35 +00:00
|
|
|
Transmission.fmt.percentString(100.0 * t.getRecheckProgress()),
|
2011-08-16 18:49:26 +00:00
|
|
|
'% tested)' ].join('');
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
return t.getStateString();
|
2011-08-16 18:49:26 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getProgressDetails: function(controller, t)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
if (t.needsMetaData()) {
|
2014-01-20 22:32:20 +00:00
|
|
|
var MetaDataStatus = "retrieving";
|
|
|
|
if (t.isStopped())
|
|
|
|
MetaDataStatus = "needs";
|
2011-08-20 21:17:12 +00:00
|
|
|
var percent = 100 * t.getMetadataPercentComplete();
|
2014-01-20 22:32:20 +00:00
|
|
|
return [ "Magnetized transfer - " + MetaDataStatus + " metadata (",
|
2011-08-24 02:04:35 +00:00
|
|
|
Transmission.fmt.percentString(percent),
|
2011-08-16 18:49:26 +00:00
|
|
|
"%)" ].join('');
|
|
|
|
}
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
var c,
|
|
|
|
sizeWhenDone = t.getSizeWhenDone(),
|
|
|
|
totalSize = t.getTotalSize(),
|
|
|
|
is_done = t.isDone() || t.isSeeding();
|
2011-08-20 21:17:12 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (is_done) {
|
2011-09-05 07:46:55 +00:00
|
|
|
if (totalSize === sizeWhenDone) // seed: '698.05 MiB'
|
2011-08-24 02:04:35 +00:00
|
|
|
c = [ Transmission.fmt.size(totalSize) ];
|
2011-08-16 18:49:26 +00:00
|
|
|
else // partial seed: '127.21 MiB of 698.05 MiB (18.2%)'
|
2011-08-24 02:04:35 +00:00
|
|
|
c = [ Transmission.fmt.size(sizeWhenDone),
|
2011-08-16 18:49:26 +00:00
|
|
|
' of ',
|
2011-08-24 02:04:35 +00:00
|
|
|
Transmission.fmt.size(t.getTotalSize()),
|
2011-08-23 15:32:52 +00:00
|
|
|
' (', t.getPercentDoneStr(), '%)' ];
|
2011-08-16 18:49:26 +00:00
|
|
|
// append UL stats: ', uploaded 8.59 GiB (Ratio: 12.3)'
|
2011-08-24 02:04:35 +00:00
|
|
|
c.push(', uploaded ',
|
2015-05-05 19:12:48 +00:00
|
|
|
Transmission.fmt.size(t.getUploadedEver()),
|
|
|
|
' (Ratio ',
|
|
|
|
Transmission.fmt.ratioString(t.getUploadRatio()),
|
|
|
|
')');
|
2011-08-16 18:49:26 +00:00
|
|
|
} else { // not done yet
|
2011-08-24 02:04:35 +00:00
|
|
|
c = [ Transmission.fmt.size(sizeWhenDone - t.getLeftUntilDone()),
|
|
|
|
' of ', Transmission.fmt.size(sizeWhenDone),
|
2011-08-16 18:49:26 +00:00
|
|
|
' (', t.getPercentDoneStr(), '%)' ];
|
|
|
|
}
|
|
|
|
|
|
|
|
// maybe append eta
|
2011-08-24 02:04:35 +00:00
|
|
|
if (!t.isStopped() && (!is_done || t.seedRatioLimit(controller)>0)) {
|
2011-08-16 18:49:26 +00:00
|
|
|
c.push(' - ');
|
2011-08-24 02:04:35 +00:00
|
|
|
var eta = t.getETA();
|
|
|
|
if (eta < 0 || eta >= (999*60*60) /* arbitrary */)
|
|
|
|
c.push('remaining time unknown');
|
2011-08-16 18:49:26 +00:00
|
|
|
else
|
2011-08-24 02:04:35 +00:00
|
|
|
c.push(Transmission.fmt.timeInterval(t.getETA()),
|
2015-05-05 19:12:48 +00:00
|
|
|
' remaining');
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return c.join('');
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
render: function(controller, t, root)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
|
|
|
// name
|
2012-07-20 17:37:50 +00:00
|
|
|
setTextContent(root._name_container, t.getName());
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
// progressbar
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.renderProgressbar(controller, t, root._progressbar);
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
// peer details
|
2011-08-20 21:17:12 +00:00
|
|
|
var has_error = t.getError() !== Torrent._ErrNone;
|
2011-08-16 18:49:26 +00:00
|
|
|
var e = root._peer_details_container;
|
|
|
|
$(e).toggleClass('error',has_error);
|
2012-07-20 17:37:50 +00:00
|
|
|
setTextContent(e, this.getPeerDetails(t));
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
// progress details
|
|
|
|
e = root._progress_details_container;
|
2012-07-20 17:37:50 +00:00
|
|
|
setTextContent(e, this.getProgressDetails(controller, t));
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
// pause/resume button
|
2011-08-24 02:04:35 +00:00
|
|
|
var is_stopped = t.isStopped();
|
|
|
|
e = root._pause_resume_button_image;
|
|
|
|
e.alt = is_stopped ? 'Resume' : 'Pause';
|
|
|
|
e.className = is_stopped ? 'torrent_resume' : 'torrent_pause';
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/****
|
|
|
|
*****
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
|
|
|
function TorrentRendererCompact()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TorrentRendererCompact.prototype =
|
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
createRow: function()
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2011-09-03 05:12:14 +00:00
|
|
|
var progressbar, details, name, root;
|
2011-08-28 13:57:25 +00:00
|
|
|
|
|
|
|
progressbar = TorrentRendererHelper.createProgressbar('compact');
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
details = document.createElement('div');
|
2011-08-16 18:49:26 +00:00
|
|
|
details.className = 'torrent_peer_details compact';
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
name = document.createElement('div');
|
2011-08-23 15:32:52 +00:00
|
|
|
name.className = 'torrent_name compact';
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
root = document.createElement('li');
|
2011-08-24 02:04:35 +00:00
|
|
|
root.appendChild(progressbar.element);
|
|
|
|
root.appendChild(details);
|
|
|
|
root.appendChild(name);
|
2011-08-16 18:49:26 +00:00
|
|
|
root.className = 'torrent compact';
|
2011-08-20 15:31:34 +00:00
|
|
|
root._progressbar = progressbar;
|
2011-08-16 18:49:26 +00:00
|
|
|
root._details_container = details;
|
|
|
|
root._name_container = name;
|
|
|
|
return root;
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getPeerDetails: function(t)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
|
|
|
var c;
|
2011-08-24 02:04:35 +00:00
|
|
|
if ((c = t.getErrorMessage()))
|
2011-08-16 18:49:26 +00:00
|
|
|
return c;
|
2011-08-25 06:18:42 +00:00
|
|
|
if (t.isDownloading()) {
|
2011-08-28 13:57:25 +00:00
|
|
|
var have_dn = t.getDownloadSpeed() > 0,
|
|
|
|
have_up = t.getUploadSpeed() > 0;
|
2011-08-25 06:18:42 +00:00
|
|
|
if (!have_up && !have_dn)
|
|
|
|
return 'Idle';
|
|
|
|
var s = '';
|
|
|
|
if (have_dn)
|
|
|
|
s += TorrentRendererHelper.formatDL(t);
|
|
|
|
if (have_dn && have_up)
|
|
|
|
s += ' '
|
|
|
|
if (have_up)
|
|
|
|
s += TorrentRendererHelper.formatUL(t);
|
|
|
|
return s;
|
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
if (t.isSeeding())
|
2011-08-24 19:20:59 +00:00
|
|
|
return [ 'Ratio: ',
|
|
|
|
Transmission.fmt.ratioString(t.getUploadRatio()),
|
|
|
|
', ',
|
|
|
|
TorrentRendererHelper.formatUL(t) ].join('');
|
2011-08-24 02:04:35 +00:00
|
|
|
return t.getStateString();
|
2011-08-16 18:49:26 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
render: function(controller, t, root)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
|
|
|
// name
|
2011-08-24 02:04:35 +00:00
|
|
|
var is_stopped = t.isStopped();
|
2011-08-16 18:49:26 +00:00
|
|
|
var e = root._name_container;
|
2011-08-24 02:04:35 +00:00
|
|
|
$(e).toggleClass('paused', is_stopped);
|
2012-07-20 17:37:50 +00:00
|
|
|
setTextContent(e, t.getName());
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
// peer details
|
2011-08-20 21:17:12 +00:00
|
|
|
var has_error = t.getError() !== Torrent._ErrNone;
|
2011-08-16 18:49:26 +00:00
|
|
|
e = root._details_container;
|
2011-08-24 02:04:35 +00:00
|
|
|
$(e).toggleClass('error', has_error);
|
2012-07-20 17:37:50 +00:00
|
|
|
setTextContent(e, this.getPeerDetails(t));
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
// progressbar
|
2011-08-24 02:04:35 +00:00
|
|
|
TorrentRendererHelper.renderProgressbar(controller, t, root._progressbar);
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/****
|
|
|
|
*****
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
2011-08-30 21:27:30 +00:00
|
|
|
function TorrentRow(view, controller, torrent)
|
2011-08-16 18:49:26 +00:00
|
|
|
{
|
2011-08-30 21:27:30 +00:00
|
|
|
this.initialize(view, controller, torrent);
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
|
|
|
TorrentRow.prototype =
|
|
|
|
{
|
2011-08-30 21:27:30 +00:00
|
|
|
initialize: function(view, controller, torrent) {
|
2011-08-31 04:37:49 +00:00
|
|
|
var row = this;
|
2011-08-20 15:31:34 +00:00
|
|
|
this._view = view;
|
2011-08-31 04:37:49 +00:00
|
|
|
this._torrent = torrent;
|
2011-08-24 02:04:35 +00:00
|
|
|
this._element = view.createRow();
|
|
|
|
this.render(controller);
|
2011-08-31 04:37:49 +00:00
|
|
|
$(this._torrent).bind('dataChanged.torrentRowListener',function(){row.render(controller);});
|
2011-08-16 18:49:26 +00:00
|
|
|
|
|
|
|
},
|
2011-08-24 02:04:35 +00:00
|
|
|
getElement: function() {
|
2011-08-16 18:49:26 +00:00
|
|
|
return this._element;
|
|
|
|
},
|
2011-08-24 02:04:35 +00:00
|
|
|
render: function(controller) {
|
|
|
|
var tor = this.getTorrent();
|
|
|
|
if (tor)
|
|
|
|
this._view.render(controller, tor, this.getElement());
|
2011-08-16 18:49:26 +00:00
|
|
|
},
|
2011-08-24 02:04:35 +00:00
|
|
|
isSelected: function() {
|
|
|
|
return this.getElement().className.indexOf('selected') !== -1;
|
2011-08-16 18:49:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getTorrent: function() {
|
|
|
|
return this._torrent;
|
|
|
|
},
|
2011-08-26 00:43:35 +00:00
|
|
|
getTorrentId: function() {
|
|
|
|
return this.getTorrent().getId();
|
2011-10-15 04:35:20 +00:00
|
|
|
}
|
2011-08-16 18:49:26 +00:00
|
|
|
};
|