Merge pull request #34 from feross/progress
improve progress percent & bytes display
This commit is contained in:
@@ -45,23 +45,18 @@ function renderTorrent (torrent, dispatch) {
|
||||
|
||||
// Renders the torrent name and download progress
|
||||
function renderTorrentMetadata (torrent) {
|
||||
var progressPercent = 0
|
||||
var progressBytes = 0
|
||||
var progress = Math.floor(100 * (torrent.progress || 0))
|
||||
var downloaded = prettyBytes(torrent.downloaded || 0)
|
||||
var total = prettyBytes(torrent.length || 0)
|
||||
|
||||
if (torrent.progress) {
|
||||
progressPercent = Math.floor(100 * torrent.progress)
|
||||
}
|
||||
|
||||
if (torrent.length && torrent.progress) {
|
||||
progressBytes = torrent.length * torrent.progress
|
||||
}
|
||||
if (downloaded !== total) downloaded += ` / ${total}`
|
||||
|
||||
return hx`
|
||||
<div class="metadata">
|
||||
<div class="name ellipsis">${torrent.name || 'Loading torrent...'}</div>
|
||||
<div class="status">
|
||||
<span class="progress">${progressPercent}%</span>
|
||||
<span>${prettyBytes(progressBytes)} / ${prettyBytes(torrent.length || 0)}</span>
|
||||
<span class="progress">${progress}%</span>
|
||||
<span>${downloaded}</span>
|
||||
</div>
|
||||
${getFilesLength()}
|
||||
<span>${getPeers()}</span>
|
||||
|
||||
Reference in New Issue
Block a user