summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/models/ServerStatus.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 12:49:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 12:49:42 +0100
commit6232db5a1d3b8b5e4412af67d5bc7ca65f94333c (patch)
tree02a95e1216ace355d84a9704fb9070bd744b17c2 /module/web/static/js/models/ServerStatus.js
parentadded missing file (diff)
downloadpyload-6232db5a1d3b8b5e4412af67d5bc7ca65f94333c.tar.xz
renamed most events, push events to webui
Diffstat (limited to 'module/web/static/js/models/ServerStatus.js')
-rw-r--r--module/web/static/js/models/ServerStatus.js81
1 files changed, 40 insertions, 41 deletions
diff --git a/module/web/static/js/models/ServerStatus.js b/module/web/static/js/models/ServerStatus.js
index 2430a9ffd..9242bdf95 100644
--- a/module/web/static/js/models/ServerStatus.js
+++ b/module/web/static/js/models/ServerStatus.js
@@ -1,47 +1,46 @@
define(['jquery', 'backbone', 'underscore'],
function($, Backbone, _) {
- return Backbone.Model.extend({
+ 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;
- defaults: {
- speed: 0,
- files: null,
- 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);
-
- // stats are not available
- if (obj.files === null)
return obj;
+ }
- obj.files.linksleft = obj.files.linkstotal - obj.files.linksdone;
- obj.files.sizeleft = obj.files.sizetotal - obj.files.sizedone;
- if (obj.speed && obj.speed > 0)
- obj.files.eta = Math.round(obj.files.sizeleft / obj.speed);
- else if (obj.files.sizeleft > 0)
- obj.files.eta = Infinity;
- else
- obj.files.eta = 0;
-
- return obj;
- }
-
- });
-}); \ No newline at end of file
+ });
+ }); \ No newline at end of file