X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster%2FHTML.pm;h=a82cafd1cd3ab7023a788bd9463d86673601f6be;hb=dc7e3b7c32ab45ca72d1ec68e74d1aceab7fe041;hp=16ae617ecf9c3635f5a9d2bbba0701a62c039659;hpb=3b69df7a785bbfc5b8c4a1719c046f9800aa3548;p=gruntmaster-page.git diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index 16ae617..a82cafd 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -118,10 +118,26 @@ sub process_pb_entry { my ($tree, %args) = @_; $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->content_handler( statement => literal $args{statement}, 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-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})); + } else { + $_->detach for $tree->fclass('rc'); # requires contest + $tree->fid('solution_modal')->fclass('modal-body')->replace_content(literal $args{solution}); + } if ($args{cansubmit}) { $tree->look_down(name => 'problem')->attr(value => $args{id}); my $contest = $tree->look_down(name => 'contest'); @@ -132,6 +148,11 @@ sub process_pb_entry { } } +sub process_sol { + my ($tree, %args) = @_; + $tree->content_handler(solution => literal $args{solution}); +} + sub process_pb { my ($tree, %args) = @_; my $titer = sub { @@ -195,7 +216,7 @@ sub process_st { my ($st, $tr) = @_; $tr->set_child_content(class => 'rank', $st->{rank}); $tr->set_child_content(class => 'score', $st->{score}); - $tr->fclass('user')->namedlink($st->{user}->id, $st->{user}->name); + $tr->fclass('user')->namedlink($st->{user}, $st->{user_name}); my $pbscore = $tr->fclass('pbscore'); $pbscore->detach unless $st->{problems}; $pbscore->iter($pbscore => @{$st->{scores}});