projects
/
onis.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
4c9ae9a
)
The Weeksdays plugin has been tested and works as wanted. Wee :)
author
octo
<octo>
Thu, 14 Apr 2005 13:25:21 +0000
(13:25 +0000)
committer
octo
<octo>
Thu, 14 Apr 2005 13:25:21 +0000
(13:25 +0000)
lib/Onis/Plugins/Weekdays.pm
patch
|
blob
|
history
diff --git
a/lib/Onis/Plugins/Weekdays.pm
b/lib/Onis/Plugins/Weekdays.pm
index
436e2e1
..
788c83e
100644
(file)
--- a/
lib/Onis/Plugins/Weekdays.pm
+++ b/
lib/Onis/Plugins/Weekdays.pm
@@
-55,11
+55,13
@@
sub add
my $day = (localtime ($time))[6];
my $index = ($day * 4) + $hour;
my $day = (localtime ($time))[6];
my $index = ($day * 4) + $hour;
- my @data = $WeekdayCache->get ($nick) || (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0));
+ my @data = $WeekdayCache->get ($nick);
+ @data = (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) unless (@data);
$data[$index] += $chars;
$WeekdayCache->put ($nick, @data);
$data[$index] += $chars;
$WeekdayCache->put ($nick, @data);
- @data = $WeekdayCache->get ('<TOTAL>') || (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0));
+ @data = $WeekdayCache->get ('<TOTAL>');
+ @data = (qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) unless (@data);
$data[$index] += $chars;
$WeekdayCache->put ('<TOTAL>', @data);
}
$data[$index] += $chars;
$WeekdayCache->put ('<TOTAL>', @data);
}
@@
-119,6
+121,7
@@
sub output
my $fh = get_filehandle ();
my $max = 0;
my $fh = get_filehandle ();
my $max = 0;
+ my $total = 0;
my $bar_factor = 0;
for (@order)
my $bar_factor = 0;
for (@order)
@@
-126,6
+129,7
@@
sub output
my ($num, $abbr, $name) = @$_;
my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
my ($num, $abbr, $name) = @$_;
my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
+ $total += $sum;
$max = $sum if ($max < $sum);
}
$max = $sum if ($max < $sum);
}
@@
-135,18
+139,28
@@
sub output
for (@order)
{
my ($num, $abbr, $name) = @$_;
for (@order)
{
my ($num, $abbr, $name) = @$_;
- my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
-
- print $fh qq# <td class="bar $abbr">$sum<br />\n #;
- for (my $i = 0; $i < 4; $i++)
+ print $fh qq# <td class="bar vertical $abbr">#;
+ for (my $i = 3; $i >= 0; $i--)
{
my $num = $data->{$abbr}[$i];
{
my $num = $data->{$abbr}[$i];
- my $height =
int (0.5 + $num * $bar_factor) || 1
;
+ my $height =
sprintf ("%.2f", (95 * $num / $max))
;
my $img = $VImages[$i];
my $img = $VImages[$i];
-
- print $fh qq(<img src="$img" alt="" style="height: ${height}px;" />);
+ my $class = '';
+
+ $class = q( class="first") if ($i == 3);
+ $class = q( class="last") if ($i == 0);
+
+ print $fh qq(<img src="$img" alt="" style="height: ${height}%;"$class />);
}
}
- print $fh "\n </td>\n";
+ print $fh "</td>\n";
+ }
+ print $fh qq( </tr>\n <tr class="counter">\n);
+ for (@order)
+ {
+ my ($num, $abbr, $name) = @$_;
+ my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3];
+ my $pct = sprintf ("%.1f", (100 * $sum / $total));
+ print $fh qq( <td class="counter $abbr">$pct%</td>\n);
}
print $fh qq( </tr>\n <tr class="numeration">\n);
for (@order)
}
print $fh qq( </tr>\n <tr class="numeration">\n);
for (@order)