browser: abbreviate agent name depending on version columns
[sheet.git] / browser.plp
index 1f5cfc0048a3b4b855932123da6cf547158d818c..0531e6d1f86c8d1ca1ad937526c23d20491b45fe 100644 (file)
@@ -102,12 +102,16 @@ my $header = join('',
        '<tr>',
        '<th colspan="3">feature',
        (map {
-               sprintf('<th colspan="%d" title="%.1f%%">%s',
+               my $name = $caniuse->{agents}->{$_}->{browser};
+               sprintf('<th colspan="%d" title="%s">%s',
                        scalar @{ $versions{$_} },
-                       sum(values %{ $canihas->{$_} }),
+                       join(' ',
+                               sprintf('%.1f%%', sum(values %{ $canihas->{$_} })),
+                               $name,
+                       ),
                        do {
-                               my $name = $caniuse->{agents}->{$_}->{browser};
-                               length $name < 16 ? $name : $caniuse->{agents}->{$_}->{abbr};
+                               length $name < 3 + @{ $versions{$_} }*2 ? $name
+                                       : $caniuse->{agents}->{$_}->{abbr};
                        },
                )
        } @browsers),
@@ -131,7 +135,7 @@ print "</thead>\n";
 
 sub featurescore {
        # relative amount of support for given feature
-       state $statspts = { y=>10, 'y x'=>9, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 };
+       state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 };
        my $rank = 0;
        if (my $row = shift) {
                if ($canihas) {