browser: repeat colgroup headers as table footer
[sheet.git] / browser.plp
index 16aad08a1a93afb61e6b44df04c947526043ab11..005ab167f9295c9ea474c16d92af97197345bfd8 100644 (file)
@@ -1,5 +1,6 @@
 <(common.inc.plp)><:
 use 5.010;
+use utf8;
 use List::Util qw(sum max);
 
 Html({
@@ -59,16 +60,22 @@ print '<col>' x 3;
 printf '<colgroup span="%d">', scalar @{ $versions{$_} } for @browsers;
 print "\n";
 
-print '<thead><tr>';
-print '<th colspan="3">feature';
-printf('<th colspan="%d">%s',
-       scalar @{ $versions{$_} },
-       do {
-               my $name = $caniuse->{agents}->{$_}->{browser};
-               length $name < 16 ? $name : $caniuse->{agents}->{$_}->{abbr};
-       },
-) for @browsers;
-print '<th>%';
+my $header = join('',
+       '<tr>',
+       '<th colspan="3">feature',
+       (map {
+               sprintf('<th colspan="%d" title="%.1f%%">%s',
+                       scalar @{ $versions{$_} },
+                       sum(values %{ $canihas->{$_} }),
+                       do {
+                               my $name = $caniuse->{agents}->{$_}->{browser};
+                               length $name < 16 ? $name : $caniuse->{agents}->{$_}->{abbr};
+                       },
+               )
+       } @browsers),
+       '<th>%',
+);
+print '<thead>', $header;
 # preceding row without any colspan to work around gecko bug
 print "\n<tr>";
 print '<td>' x 3;
@@ -156,6 +163,7 @@ for my $id (sort {
        });
        print '<td>', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100;
 }
+print '<tfoot>', $header;
 print '</table>';
 
 sub paddedver {