summaryrefslogtreecommitdiff
path: root/lib/VNDB/Func.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/Func.pm')
-rw-r--r--lib/VNDB/Func.pm32
1 files changed, 30 insertions, 2 deletions
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;