diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-04 13:03:25 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-04 13:03:25 +0100 |
commit | ef0a09ceb334f1d1f05ad790e570ef0cdaaa3c52 (patch) | |
tree | e2f7b1e1f16298d35b18d705bb2c1d7b406d846b /module/web/static/js/views | |
parent | more responsive file listing, scales for smaller screen sizes (diff) | |
download | pyload-ef0a09ceb334f1d1f05ad790e570ef0cdaaa3c52.tar.xz |
functions to render file status, only simple coloring for now
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r-- | module/web/static/js/views/fileView.js | 19 | ||||
-rw-r--r-- | module/web/static/js/views/filterView.js | 16 |
2 files changed, 15 insertions, 20 deletions
diff --git a/module/web/static/js/views/fileView.js b/module/web/static/js/views/fileView.js index a8cac9503..59a26d7c9 100644 --- a/module/web/static/js/views/fileView.js +++ b/module/web/static/js/views/fileView.js @@ -1,5 +1,5 @@ -define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'], - function($, Backbone, _, App, ItemView) { +define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abstract/itemView'], + function($, Backbone, _, App, Api, ItemView) { // Renders single file item return ItemView.extend({ @@ -26,18 +26,17 @@ define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'], var data = this.model.toJSON(); if (data.download) { var status = data.download.status; - // TODO: remove hardcoded states - if (status === 1 || status === 11) + if (status === Api.DownloadStatus.Offline || status === Api.DownloadStatus.TempOffline) data.offline = true; - else if (status === 7) - data.failed = true; - else if (status === 2) + else if (status === Api.DownloadStatus.Online) data.online = true; - else if (status === 9) + else if (status === Api.DownloadStatus.Waiting) data.waiting = true; - else if (status === 10) + else if (status === Api.DownloadStatus.Downloading) data.downloading = true; - else if (status === 5 || status === 6) + else if (this.model.isFailed()) + data.failed = true; + else if (this.model.isFinished()) data.finished = true; } diff --git a/module/web/static/js/views/filterView.js b/module/web/static/js/views/filterView.js index 2c2aecf0b..a085fdad5 100644 --- a/module/web/static/js/views/filterView.js +++ b/module/web/static/js/views/filterView.js @@ -1,10 +1,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($, Backbone, _, App, 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 - // Renders the actionbar for the dashboard, handles everything related to filtering displayed files return Backbone.View.extend({ el: 'ul.actionbar', @@ -77,12 +73,12 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], // determine if a file should be visible // TODO: non download files is_visible: function(file) { - if (this.state == Api.DownloadState.Finished) - return _.indexOf(Finished, file.get('download').status) > -1; - else if (this.state == Api.DownloadState.Unfinished) - return _.indexOf(Finished, file.get('download').status) == -1 && _.indexOf(Failed, file.get('download').status) == -1; - else if (this.state == Api.DownloadState.Failed) - return _.indexOf(Failed, file.get('download').status) > -1; + if (this.state === Api.DownloadState.Finished) + return file.isFinished(); + else if (this.state === Api.DownloadState.Unfinished) + return file.isUnfinished(); + else if (this.state === Api.DownloadState.Failed) + return file.isFailed(); return true; }, |