diff options
author | Yorhel <git@yorhel.nl> | 2009-03-07 11:10:06 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-03-07 11:15:45 +0100 |
commit | afd4fa3f408e5644c207e7c4d15f41ff4889904b (patch) | |
tree | 8562b09f624ceebc8e7e56a14f584982611dd536 | |
parent | 37196fc10d36249a525b07c1d74489bf259bde99 (diff) |
Cute interface for displaying tag scores
...I could've also just used a gradient background image, which is
easier to do and looks better... but I hate solutions that require
external resources. >.>
-rw-r--r-- | data/style.css | 9 | ||||
-rw-r--r-- | lib/VNDB/Func.pm | 32 | ||||
-rw-r--r-- | lib/VNDB/Handler/Tags.pm | 9 |
3 files changed, 41 insertions, 9 deletions
diff --git a/data/style.css b/data/style.css index 095f14b4..d9413d39 100644 --- a/data/style.css +++ b/data/style.css @@ -969,7 +969,7 @@ ul#catselect li li.exc { background-position: 0px -33px; color: $statnok$; } .tagtree li { float: left; width: 200px; margin-top: 10px; } .tagtree li li { float: none; width: auto; margin-top: 0; } .tagtree ul { margin-left: 10px; list-style-type: none; } -.tagvnlist .tc1 { text-align: right; width: 60px; } +.tagvnlist .tc1 { width: 105px; } .tagvnlist .tc1 i { font-style: normal; font-size: 8px } .tagvnlist .tc3 { text-align: right; padding: 0; } .tagvnlist .tc4 { padding: 0; } @@ -983,10 +983,13 @@ ul#catselect li li.exc { background-position: 0px -33px; color: $statnok$; } #tagtable .tc2_1 { border-right: 1px solid $border$; border-left: 1px solid $border$; width: 150px; text-align: center } #tagtable .tc3_1 { border-left: 1px solid $border$; width: 150px; text-align: center } #tagtable .tc1 { min-width: 200px; border-right: 1px solid $border$ } +#tagtable .tc2 i { font-style: normal; font-size: 8px } #tagtable .tc3 { border-right: 1px solid $border$ } #tagtable .tc5 { text-align: right } -a.taglvl { display: block; float: left; width: 8px; height: 12px; border: 1px solid $border$; font-size: 1px; color: $maintext$!important } -a.taglvl0 { width: 15px; border: none!important; font-size: 10px; text-align: center; } +.taglvl { display: block; float: left; width: 8px; height: 12px; border: 1px solid $border$; font-size: 1px; color: $maintext$!important } +.taglvl0 { width: 15px; border: none!important; font-size: 10px; text-align: center; } +div.taglvl0 { font-size: 8px; width: 20px!important } +div.taglvl { border: none!important; width: 10px; height: 14px } a.taglvl:hover { border-bottom: 1px solid transparent!important } .taglvlsel.taglvl-3 { background-color: #f00; border-color: #f00 } .taglvlsel.taglvl-2 { background-color: #f40; border-color: #f40 } diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index a472d2e2..952f214c 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -5,8 +5,8 @@ use strict; use warnings; use YAWF ':html'; use Exporter 'import'; -use POSIX 'strftime'; -our @EXPORT = qw| shorten age date datestr monthstr userstr bb2html gtintype liststat clearfloat cssicon |; +use POSIX 'strftime', 'ceil', 'floor'; +our @EXPORT = qw| shorten age date datestr monthstr userstr bb2html gtintype liststat clearfloat cssicon tagscore|; # I would've done this as a #define if this was C... @@ -237,5 +237,33 @@ sub cssicon { } +# Tag score in html tags, argument: score, users +sub tagscore { + my $s = shift; + div class => 'taglvl', style => sprintf('width: %.0fpx', ($s-floor($s))*10), ' ' if $s < 0 && $s-floor($s) > 0; + for(-3..3) { + div(class => "taglvl taglvl0", sprintf '%.1f', $s), next if !$_; + if($_ < 0) { + if($s > 0 || floor($s) > $_) { + div class => "taglvl taglvl$_", ' '; + } elsif(floor($s) != $_) { + div class => "taglvl taglvl$_ taglvlsel", ' '; + } else { + div class => "taglvl taglvl$_ taglvlsel", style => sprintf('width: %.0fpx', 10-($s-$_)*10), ' '; + } + } else { + if($s < 0 || ceil($s) < $_) { + div class => "taglvl taglvl$_", ' '; + } elsif(ceil($s) != $_) { + div class => "taglvl taglvl$_ taglvlsel", ' '; + } else { + div class => "taglvl taglvl$_ taglvlsel", style => sprintf('width: %.0fpx', 10-($_-$s)*10), ' '; + } + } + } + div class => 'taglvl', style => sprintf('width: %.0fpx', (ceil($s)-$s)*10), ' ' if $s > 0 && ceil($s)-$s > 0; +} + + 1; diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm index 88fa96ef..0d2e7410 100644 --- a/lib/VNDB/Handler/Tags.pm +++ b/lib/VNDB/Handler/Tags.pm @@ -102,7 +102,7 @@ sub tagpage { my($s, $n, $l) = @_; Tr $n % 2 ? (class => 'odd') : (); td class => 'tc1'; - txt sprintf '%.2f ', $l->{rating}; + tagscore $l->{rating}; i sprintf '(%d)', $l->{users}; end; td class => 'tc2'; @@ -327,9 +327,10 @@ sub vntagmod { td class => 'tc1'; a href => "/g$t->{id}", $t->{name}; end; - td class => 'tc2', sprintf '%.2f (%d)', - !$m->{vote} ? $t->{rating} : $t->{users} == 1 ? 0 : ($t->{rating}*$t->{users} - $m->{vote}) / ($t->{users}-1), - $t->{users} - ($m->{vote} ? 1 : 0); + td class => 'tc2'; + tagscore !$m->{vote} ? $t->{rating} : $t->{users} == 1 ? 0 : ($t->{rating}*$t->{users} - $m->{vote}) / ($t->{users}-1); + i ' ('.($t->{users} - ($m->{vote} ? 1 : 0)).')'; + end; td class => 'tc3', sprintf '%.2f', $t->{spoiler}; td class => 'tc4', $m->{vote}||0; td class => 'tc5', defined $m->{spoiler} ? $m->{spoiler} : -1; |