Browse Source

Also pass number of downloaded/total bytes to "downloadedChunk" event.

pull/70/head
Joachim Bauch 11 years ago
parent
commit
e8f8240e92
  1. 5
      static/js/services/filedownload.js

5
static/js/services/filedownload.js

@ -40,6 +40,8 @@ define(["jquery", "underscore"], function($, _) {
this.end = scope.info.chunks - 1; this.end = scope.info.chunks - 1;
this.fragments = 100; this.fragments = 100;
this.concurrent = 5; this.concurrent = 5;
this.downloadedBytes = 0;
this.totalBytes = scope.info.size;
this.jobs = []; this.jobs = [];
this.xfer_all = []; this.xfer_all = [];
@ -212,7 +214,8 @@ define(["jquery", "underscore"], function($, _) {
var byte_position = file.scope.chunk_size * idx; var byte_position = file.scope.chunk_size * idx;
file.setChunk(idx, byte_position, data); file.setChunk(idx, byte_position, data);
safeApply(this.scope, _.bind(function($scope) { safeApply(this.scope, _.bind(function($scope) {
$scope.$emit("downloadedChunk", idx, data.byteLength); this.downloadedBytes += data.byteLength;
$scope.$emit("downloadedChunk", idx, data.byteLength, this.downloadedBytes, this.totalBytes);
job.next(); job.next();
}, this)); }, this));
}, this)); }, this));

Loading…
Cancel
Save