[FFmpeg-devel] [FATESERVER/PATCH 2/8] index: use one parameter "sort" for both ascending and descending sorting

Timothy Gu timothygu99 at gmail.com
Wed Jun 11 03:07:48 CEST 2014


Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
---
 index.cgi | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/index.cgi b/index.cgi
index c9021c7..1aa2c00 100755
--- a/index.cgi
+++ b/index.cgi
@@ -78,8 +78,8 @@ $allfail = 100 * $allfail / @reps;
 my $warn = 100 - $allpass - $allfail;
 
 my @sort = ('subarch', 'os', 'cc', 'comment', 'slot');
-my $sort = param('asort') || param('dsort');
-my $sdir = param('dsort') ? -1 : 1;
+my $sort = param('sort');
+my $sdir = 1; # default to ascending sorting
 defined $sort and unshift @sort, $sort eq 'arch'? 'subarch': $sort;
 $sort ||= $sort[0];
 
@@ -91,6 +91,10 @@ sub nscmp {
 sub repcmp {
     my $r;
     for my $s (@sort) {
+        if ($s =~ /^desc/) {
+            $s =~ s/^desc//;
+            $sdir = -1;
+        }
         last if $r = $sdir * nscmp $$a{$s}, $$b{$s};
     }
     return $r;
@@ -104,14 +108,17 @@ sub lsort {
         $params .= "$thisparam=" . param($thisparam);
     }
     $params .= '&' if $params;
-    my ($text, $key, $p) = @_;
-    if ($sort eq $key) {
-        $p = param('asort') ? 'dsort' : 'asort';
-    }
-    if (!$p) {
-        $p = 'asort';
+    my ($text, $key) = @_;
+
+    if ($sort eq $key) {                           # $sort = $key
+        if ($key =~ /^desc/) {                     # $sort = desc*
+            $key =~ s/^desc//;
+        } else {                                   # $sort = *
+            $key = "desc$key";
+        }
     }
-    anchor $text, href => "$uri?$params$p=$key";
+
+    anchor $text, href => "$uri?${params}sort=$key";
 }
 
 sub category {
@@ -213,7 +220,7 @@ span ' ', class => 'fail', style => "width: ${allfail}%" if $allfail;
 end 'td';
 end 'tr';
 start 'tr';
-start 'th'; lsort 'Time',     'date', 'dsort'; end 'th';
+start 'th'; lsort 'Time',     'descdate';      end 'th';
 start 'th'; lsort 'Rev',      'rev';           end 'th';
 start 'th'; lsort 'Arch',     'arch';          end 'th';
 start 'th'; lsort 'OS',       'os';            end 'th';
-- 
1.9.1



More information about the ffmpeg-devel mailing list