summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/models/Progress.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 18:15:36 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 18:15:36 +0100
commitd2b45c5442aeb0e02f251916ae1beb06830ef4c1 (patch)
treeb5587ad618f0780c7e7443195cda652d9a2eadbb /module/web/static/js/models/Progress.js
parentrenamed most events, push events to webui (diff)
downloadpyload-d2b45c5442aeb0e02f251916ae1beb06830ef4c1.tar.xz
render download progress
Diffstat (limited to 'module/web/static/js/models/Progress.js')
-rw-r--r--module/web/static/js/models/Progress.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/module/web/static/js/models/Progress.js b/module/web/static/js/models/Progress.js
index ebbe34862..c6a2fc4d1 100644
--- a/module/web/static/js/models/Progress.js
+++ b/module/web/static/js/models/Progress.js
@@ -2,10 +2,11 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
return Backbone.Model.extend({
-// TODO
-// idAttribute: 'fid',
+ // generated, not submitted
+ idAttribute: 'pid',
defaults: {
+ pid: -1,
plugin: null,
name: null,
statusmsg: -1,
@@ -15,7 +16,6 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
download: null
},
-
// Model Constructor
initialize: function() {
@@ -26,8 +26,18 @@ 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;
+
+ return obj;
+ },
+
isDownload : function() {
- return this.has('download')
+ return this.has('download');
}
});