X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/81f63c446be472807c37b97ce6c6cd675bd198c6..86a6750572ee3fa30d006a4edce6d5c188726a17:/browser.plp diff --git a/browser.plp b/browser.plp index c24df9e..80369d9 100644 --- a/browser.plp +++ b/browser.plp @@ -4,7 +4,7 @@ no if $] >= 5.018, warnings => 'experimental::smartmatch'; Html({ title => 'browser compatibility cheat sheet', - version => '1.4', + version => '1.5', description => [ "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)", "comparing support and usage share for all popular browser versions.", @@ -36,11 +36,14 @@ my %CSTATS = ( 'p d' => 'l2', 'a d' => 'l2', 'y' => 'l5', + 'y #' => 'l4', 'y x' => 'l5 ex', + 'y x #' => 'l4 ex', 'a' => 'l3', 'a x' => 'l3 ex', 'p' => 'l2', 'u' => 'l0', + 'u d' => 'l2', ); my %DSTATS = ( u => 'unknown', @@ -83,8 +86,11 @@ while (my ($browser, $row) = each %{ $caniuse->{agents} }) { ]; } -print <<''; -
Alternate rendition of Fyrd's when can I use... page +my $ref = showlink('Can I use', 'https://caniuse.com/'); +$ref =~ s/(?=>)/ title="updated $_"/ + for map { s/[\sT].*//r } $caniuse->{-date} || (); +$ref = "Fyrd's $ref page"; +say '
Alternate rendition of '.$ref;
my ($canihas, $usage);
my $minusage = $get{threshold} // 1;
@@ -106,7 +112,7 @@ given ($get{usage} // 'wm') {
my $ref = $canihas->{-title} || 'unknown';
$ref = showlink($ref, $_)
for $canihas->{-site} || $canihas->{-source} || ();
- $ref .= " $_" for $canihas->{-date} || ();
+ $ref =~ s/(?=>)/ title="updated $_"/ for $canihas->{-date} || ();
print "\nwith $ref browser usage statistics";
}
@@ -193,11 +199,11 @@ $canihas ||= {
} @browsers
}; # fallback hash based on release semantics
-my $usagepct = 1; # score multiplier for 0..100 result
-# normalise usage percentage to only include shown browsers
-$usagepct = 100.01 / featurescore({ # yes for every possible version
- map { $_ => { map {$_ => 'y'} map { @{$_} } @{$versions{$_}} } } keys %versions
-});
+# score multiplier for percentage of all browser versions
+my $usagepct = 99.99 / sum(
+ map { $_->{-total} // values %{$_} } values %{$canihas}
+);
+
$_->{usage} = featurescore($_->{stats}) * $usagepct
for values %{ $caniuse->{data} };
@@ -232,18 +238,18 @@ print '', $header;
# preceding row without any colspan to work around gecko bug
print "\n";
for my $browser (@browsers) {
- for (@{ $versions{$browser} }) {
+ for my $span (@{ $versions{$browser} }) {
my $lastver = first {
!defined $caniuse->{agents}->{$browser}->{verrelease}->{$_} # stable
- } reverse @{$_};
+ } reverse @{$span};
printf(' %s',
join(' ',
- sprintf('%.1f%%', sum(@{ $canihas->{$browser} }{@$_}) * $usagepct),
- 'version ' . showversions(@{$_}, undef),
- $_->[-1] eq $lastver ? () : '(development)',
+ sprintf('%.1f%%', sum(@{ $canihas->{$browser} }{ @{$span} }) * $usagepct),
+ 'version ' . showversions(@{$span}, undef),
+ $span->[-1] eq $lastver ? () : '(development)',
),
!defined $lastver && ' class="ex"',
- showversions($lastver),
+ showversions($lastver // $span->[0]),
);
}
}
@@ -413,6 +419,7 @@ sub saybrowsercols {
));
$title .= "\n$_" for notestotitle(@notes);
+ $prev .= ' #' if @notes and $prev =~ /^y/;
printf(' %s',
join(' ',
X => $CSTATS{$prev},
@@ -423,7 +430,7 @@ sub saybrowsercols {
),
scalar @span,
$title,
- showversions($span[0]->[0], @span > 1 ? $span[-1]->[-1] : ()),
+ showversions($span[0]->[0], @span > 1 && defined $ver ? $span[-1]->[-1] : ()),
);
undef $prev;
@span = ();
@@ -455,9 +462,9 @@ say '';
sub paddedver {
# normalised version number comparable as string (cmp)
- shift =~ /(?:.*-|^)(\d*)(.*)/;
+ $_[0] =~ m/(?:.*-|^)(\d*)(.*)/;
# matched (major)(.minor) of last value in range (a-B)
- return sprintf('%02d', $1 || 99) . $2;
+ return sprintf('%02d', length $1 ? $1 : 99) . $2;
}
sub showversions {
@@ -474,6 +481,7 @@ sub showversions {
supported
+ annotated
partial
optional
missing
@@ -511,5 +519,7 @@ sub showversions {
-
+