diff options
author | 2013-06-08 17:37:43 +0200 | |
---|---|---|
committer | 2013-06-08 17:37:44 +0200 | |
commit | 2cf160d497e501bf254bd8be054c0f5880ab90ca (patch) | |
tree | 03a720b6142cc03fe7ef258fa8d17da92b30a462 /module/web/app/scripts/models/ServerStatus.js | |
parent | Merge pull request #151 from vuolter/invertedconf (diff) | |
download | pyload-2cf160d497e501bf254bd8be054c0f5880ab90ca.tar.xz |
restructured webui to single-page-app, removed jinja
Diffstat (limited to 'module/web/app/scripts/models/ServerStatus.js')
-rw-r--r-- | module/web/app/scripts/models/ServerStatus.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/module/web/app/scripts/models/ServerStatus.js b/module/web/app/scripts/models/ServerStatus.js new file mode 100644 index 000000000..9242bdf95 --- /dev/null +++ b/module/web/app/scripts/models/ServerStatus.js @@ -0,0 +1,46 @@ +define(['jquery', 'backbone', 'underscore'], + function($, Backbone, _) { + + return Backbone.Model.extend({ + + defaults: { + speed: 0, + linkstotal: 0, + linksqueue: 0, + sizetotal: 0, + sizequeue: 0, + notifications: -1, + paused: false, + download: false, + reconnect: false + }, + + // Model Constructor + initialize: function() { + + }, + + fetch: function() { + options || (options = {}); + options.url = 'api/getServerStatus'; + + return Backbone.Model.prototype.fetch.call(this, options); + }, + + toJSON: function(options) { + var obj = Backbone.Model.prototype.toJSON.call(this, options); + + obj.linksdone = obj.linkstotal - obj.linksqueue; + obj.sizedone = obj.sizetotal - obj.sizequeue; + if (obj.speed && obj.speed > 0) + obj.eta = Math.round(obj.sizequeue / obj.speed); + else if (obj.sizequeue > 0) + obj.eta = Infinity; + else + obj.eta = 0; + + return obj; + } + + }); + });
\ No newline at end of file |