sub process_us_entry {
my ($tree, %args) = @_;
$tree->fid($_)->attr('href', "/$_/?owner=$args{id}") for qw/log pb/;
+ $tree->fid('track_user')->attr('data-user', $args{id});
my @solved = map { $_->{solved} ? ($_->{problem}) : () } @{$args{problems}};
my @attempted = map { !$_->{solved} ? ($_->{problem}) : () } @{$args{problems}};
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});
};
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 {
$tree->fid('owner')->edit_href(sub{s/owner_id/$args{owner}/});
$tree->fid('job_log')->edit_href(sub{s/problem_id/$args{id}/});
$tree->fid('solution')->edit_href(sub{s/problem_id/$args{id}/});
+ $tree->fid('job_log')->edit_href(sub{$_ .= "&private=$args{private}"}) if $args{private};
$tree->content_handler(
statement => literal $args{statement},
+ level => ucfirst $args{level},
author => $args{author},
owner => $args{owner_name} || $args{owner});
if ($args{contest_stop}) {
$tree->fid('solution')->detach;
$tree->fid('solution_modal')->detach;
my $countdown = $tree->fid('countdown');
- $countdown->attr('data-start' => $args{contest_start});
+ $countdown->attr('data-start' => $args{open_time});
$countdown->attr('data-stop' => $args{contest_stop});
$countdown->attr('data-time' => $args{time});
my $left = $args{contest_stop} - $args{time};
$countdown->replace_content(sprintf '%02d:%02d:%02d', $left/60/60, $left/60%60, $left%60);
$tree->fid('score')->attr('data-value' => $args{value});
- $tree->fid('score')->replace_content(Gruntmaster::Data::calc_score($args{value}, $args{time} - $args{contest_start}, 0, $args{contest_stop} - $args{contest_start}));
+ $tree->fid('score')->replace_content(Gruntmaster::Data::Result::Contest::calc_score($args{value}, $args{time} - $args{open_time}, 0, $args{contest_stop} - $args{contest_start}));
} else {
+ $tree->fid('solution')->detach unless $args{solution};
$_->detach for $tree->fclass('rc'); # requires contest
$tree->fid('solution_modal')->fclass('modal-body')->replace_content(literal $args{solution});
}
sub process_log_entry {
my ($tree, %args) = @_;
+ $tree->fid('problem')->namedlink(@args{qw/problem problem_name/});
+ $tree->fid('owner')->namedlink(@args{qw/owner owner_name/});
+ $tree->fid('source')->namedlink("$args{id}.$args{extension}", sprintf '%.2fKB', $args{size}/1024);
+ if ($args{contest}) {
+ $tree->fid('contest')->namedlink(@args{qw/contest contest_name/});
+ $tree->fid('problem')->find('a')->edit_href(sub {$_.="?contest=$args{contest}"});
+ } else {
+ $tree->fid('contest')->left->detach;
+ $tree->fid('contest')->detach;
+ }
+
$args{errors} ? $tree->fid('errors')->find('pre')->replace_content($args{errors}) : $tree->fid('errors')->detach;
my $iter = sub {
my ($data, $tr) = @_;
$tr->defmap(class => $data);
$tr->fclass('result_text')->attr(class => "r$data->{result}")
};
- @{$args{results}} ? $tree->fid('results')->find('tbody')->find('tr')->iter3($args{results}, $iter) : $tree->fid('results')->detach;
+ $tree->fclass('result_text')->replace_content($args{result_text});
+ $tree->fclass('result_text')->attr(class => "r$args{result}");
+ $args{results} ? $tree->fid('results')->find('tbody')->find('tr')->iter3($args{results}, $iter) : $tree->fid('results')->detach;
+ $tree->fid('no_results')->detach if $tree->fid('results') || $tree->fid('errors');
}
sub process_log {
$tr->fclass('problem')->namedlink($data->{problem}, $data->{problem_name});
$tr->fclass('problem')->find('a')->edit_href(sub{$_ .= "?contest=$args{contest}"}) if $args{contest};
$tr->fclass('date')->replace_content(ftime $data->{date});
+ $tr->fclass('format')->replace_content($data->{format});
$tr->fclass('size')->namedlink("$data->{id}.$data->{extension}", sprintf "%.2fKB", $data->{size}/1024);
$tr->fclass('size')->attr('data-private', '') if $data->{private};
$tr->fclass('owner')->namedlink($data->{owner}, $data->{owner_name});
$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;
+ for my $cls (qw/next previous/) {
+ my $elem = $tree->fclass($cls);
+ next unless $elem;
+ delete $args{args}{page};
+ my $str = join '&', map { $_ . '=' . $args{args}{$_} } keys %{$args{args}};
+ $elem->find('a')->edit_href(sub{s/$/&$str/});
+ }
$tree->fclass('current')->replace_content("Page $args{current_page} of $args{last_page}");
}
my $pbiter = sub {
my ($data, $th) = @_;
$th->attr(class => undef);
- $th->namedlink($data->id, $data->name);
+ $th->namedlink(@$data);
};
$tree->fclass('problem')->iter3($args{problems}, $pbiter);
my $iter = sub {
$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);