1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-29 00:02:28 +01:00

Only include active downloads in :downloads totals. Closes issue #726.

This commit is contained in:
Kris Maglione
2011-12-05 17:17:59 -05:00
parent 0b03a64e70
commit 482c072068
2 changed files with 14 additions and 7 deletions

View File

@@ -385,8 +385,13 @@ var DOM = Class("DOM", {
return;
this[0] instanceof Ci.nsIDOMNSEditableElement;
if (this[0].editor instanceof Ci.nsIEditor)
var editor = this[0].editor;
try {
if (this[0].editor instanceof Ci.nsIEditor)
var editor = this[0].editor;
}
catch (e) {
util.reportError(e);
}
try {
if (!editor)

View File

@@ -170,7 +170,8 @@ var Download = Class("Download", {
}
}
let total = this.nodes.progressTotal.textContent = this.size ? util.formatBytes(this.size, 1, true) : _("download.unknown");
let total = this.nodes.progressTotal.textContent = this.size || !this.nActive ? util.formatBytes(this.size, 1, true)
: _("download.unknown");
let suffix = RegExp(/( [a-z]+)?$/i.exec(total)[0] + "$");
this.nodes.progressHave.textContent = util.formatBytes(this.amountTransferred, 1, true).replace(suffix, "");
@@ -322,16 +323,17 @@ var DownloadList = Class("DownloadList",
updateProgress: function updateProgress() {
let downloads = values(this.downloads).toArray();
let active = downloads.filter(function (d) d.alive);
let self = Object.create(this);
for (let prop in values(["amountTransferred", "size", "speed", "timeRemaining"]))
this[prop] = downloads.reduce(function (acc, dl) dl[prop] + acc, 0);
this[prop] = active.reduce(function (acc, dl) dl[prop] + acc, 0);
Download.prototype.updateProgress.call(self);
let active = downloads.filter(function (dl) dl.alive).length;
if (active)
this.nodes.total.textContent = _("download.nActive", active);
this.nActive = active.length;
if (active.length)
this.nodes.total.textContent = _("download.nActive", active.length);
else for (let key in values(["total", "percent", "speed", "time"]))
this.nodes[key].textContent = "";