diff options
Diffstat (limited to 'pyload/web/app/scripts/collections')
| -rw-r--r-- | pyload/web/app/scripts/collections/AccountList.js | 24 | ||||
| -rw-r--r-- | pyload/web/app/scripts/collections/FileList.js | 28 | ||||
| -rw-r--r-- | pyload/web/app/scripts/collections/InteractionList.js | 49 | ||||
| -rw-r--r-- | pyload/web/app/scripts/collections/PackageList.js | 16 | ||||
| -rw-r--r-- | pyload/web/app/scripts/collections/ProgressList.js | 18 | 
5 files changed, 135 insertions, 0 deletions
| diff --git a/pyload/web/app/scripts/collections/AccountList.js b/pyload/web/app/scripts/collections/AccountList.js new file mode 100644 index 000000000..bfc2af5a3 --- /dev/null +++ b/pyload/web/app/scripts/collections/AccountList.js @@ -0,0 +1,24 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'models/Account'], function($, Backbone, _, App, Account) { +    'use strict'; + +    return Backbone.Collection.extend({ + +        model: Account, + +        comparator: function(account) { +            return account.get('plugin'); +        }, + +        initialize: function() { + +        }, + +        fetch: function(options) { +            // TODO: refresh options? +            options = App.apiRequest('getAccounts/false', null, options); +            return Backbone.Collection.prototype.fetch.call(this, options); +        } + +    }); + +});
\ No newline at end of file diff --git a/pyload/web/app/scripts/collections/FileList.js b/pyload/web/app/scripts/collections/FileList.js new file mode 100644 index 000000000..112dc5e51 --- /dev/null +++ b/pyload/web/app/scripts/collections/FileList.js @@ -0,0 +1,28 @@ +define(['jquery', 'backbone', 'underscore', 'models/File'], function($, Backbone, _, File) { +    'use strict'; + +    return Backbone.Collection.extend({ + +        model: File, + +        comparator: function(file) { +            return file.get('fileorder'); +        }, + +        isEqual: function(fileList) { +            if (this.length !== fileList.length) return false; + +            // Assuming same order would be faster in false case +            var diff = _.difference(this.models, fileList.models); + +            // If there is a difference models are unequal +            return diff.length > 0; +        }, + +        initialize: function() { + +        } + +    }); + +});
\ No newline at end of file diff --git a/pyload/web/app/scripts/collections/InteractionList.js b/pyload/web/app/scripts/collections/InteractionList.js new file mode 100644 index 000000000..24f8b9248 --- /dev/null +++ b/pyload/web/app/scripts/collections/InteractionList.js @@ -0,0 +1,49 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'models/InteractionTask'], +    function($, Backbone, _, App, InteractionTask) { +        'use strict'; + +        return Backbone.Collection.extend({ + +            model: InteractionTask, + +            comparator: function(task) { +                return task.get('iid'); +            }, + +            fetch: function(options) { +                options = App.apiRequest('getInteractionTasks/0', null, options); +                var self = this; +                options.success = function(data) { +                    self.set(data); +                }; + +                return $.ajax(options); +            }, + +            toJSON: function() { +                var data = {queries: 0, notifications: 0}; + +                this.map(function(task) { +                    if (task.isNotification()) +                        data.notifications++; +                    else +                        data.queries++; +                }); + +                return data; +            }, + +            // a task is waiting for attention (no notification) +            hasTaskWaiting: function() { +                var tasks = 0; +                this.map(function(task) { +                    if (!task.isNotification()) +                        tasks++; +                }); + +                return tasks > 0; +            } + +        }); + +    });
\ No newline at end of file diff --git a/pyload/web/app/scripts/collections/PackageList.js b/pyload/web/app/scripts/collections/PackageList.js new file mode 100644 index 000000000..7bee861a4 --- /dev/null +++ b/pyload/web/app/scripts/collections/PackageList.js @@ -0,0 +1,16 @@ +define(['jquery', 'backbone', 'underscore', 'models/Package'], function($, Backbone, _, Package) { +    'use strict'; + +    return Backbone.Collection.extend({ + +        model: Package, + +        comparator: function(pack) { +            return pack.get('packageorder'); +        }, + +        initialize: function() { +        } + +    }); +});
\ No newline at end of file diff --git a/pyload/web/app/scripts/collections/ProgressList.js b/pyload/web/app/scripts/collections/ProgressList.js new file mode 100644 index 000000000..51849d8de --- /dev/null +++ b/pyload/web/app/scripts/collections/ProgressList.js @@ -0,0 +1,18 @@ +define(['jquery', 'backbone', 'underscore', 'models/Progress'], function($, Backbone, _, Progress) { +    'use strict'; + +    return Backbone.Collection.extend({ + +        model: Progress, + +        comparator: function(progress) { +            return progress.get('eta'); +        }, + +        initialize: function() { + +        } + +    }); + +});
\ No newline at end of file | 
