X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/69a605876ce089075ae4fe8ca76c85630a8c6897..07cba79c0739b2b618cdf711449159a6ace26d67:/browser.plp diff --git a/browser.plp b/browser.plp index 330b443..95dd4a9 100644 --- a/browser.plp +++ b/browser.plp @@ -1,5 +1,6 @@ <(common.inc.plp)><: use 5.010; +use utf8; use List::Util qw(sum max); Html({ @@ -9,7 +10,7 @@ Html({ "caniuse.", keywords => [qw'html css browser feature'], stylesheet => [qw'light dark circus mono red'], - data => ['caniuse.js'], + data => ['browser-support.inc.pl'], }); :> @@ -20,29 +21,7 @@ with Wikimedia browser usage statistics.

<: -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', @@ -81,16 +60,22 @@ print '' x 3; printf '', scalar @{ $versions{$_} } for @browsers; print "\n"; -print ''; -print 'feature'; -printf('%s', - scalar @{ $versions{$_} }, - do { - my $name = $caniuse->{agents}->{$_}->{browser}; - length $name < 16 ? $name : $caniuse->{agents}->{$_}->{abbr}; - }, -) for @browsers; -print '%'; +my $header = join('', + '', + 'feature', + (map { + sprintf('%s', + scalar @{ $versions{$_} }, + sum(values %{ $canihas->{$_} }), + do { + my $name = $caniuse->{agents}->{$_}->{browser}; + length $name < 16 ? $name : $caniuse->{agents}->{$_}->{abbr}; + }, + ) + } @browsers), + '%', +); +print '', $header; # preceding row without any colspan to work around gecko bug print "\n"; print '' x 3; @@ -178,6 +163,7 @@ for my $id (sort { }); print '', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100; } +print '', $header; print ''; sub paddedver { @@ -196,6 +182,19 @@ sub showversions { } :> +