<(common.inc.plp)><:
use 5.010;
+use utf8;
use List::Util qw(sum max);
Html({
"caniuse.",
keywords => [qw'html css browser feature'],
stylesheet => [qw'light dark circus mono red'],
- data => ['caniuse.js'],
+ data => ['browser-support.inc.pl'],
});
:>
browser usage statistics.</p>
<:
-use JSON;
-use File::Slurp 'read_file';
-my $source = read_file('caniuse.js');
-for ($source) { # cleanup
- # convert seperate variables to hash keys
- s/\A/{/;
- s/^caniuse\.(\w+) = /"$1":/gm;
- s/;$/,/gm;
- s/,\s*\Z/\n}/;
- # fractions not supported by barekey
- s/(?<=[,{]) (\d*\.\d) (?=:')/"$1"/gx;
- # escapes not supported in singlequote
- s{'((?:[^\\']+|\\.)*)'}{
- my $_ = $1;
- s/"/\\"/g;
- s/\\'/'/g;
- qq("$_");
- }ge;
-}
-my $caniuse = from_json($source, {
-# allow_singlequote => 1,
- allow_barekey => 1,
-});
+my $caniuse = do 'browser-support.inc.pl' or die $! || $@;
my %CSTATS = (
n => 'di-b',
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;
});
print '<td>', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100;
}
+print '<tfoot>', $header;
print '</table>';
sub paddedver {