From ef0a09ceb334f1d1f05ad790e570ef0cdaaa3c52 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 4 Mar 2013 13:03:25 +0100 Subject: functions to render file status, only simple coloring for now --- module/web/static/js/models/File.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'module/web/static/js/models/File.js') diff --git a/module/web/static/js/models/File.js b/module/web/static/js/models/File.js index e965df9df..42275a452 100644 --- a/module/web/static/js/models/File.js +++ b/module/web/static/js/models/File.js @@ -1,4 +1,8 @@ -define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { +define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backbone, _, Api) { + + var Finished = [Api.DownloadStatus.Finished, Api.DownloadStatus.Skipped]; + var Failed = [Api.DownloadStatus.Failed, Api.DownloadStatus.Aborted, Api.DownloadStatus.TempOffline, Api.DownloadStatus.Offline]; + // Unfinished - Other return Backbone.Model.extend({ @@ -45,6 +49,18 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { isDownload : function() { return this.has('download'); + }, + + isFinished: function() { + return _.indexOf(Finished, this.get('download').status) > -1; + }, + + isUnfinished: function() { + return _.indexOf(Finished, this.get('download').status) === -1 && _.indexOf(Failed, this.get('download').status) === -1; + }, + + isFailed: function() { + return _.indexOf(Failed, this.get('download').status) > -1; } }); -- cgit v1.2.3