X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/068f457f9a60a17ca141d3b90bd7dee9aa7267bc..044c816621892378582d969646276a569ac4eb06:/browser.plp?ds=inline
diff --git a/browser.plp b/browser.plp
index 16aad08..fc04389 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({
@@ -8,7 +9,7 @@ Html({
description =>
"caniuse.",
keywords => [qw'html css browser feature'],
- stylesheet => [qw'light dark circus mono red'],
+ stylesheet => [qw'circus dark mono red light'],
data => ['browser-support.inc.pl'],
});
@@ -19,26 +20,28 @@ Html({
with Wikimedia
browser usage statistics.
+
<:
my $caniuse = do 'browser-support.inc.pl' or die $! || $@;
my %CSTATS = (
- n => 'di-b',
- y => 'di-aa',
- a => 'di-d',
- 'a x' => 'di-d',
- j => 'di-prop',
- p => 'di-prop',
- 'p j' => 'di-prop',
- 'y x' => 'di-a',
+ 'n' => 'l0',
+ 'y' => 'l6',
+ 'y x' => 'l5',
+ 'a' => 'l4',
+ 'a x' => 'l4',
+ 'p j' => 'l2',
+ 'j' => 'l2',
+ 'p' => 'l2',
+ 'u' => 'l9',
);
my %CSTATUS = (
- unoff => 'di-rare', # unofficial
- wd => 'di-b', # draft
- pr => 'di-prop', # proposed
- cr => 'di-d', # candidate
- rec => 'di-a', # recommendation
- ietf => 'di-aa', # standard
+ unoff => 'l0', # unofficial
+ wd => 'l4', # draft
+ cr => 'l5', # candidate
+ pr => 'l5', # proposed
+ rec => 'l6', # recommendation
+ ietf => 'l6', # standard
);
my @browsers = qw(trident gecko webkit_saf webkit_chr presto);
my %versions;
@@ -48,9 +51,22 @@ if (my ($somerow) = values %{ $caniuse->{data} }) {
}
}
-my $canihas = do 'browser-usage.inc.pl' or do {
+my $canihas = do 'browser-usage.inc.pl' || do {
printf "
Browser usage data not found: %s.
\n", $_
for $! || $@;
+ +{
+ map {
+ $_ => +{
+ map {
+ ($_->[4] => 0 ), # future
+ ($_->[3] => .5), # next
+ ($_->[0] => 5 ), # past
+ ($_->[1] => 10 ), # previous
+ ($_->[2] => 30 ), # current
+ } $caniuse->{agents}->{$_}->{versions}
+ }
+ } @browsers
+ }; # fallback hash based on release semantics
};
my $scorediv = (max(map { sum(values %$_) } values %$canihas) // 1) / 100;
@@ -59,16 +75,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;
@@ -123,7 +145,14 @@ for my $id (sort {
my $cell = $_ ? lc $_->[0] : '-';
print ' | ', $cell;
}
- printf ' | %s', $row->{description}, $row->{title};
+ print ' | ', $row->{title};
+ print '';
+ s/\.?$/./, print " $_ " for map { ref $_ ? @$_ : $_ || () }
+ $row->{description}, $row->{notes};
+ printf 'Resources: %s.', join(', ',
+ map { qq( $_->{title}) } @$_
+ ) for $row->{links} // ();
+ print ' ';
for ($row->{status}) {
my $cell = $_ // '-';
$cell = sprintf '%s', $_, $cell for $row->{spec} // ();
@@ -138,8 +167,12 @@ for my $id (sort {
my $usage = sum(map { $canihas->{$browser}->{$_} } @span);
printf ' | %s',
join(' ',
- $CSTATS{ $data->{$browser}->{$prev} },
- sprintf('opacity%.0f', $usage / $scorediv),
+ X => $CSTATS{ $data->{$browser}->{$prev} },
+ !$usage ? ('p0') : ('p',
+ sprintf('p%01d', $usage / 10),
+ sprintf('p%02d', $usage),
+ ),
+ sprintf('pp%02d', $usage / $scorediv),
),
scalar @span,
$usage,
@@ -156,6 +189,7 @@ for my $id (sort {
});
print ' | ', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100;
}
+print ' | |
', $header;
print '';
sub paddedver {
@@ -173,18 +207,29 @@ sub showversions {
return join('â', @span);
}
-:>
+:>
+
- supported
- | prefixed
- | partial
- | external (js/plugin)
- | missing
+ | supported
+ | prefixed
+ | partial
+ | external (js/plugin)
+ | missing
|
+
+ Usage percentage:
+ 0 -
+ .01 -
+ 1-9 -
+ 10 -
+ 20 -
+ majority
+
+