]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster/HTML.pm
Remove previous/next when not relevant
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster / HTML.pm
index 45230551f8a391bd2042b08a550e9fd33e8877ca..6921981215ac79bb7633f082436282a27065c785 100644 (file)
@@ -93,7 +93,7 @@ sub process_us_entry {
 
        my $ctiter = sub {
                my ($data, $td) = @_;
-               $td->fclass('contest')->namedlink($data->{contest});
+               $td->fclass('contest')->namedlink($data->{contest}, $data->{contest_name});
                $td->fclass('score')->replace_content($data->{score});
                $td->fclass('rank')->replace_content($data->{rank});
        };
@@ -102,13 +102,12 @@ sub process_us_entry {
 
 sub process_us {
        my ($tree, %args) = @_;
-       my $item = $tree->fclass('list-group-item');
-       $item->replace_with(map {
-               my $new = $item->clone;
-               $new->attr(href => $_->{id});
-               $new->replace_content($_->{name} || $_->{id});
-               $new
-       } @{$args{us}});
+       my $iter = sub {
+               my ($data, $tr) = @_;
+               $tr->fclass('user')->namedlink($data->{id}, $data->{name});
+               $tr->fclass($_)->replace_content($data->{$_}) for qw/solved attempted contests/;
+       };
+       $tree->find('tbody')->find('tr')->iter3($args{us}, $iter);
 }
 
 sub process_ct_entry {
@@ -217,8 +216,8 @@ sub process_log {
                $tr->fclass('result_text')->attr(class => "r$data->{result}");
        };
        $tree->find('table')->find('tbody')->find('tr')->iter3($args{log}, $iter);
-       $args{next_page} ? $tree->fclass('next')->namedlink($args{next_page}, 'Next') : $tree->fclass('next')->attr(class => 'next disabled');
-       $args{previous_page} ? $tree->fclass('previous')->namedlink($args{previous_page}, 'Previous') : $tree->fclass('previous')->attr(class => 'previous disabled');
+       $args{next_page} ? $tree->fclass('next')->namedlink($args{next_page}, 'Next') : $tree->fclass('next')->detach;
+       $args{previous_page} ? $tree->fclass('previous')->namedlink($args{previous_page}, 'Previous') : $tree->fclass('previous')->detach;
        $tree->fclass('current')->replace_content("Page $args{current_page} of $args{last_page}");
 }
 
@@ -237,7 +236,6 @@ sub process_st {
                $tr->set_child_content(class => 'score', $st->{score});
                $tr->fclass('user')->namedlink($st->{user}, $st->{user_name});
                my $pbscore = $tr->fclass('pbscore');
-               $pbscore->detach unless $st->{problems};
                $pbscore->iter($pbscore => @{$st->{scores}});
        };
        $tree->find('tbody')->find('tr')->iter3($args{st}, $iter);
This page took 0.018596 seconds and 4 git commands to generate.