diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-12-01 21:06:17 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-12-01 21:06:17 +0100 |
commit | fdb98aba01a9cbf415526d796a24d372fd00419a (patch) | |
tree | da9c9c3138d727bc282ca2db618dc4b56ec62f30 /pyload/web/app/scripts/models | |
parent | fixed are few addons and improved crypter workarounds (diff) | |
download | pyload-fdb98aba01a9cbf415526d796a24d372fd00419a.tar.xz |
fixed cnl, packages now pausable
Diffstat (limited to 'pyload/web/app/scripts/models')
-rw-r--r-- | pyload/web/app/scripts/models/Package.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pyload/web/app/scripts/models/Package.js b/pyload/web/app/scripts/models/Package.js index a34ec1c69..555d5b7d6 100644 --- a/pyload/web/app/scripts/models/Package.js +++ b/pyload/web/app/scripts/models/Package.js @@ -1,5 +1,5 @@ -define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'require'], - function($, Backbone, _, App, FileList, require) { +define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collections/FileList', 'require'], + function($, Backbone, _, App, Api, FileList, require) { 'use strict'; return Backbone.Model.extend({ @@ -36,6 +36,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'requ toJSON: function(options) { var obj = Backbone.Model.prototype.toJSON.call(this, options); obj.percent = Math.round(obj.stats.linksdone * 100 / obj.stats.linkstotal); + obj.paused = obj.status === Api.PackageStatus.Paused; return obj; }, @@ -64,6 +65,21 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'requ // TODO }, + togglePaused: function() { + var self = this; + var paused = this.get('status') === Api.PackageStatus.Paused; + + $.ajax(App.apiRequest('setPackagePaused', { + pid: this.get('pid'), + paused: !paused + }, { + success: function(data) { + console.log('New package status', data); + self.set('status', data); + } + })); + }, + destroy: function(options) { // TODO: Not working when using data?, array seems to break it options = App.apiRequest( |