(trunk web) #4637 "sorting by size in the web ui" -- patch added.

This commit is contained in:
Jordan Lee 2011-11-28 03:35:33 +00:00
parent 788b1f20a7
commit 2d4d29793c
3 changed files with 17 additions and 1 deletions

View File

@ -360,8 +360,9 @@
<li class='sort-mode' id="sort_by_activity">Activity</li>
<li class='sort-mode' id="sort_by_age">Age</li>
<li class='sort-mode' id="sort_by_name">Name</li>
<li class='sort-mode' id="sort_by_percent_completed">Progress</li>
<li class='sort-mode' id="sort_by_ratio">Ratio</li>
<li class='sort-mode' id="sort_by_size">Size</li>
<li class='sort-mode' id="sort_by_percent_completed">Progress</li>
<li class='sort-mode' id="sort_by_queue_order">Queue Order</li>
<li class='sort-mode' id="sort_by_state">State</li>
<li class="separator"></li>

View File

@ -157,6 +157,7 @@ Prefs._SortByAge = 'age';
Prefs._SortByActivity = 'activity';
Prefs._SortByName = 'name';
Prefs._SortByQueue = 'queue_order';
Prefs._SortBySize = 'size';
Prefs._SortByProgress = 'percent_completed';
Prefs._SortByRatio = 'ratio';
Prefs._SortByState = 'state';

View File

@ -408,6 +408,14 @@ Torrent.compareByProgress = function(ta, tb)
return (a - b) || Torrent.compareByRatio(ta, tb);
};
Torrent.compareBySize = function(ta, tb)
{
var a = ta.getTotalSize(),
b = tb.getTotalSize();
return (a - b) || Torrent.compareByName(ta, tb);
}
Torrent.compareTorrents = function(a, b, sortMethod, sortDirection)
{
var i;
@ -426,6 +434,9 @@ Torrent.compareTorrents = function(a, b, sortMethod, sortDirection)
case Prefs._SortByProgress:
i = Torrent.compareByProgress(a,b);
break;
case Prefs._SortBySize:
i = Torrent.compareBySize(a,b);
break;
case Prefs._SortByState:
i = Torrent.compareByState(a,b);
break;
@ -464,6 +475,9 @@ Torrent.sortTorrents = function(torrents, sortMethod, sortDirection)
case Prefs._SortByProgress:
torrents.sort(this.compareByProgress);
break;
case Prefs._SortBySize:
torrents.sort(this.compareBySize);
break;
case Prefs._SortByState:
torrents.sort(this.compareByState);
break;