]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster/HTML.pm
Add timers for contest start/stop and problem value
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster / HTML.pm
index 52afd1129128f719d235a7bf4017ac2115e31418..fe7e4964ebe02507e0f86b4d281667bb0636c593 100644 (file)
@@ -115,9 +115,12 @@ sub process_ct_entry {
        my ($tree, %args) = @_;
        $_->edit_href (sub {s/contest_id/$args{id}/}) for $tree->find('a');
        $tree->fid('links')->detach unless $args{started};
+       my $status = ($args{time} < $args{start} ? 'starts' : 'ends');
+       $tree->fclass('timer')->attr('data-stop', $status eq 'ends' ? $args{stop} : $args{start});
        $tree->content_handler(
                start       => ftime   $args{start},
                stop        => ftime   $args{stop},
+               status      => $status,
                description => literal $args{description});
 }
 
@@ -147,14 +150,11 @@ sub process_pb_entry {
        if ($args{contest_stop}) {
                $tree->fid('solution')->detach;
                $tree->fid('solution_modal')->detach;
-               my $countdown = $tree->fid('countdown');
-               $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::Result::Contest::calc_score($args{value}, $args{time} - $args{open_time}, 0, $args{contest_stop} - $args{contest_start}));
+               my $score = $tree->fid('score');
+               $score->attr('data-start' => $args{open_time});
+               $score->attr('data-stop'  => $args{contest_stop});
+               $score->attr('data-value'  => $args{value});
+               $tree->fid('countdown')->attr('data-stop' => $args{contest_stop});
        } else {
                $tree->fid('solution')->detach unless $args{solution};
                $_->detach for $tree->fclass('rc'); # requires contest
This page took 0.020846 seconds and 4 git commands to generate.