From 3042489c06f572c21c96b27c100e978472bf3be0 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 16 May 2016 21:53:45 +0800 Subject: [PATCH] display order supports by file size --- app/index.html | 12 +++++++++--- app/scripts/controllers/list.js | 7 +++++-- app/scripts/filters/taskOrderBy.js | 2 ++ app/scripts/langs/en-US.js | 7 ++++--- app/scripts/langs/zh-CN.js | 7 ++++--- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/index.html b/app/index.html index 8402100..643ee1b 100644 --- a/app/index.html +++ b/app/index.html @@ -66,19 +66,25 @@
  • - File Name + By File Name
  • +
  • + + By File Size + + +
  • - Completed Percent + By Completed Percent
  • - Remain Time + By Remain Time
  • diff --git a/app/scripts/controllers/list.js b/app/scripts/controllers/list.js index 447d089..289b015 100644 --- a/app/scripts/controllers/list.js +++ b/app/scripts/controllers/list.js @@ -29,7 +29,9 @@ }; var processDownloadTask = function (task) { - var remainLength = task.totalLength - task.completedLength; + var totalLength = parseInt(task.totalLength); + var completedLength = parseInt(task.completedLength); + var remainLength = totalLength - completedLength; if (task.bittorrent && task.bittorrent.info) { task.taskName = task.bittorrent.info.name; @@ -39,7 +41,8 @@ task.taskName = translateFilter('Unknown'); } - task.completePercent = task.completedLength / task.totalLength * 100; + task.fileSize = totalLength; + task.completePercent = completedLength / totalLength * 100; task.idle = task.downloadSpeed == 0; task.remainTime = calculateDownloadRemainTime(remainLength, task.downloadSpeed); }; diff --git a/app/scripts/filters/taskOrderBy.js b/app/scripts/filters/taskOrderBy.js index e1d9532..35f2f85 100644 --- a/app/scripts/filters/taskOrderBy.js +++ b/app/scripts/filters/taskOrderBy.js @@ -9,6 +9,8 @@ if (type == 'name') { return orderByFilter(array, ['taskName'], false); + } else if (type == 'size') { + return orderByFilter(array, ['fileSize'], false); } else if (type == 'percent') { return orderByFilter(array, ['completePercent'], true); } else if (type == 'remain') { diff --git a/app/scripts/langs/en-US.js b/app/scripts/langs/en-US.js index 43268a5..407e51d 100644 --- a/app/scripts/langs/en-US.js +++ b/app/scripts/langs/en-US.js @@ -9,9 +9,10 @@ 'Delete': 'Delete', 'Display Order': 'Display Order', 'Default': 'Default', - 'File Name': 'File Name', - 'Completed Percent': 'Completed Percent', - 'Remain Time': 'Remain Time', + 'By File Name': 'By File Name', + 'By File Size': 'By File Size', + 'By Completed Percent': 'By Completed Percent', + 'By Remain Time': 'By Remain Time', 'Settings': 'Settings', 'Download': 'Download', 'Downloading': 'Downloading', diff --git a/app/scripts/langs/zh-CN.js b/app/scripts/langs/zh-CN.js index 23d414a..d4290cc 100644 --- a/app/scripts/langs/zh-CN.js +++ b/app/scripts/langs/zh-CN.js @@ -9,9 +9,10 @@ 'Delete': '删除下载任务', 'Display Order': '显示顺序', 'Default': '默认', - 'File Name': '文件名', - 'Completed Percent': '完成度', - 'Remain Time': '剩余时间', + 'By File Name': '按文件名', + 'By File Size': '按文件大小', + 'By Completed Percent': '按完成度', + 'By Remain Time': '按剩余时间', 'Settings': '系统设置', 'Download': '下载', 'Downloading': '正在下载',