diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-18 19:04:48 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-18 19:04:48 +0100 |
commit | 5d32c05eb764beed8a84dec1e91e0f8a8060899d (patch) | |
tree | d4d71b48908c097bde2a3ec9c7c2b80d54b5eccd /module/web/static/js/models | |
parent | render download progress (diff) | |
download | pyload-5d32c05eb764beed8a84dec1e91e0f8a8060899d.tar.xz |
added ReadWrite lock, render file progress on dashboard
Diffstat (limited to 'module/web/static/js/models')
-rw-r--r-- | module/web/static/js/models/File.js | 3 | ||||
-rw-r--r-- | module/web/static/js/models/Progress.js | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/module/web/static/js/models/File.js b/module/web/static/js/models/File.js index 2ac6c05f5..22ff231cc 100644 --- a/module/web/static/js/models/File.js +++ b/module/web/static/js/models/File.js @@ -22,7 +22,8 @@ define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backb // UI attributes selected: false, - visible: true + visible: true, + progress: 0 }, diff --git a/module/web/static/js/models/Progress.js b/module/web/static/js/models/Progress.js index c6a2fc4d1..d2d54bdb4 100644 --- a/module/web/static/js/models/Progress.js +++ b/module/web/static/js/models/Progress.js @@ -16,6 +16,12 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { download: null }, + getPercent: function() { + if (this.get('total') > 0) + return Math.round(this.get('done') * 100 / this.get('total')); + return 0; + }, + // Model Constructor initialize: function() { @@ -28,10 +34,7 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { toJSON: function(options) { var obj = Backbone.Model.prototype.toJSON.call(this, options); - if (obj.total > 0) - obj.percent = Math.round(obj.done * 100 / obj.total); - else - obj.percent = 0; + obj.percent = this.getPercent(); return obj; }, |