diff options
author | Yorhel <git@yorhel.nl> | 2012-01-10 15:44:32 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2012-01-10 15:44:32 +0100 |
commit | 7f48af30ed456688391e46b1a577c5907cdd7be7 (patch) | |
tree | 468dde27c392eab5af23e05e87f452a622c6316e /lib/VNDB/Util | |
parent | 3ea8eef12df3e84645b59301211cd233b6c27a2d (diff) |
Allow one fractional digit for VN votes
The interface to set a non-integer vote isn't very nice, but at least it
works. Or so I hope.
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r-- | lib/VNDB/Util/BrowseHTML.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm index 6d6cdeda..993f8746 100644 --- a/lib/VNDB/Util/BrowseHTML.pm +++ b/lib/VNDB/Util/BrowseHTML.pm @@ -202,7 +202,7 @@ sub htmlBrowseVN { end; td class => 'tc5', sprintf '%.2f', ($l->{c_popularity}||0)*100; td class => 'tc6'; - txt sprintf '%.2f', $l->{c_rating}||0; + txt sprintf '%.2f', ($l->{c_rating}||0)/10; b class => 'grayedout', sprintf ' (%d)', $l->{c_votecount}; end; end 'tr'; diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 73e2c5ba..8f908b19 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -338,11 +338,11 @@ sub htmlItemMessage { sub htmlVoteStats { my($self, $type, $obj, $stats) = @_; - my($max, $count, $total) = (0, 0); + my($max, $count, $total) = (0, 0, 0); for (0..$#$stats) { - $max = $stats->[$_] if $stats->[$_] > $max; - $count += $stats->[$_]; - $total += $stats->[$_]*($_+1); + $max = $stats->[$_][0] if $stats->[$_][0] > $max; + $count += $stats->[$_][0]; + $total += $stats->[$_][1]; } div class => 'votestats'; table class => 'votegraph'; @@ -350,15 +350,15 @@ sub htmlVoteStats { td colspan => 2, mt '_votestats_title'; end; end; tfoot; Tr; - td colspan => 2, mt('_votestats_sum', $count, sprintf('%.2f', $total/$count)) - .($type eq 'v' ? ' ('.mt('_vote_'.(ceil($total/$count-1)||1)).')' : ''); + td colspan => 2, mt('_votestats_sum', $count, sprintf('%.2f', $total/$count/10)) + .($type eq 'v' ? ' ('.mt('_vote_'.(ceil($total/$count/10-1)||1)).')' : ''); end; end; for (reverse 0..$#$stats) { Tr; td class => 'number', $_+1; td class => 'graph'; - div style => 'width: '.($stats->[$_] ? $stats->[$_]/$max*250 : 0).'px', ' '; - txt $stats->[$_]; + div style => 'width: '.($stats->[$_][0]/$max*250).'px', ' '; + txt $stats->[$_][0]; end; end; } @@ -392,7 +392,7 @@ sub htmlVoteStats { a href => "/u$recent->[$_]{uid}", $recent->[$_]{username}; } end; - td $recent->[$_]{vote}; + td fmtvote $recent->[$_]{vote}; td $self->{l10n}->date($recent->[$_]{date}); end; } @@ -404,7 +404,7 @@ sub htmlVoteStats { div; h3 mt '_votestats_rank_title'; p mt '_votestats_rank_pop', $obj->{p_ranking}, sprintf '%.2f', ($obj->{c_popularity}||0)*100; - p mt '_votestats_rank_rat', $obj->{r_ranking}, sprintf '%.2f', $obj->{c_rating}; + p mt '_votestats_rank_rat', $obj->{r_ranking}, sprintf '%.2f', $obj->{c_rating}/10; end; } end 'div'; |