diff --git a/common/modules/downloads.jsm b/common/modules/downloads.jsm
index b1a2ea38..a7ee8ed8 100644
--- a/common/modules/downloads.jsm
+++ b/common/modules/downloads.jsm
@@ -190,15 +190,18 @@ var DownloadList = Class("DownloadList",
Source
-
- Totals:
+
+ Totals:
Clear
-
-
-
+
+ /
+
+
+
, this.document, this.nodes);
@@ -253,6 +256,25 @@ var DownloadList = Class("DownloadList",
for (let node in values(this.nodes))
if (node.update && node.update != update)
node.update();
+ this.updateProgress();
+ },
+
+ timeRemaining: Infinity,
+
+ updateProgress: function updateProgress() {
+ let downloads = values(this.downloads).toArray();
+
+ 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);
+
+ Download.prototype.updateProgress.call(self);
+
+ let active = downloads.filter(function (dl) dl.alive).length;
+ if (active)
+ this.nodes.total.textContent = active + " active";
+ else for (let key in values(["total", "percent", "time"]))
+ this.nodes[key].textContent = "";
},
observers: {
@@ -290,6 +312,7 @@ var DownloadList = Class("DownloadList",
try {
if (download.id in this.downloads)
this.downloads[download.id].updateProgress();
+ this.updateProgress();
}
catch (e) {
util.reportError(e);
diff --git a/common/modules/util.jsm b/common/modules/util.jsm
index a58a116e..7ee979c8 100644
--- a/common/modules/util.jsm
+++ b/common/modules/util.jsm
@@ -672,6 +672,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @returns {string}
*/
formatSeconds: function formatSeconds(seconds) {
+ function pad(n, val) ("0000000" + val).substr(-Math.max(n, String(val).length));
function div(num, denom) [Math.round(num / denom), Math.round(num % denom)];
let days, hours, minutes;
@@ -683,7 +684,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (hours)
return hours + "h " + minutes + "m";
if (minutes)
- return minutes + ":" + seconds;
+ return minutes + ":" + pad(2, seconds);
return seconds + "s";
},