diff options
Diffstat (limited to 'pyload/web/app/scripts')
-rw-r--r-- | pyload/web/app/scripts/collections/ProgressList.js | 8 | ||||
-rw-r--r-- | pyload/web/app/scripts/default.js | 6 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/headerView.js | 16 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/modalView.js | 22 |
4 files changed, 38 insertions, 14 deletions
diff --git a/pyload/web/app/scripts/collections/ProgressList.js b/pyload/web/app/scripts/collections/ProgressList.js index 51849d8de..51132d86d 100644 --- a/pyload/web/app/scripts/collections/ProgressList.js +++ b/pyload/web/app/scripts/collections/ProgressList.js @@ -11,6 +11,14 @@ define(['jquery', 'backbone', 'underscore', 'models/Progress'], function($, Back initialize: function() { + }, + + // returns all progresses, that bit matches the given type + // types have to be or'ed + byType: function(types) { + return this.filter(function(progress) { + return (progress.get('type') & types) !== 0; + }); } }); diff --git a/pyload/web/app/scripts/default.js b/pyload/web/app/scripts/default.js index d66c0e1f8..8a8d122f8 100644 --- a/pyload/web/app/scripts/default.js +++ b/pyload/web/app/scripts/default.js @@ -1,6 +1,6 @@ define('default', ['require', 'backbone', 'jquery', 'app', 'router', - 'models/UserSession', 'models/AddonHandler'], - function(require, Backbone, $, App, Router, UserSession, AddonHandler) { + 'models/UserSession', 'models/AddonHandler', 'collections/ProgressList'], + function(require, Backbone, $, App, Router, UserSession, AddonHandler, ProgressList) { 'use strict'; // Global ajax options @@ -21,7 +21,9 @@ define('default', ['require', 'backbone', 'jquery', 'app', 'router', return Backbone.$.ajax.apply(Backbone.$, arguments); }; + // global available models / collections App.addons = new AddonHandler(); + App.progressList = new ProgressList(); $(function() { // load setup async diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js index 7d892bf01..d4d07ac39 100644 --- a/pyload/web/app/scripts/views/headerView.js +++ b/pyload/web/app/scripts/views/headerView.js @@ -1,8 +1,8 @@ -define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'collections/ProgressList', +define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'views/progressView', 'views/notificationView', 'helpers/formatSize', 'hbs!tpl/header/layout', 'hbs!tpl/header/status', 'hbs!tpl/header/progressbar', 'hbs!tpl/header/progressSup', 'hbs!tpl/header/progressSub' , 'flot'], function( - $, _, Backbone, App, ServerStatus, ProgressList, ProgressView, NotificationView, formatSize, template, templateStatus, templateProgress, templateSup, templateSub) { + $, _, Backbone, App, ServerStatus, ProgressView, NotificationView, formatSize, template, templateStatus, templateProgress, templateSup, templateSub) { 'use strict'; // Renders the header with all information return Backbone.Marionette.ItemView.extend({ @@ -32,7 +32,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle // models and data ws: null, status: null, - progressList: null, speeds: null, // sub view @@ -51,8 +50,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle this.status = new ServerStatus(); this.listenTo(this.status, 'change', this.update); - this.progressList = new ProgressList(); - this.listenTo(this.progressList, 'add', function(model) { + this.listenTo(App.progressList, 'add', function(model) { self.ui.progress.appendWithAnimation(new ProgressView({model: model}).render().el); }); @@ -140,7 +138,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle ); var data = {tasks: 0, downloads: 0, speed: 0, single: false}; - this.progressList.each(function(progress) { + App.progressList.each(function(progress) { if (progress.isDownload()) { data.downloads++; data.speed += progress.get('download').speed; @@ -150,7 +148,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle // Show progress of one task if (data.tasks + data.downloads === 1) { - var progress = this.progressList.at(0); + var progress = App.progressList.at(0); data.single = true; data.eta = progress.get('eta'); data.percent = progress.getPercent(); @@ -233,9 +231,9 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle prog.pid = prog.plugin + prog.name; }); - this.progressList.set(progress); + App.progressList.set(progress); // update currently open files with progress - this.progressList.each(function(prog) { + App.progressList.each(function(prog) { if (prog.isDownload() && App.dashboard.files) { var file = App.dashboard.files.get(prog.get('download').fid); if (file) { diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js index 950c0ce2f..9bdb7f4e2 100644 --- a/pyload/web/app/scripts/views/linkgrabber/modalView.js +++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js @@ -1,5 +1,5 @@ -define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'views/abstract/modalView', './collectorView', 'hbs!tpl/linkgrabber/modal'], - function($, _, Backbone, App, CollectorPackage, modalView, CollectorView, template) { +define(['jquery', 'underscore', 'backbone', 'app', 'utils/apitypes', 'models/CollectorPackage', 'views/abstract/modalView', './collectorView', 'hbs!tpl/linkgrabber/modal'], + function($, _, Backbone, App, Api, CollectorPackage, modalView, CollectorView, template) { 'use strict'; // Modal dialog for package adding - triggers package:added when package was added return modalView.extend({ @@ -24,6 +24,11 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v // Inherit parent events this.events = _.extend({}, modalView.prototype.events, this.events); this.listenTo(App.vent, 'collectorPackage:added', _.bind(this.onAdded, this)); + + var update = _.bind(this.onProgressChange, this); + this.listenTo(App.progressList, 'add', update); + this.listenTo(App.progressList, 'remove', update); + this.listenTo(App.progressList, 'change', update); }, // sets a new models as target and render @@ -123,7 +128,18 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v onDestroy: function() { if (this.collectorView) this.collectorView.close(); - } + }, + onProgressChange: function() { + var progress = App.progressList.byType(Api.ProgressType.LinkCheck | Api.ProgressType.Decrypting); + if (progress.length > 0) { + // show indicator + this.$('.status-text').html(progress[0].get('statusmsg')); + this.$('.status').fadeIn(); + } else { + // hide indicator + this.$('.status').fadeOut(); + } + } }); });
\ No newline at end of file |