- Fixes in the new Weekdays Plugin
[onis.git] / lib / Onis / Plugins / Userdetails.pm
index 4a1250d..66aa39e 100644 (file)
@@ -146,9 +146,11 @@ sub output
        my $max_time = 0;
        my $max_conv = 0;
 
-       my @nicks = $nicks_ref->[0 .. ($max - 1)];
+       my @nicks = @$nicks_ref;
        my $nick_data = {};
 
+       splice (@nicks, $max) if (scalar (@nicks) > $max);
+
        for (@nicks)
        {
                my $nick = $_;
@@ -158,16 +160,16 @@ sub output
                $nick_data->{$nick}{'bignumbers'} = get_bignumbers ($nick);
                $nick_data->{$nick}{'interestingnumbers'} = get_interestingnumbers ($nick);
                
-               for (my $i = 0; $i < 12; $i++)
+               for (my $i = 0; $i < 24; $i++)
                {
-                       $num = $nick_data->{$nick}{'lines'}[2 * $i] + $nick_data->{$nick}{'lines'}[(2 * $i) + 1];
+                       $num = $nick_data->{$nick}{'chars'}[$i];
                        $max_time = $num if ($max_time < $num);
                }
 
                for (keys %{$nick_data->{$nick}{'conversations'}})
                {
                        my $other = $_;
-                       my $ptr = $nick_data->{$nick}{'conversations'}{'nicks'}{$other};
+                       my $ptr = $nick_data->{$nick}{'conversations'}{$other}{'nicks'}{$nick};
                        $num = $ptr->[0] + $ptr->[1] + $ptr->[2] + $ptr->[3];
                        $max_conv = $num if ($max_conv < $num);
                }
@@ -252,6 +254,8 @@ sub output
                        $trans = translate ('Has written %u chars');
                        printf $fh ("      $trans<br />\n", $chars);
 
+                       $lines ||= 1;
+
                        $num = $words / $lines;
                        $trans = translate ('Has written %.1f words per line');
                        printf $fh ("      $trans<br />\n", $num);
@@ -266,16 +270,16 @@ sub output
                if (%{$ptr->{'interestingnumbers'}})
                {
                        $trans = translate ('Has given %u ops');
-                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'ops_given'});
+                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'op_given'});
                
                        $trans = translate ('Has taken %u ops');
-                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'ops_taken'});
+                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'op_taken'});
 
                        $trans = translate ('Has kicked out %u people');
-                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'kicks_given'});
+                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'kick_given'});
                
                        $trans = translate ('Has been kicked out %u times');
-                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'kicks_received'});
+                       printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'kick_received'});
 
                        $trans = translate ('Has performed %u actions');
                        printf $fh ("      $trans<br />\n", $ptr->{'interestingnumbers'}{'actions'});
@@ -311,32 +315,30 @@ sub output
                
                if (defined ($ptr->{'chars'}))
                {
-                       print $fh qq#      <table class="hours_of_day">\n        <tr>\n#;
+                       print $fh qq#      <table class="hours">\n        <tr class="bars">\n#;
                        
-                       for (my $i = 0; $i < 12; $i++)
+                       for (my $i = 0; $i < 24; $i++)
                        {
-                               my $hour = 2 * $i;
                                $num = 0;
 
-                               my $img = $V_IMAGES[int ($hour / 6)];
+                               my $img = $V_IMAGES[int ($i / 6)];
                                my $height;
 
-                               $num  = $ptr->{'chars'}[$hour];
-                               $num += $ptr->{'chars'}[$hour + 1];
+                               $num  = $ptr->{'chars'}[$i];
 
-                               $height = int (0.5 + ($time_factor * $num)) || 1;
+                               $height = sprintf ("%.2f", 95 * $num / $max_time);
 
-                               print $fh qq#          <td><img src="$img" alt="$num chars" #,
-                               qq#style="height: ${height}px;" /></td>\n#;
+                               print $fh qq#          <td class="bar vertical"><img src="$img" alt="$num chars" #,
+                               qq#class="first last" style="height: $height\%;" /></td>\n#;
                        }
 
                        print $fh <<EOF;
         </tr>
-       <tr class="hour_row">
-         <td colspan="3">0-5</td>
-         <td colspan="3">6-11</td>
-         <td colspan="3">12-17</td>
-         <td colspan="3">18-23</td>
+       <tr class="numeration">
+         <td colspan="6" class="numeration">0-5</td>
+         <td colspan="6" class="numeration">6-11</td>
+         <td colspan="6" class="numeration">12-17</td>
+         <td colspan="6" class="numeration">18-23</td>
        </tr>
       </table>
 EOF