X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/b3b23b8e45537cadbfc4b5d4e939f145931e0a4b..e60ccb7426f287532b0cfb89632ff963698530b8:/browser.plp?ds=sidebyside diff --git a/browser.plp b/browser.plp index dcc7688..fe96312 100644 --- a/browser.plp +++ b/browser.plp @@ -1,10 +1,9 @@ <(common.inc.plp)><: use List::Util qw(sum max first); -no if $] >= 5.018, warnings => 'experimental::smartmatch'; Html({ title => 'browser compatibility cheat sheet', - version => '1.5', + version => '1.6', description => [ "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)", "comparing support and usage share for all popular browser versions.", @@ -14,20 +13,12 @@ Html({ html html5 css css3 svg javascript js dom mobile ie internet explorer firefox chrome safari webkit opera '], - stylesheet => [qw'circus dark mono red light'], data => ['data/browser/support.inc.pl'], }); say "
Alternate rendition of '.$ref;
my ($canihas, $usage);
my $minusage = $get{threshold} // 1;
-given ($get{usage} // 'wm') {
- when (!$_) {
- # none
- }
- when (!m{ \A [a-z]\w+ (?:/\d[\d-]*\d)? \z }x) {
+for ($get{usage} // 'wm') {
+ $_ or next; # none
+ unless (m{ \A [a-z]\w+ (?:/\d[\d-]*\d)? \z }x) {
Alert([
'Invalid browser usage data request',
'Identifier must be alphanumeric name or 0
.',
]);
+ next;
}
- $canihas = do "data/browser/usage-$_.inc.pl" or do {
- Alert('Browser usage data not found', $@ || $!);
- break;
+
+ $canihas = eval { Data("data/browser/usage-$_") } or do {
+ Alert('Browser usage data not found', ref $@ ? @{$@} : $@);
+ next;
};
$usage = $_;
my $ref = $canihas->{-title} || 'unknown';
@@ -198,7 +189,10 @@ $canihas ||= {
# score multiplier for percentage of all browser versions
my $usagepct = 99.99 / sum(
- map { $_->{-total} // values %{$_} } values %{$canihas}
+ map { $_->{-total} // values %{$_} }
+ map { $canihas->{$_} }
+ grep { !/^-/ }
+ keys %{$canihas}
);
$_->{usage} = featurescore($_->{stats}) * $usagepct
@@ -237,13 +231,15 @@ print "\n
$1
}gx;
+ s{ \(\K (?: \Qhttps://caniuse.com\E )? (?: /? \#feat= | / ) }{#}gx;
s{ \[ ([^]]*) \] \( ([^)]*) \) }{$1}gx;
}
return @html;
@@ -375,9 +375,9 @@ sub saybrowsercols {
my $data = $feature->{stats}->{$browser};
if (ref $data eq 'ARRAY') {
# special case for unsupported
- my $release = $caniuse->{agents}->{$browser}->{verrelease};
$data = {
- map { $_ => defined $release->{$_} ? 'u' : 'n' } keys %$release
+ map { $_ => 'n' }
+ keys %{ $caniuse->{agents}->{$browser}->{version_list} }
};
}
@@ -386,15 +386,15 @@ sub saybrowsercols {
my $compare = (
!defined $ver ? undef : # last column if nameless
ref $data ne 'HASH' ? '' : # unclassified if no support hash
- $data->{ $ver->[-1] } // $prev # known or inherit from predecessor
- // (grep { defined } @{$data}{ map { $_->[0] } @{ $versions{$browser} } })[0]
- ~~ 'n' && 'n' # first known version is unsupported
+ (first { defined } @{$data}{ reverse @{$ver} }) # last known version
+ // $prev # inherit from predecessor
|| 'u' # unsure
);
- unless (!defined $prev or $prev ~~ $compare) {
- my @vercover = (map { @{$_} } @span);
+ if (defined $prev and not $prev ~~ $compare) {
+ # different columns
+ my @vercover = (map { @{$_} } @span); # accumulated conforming versions
for ($ver ? @{$ver} : ()) {
- $data->{$_} eq $data->{$vercover[-1]} or last;
+ last if defined $data->{$_}; # until different
push @vercover, $_; # matches from next span start
}
my $usage = sum(@{ $canihas->{$browser} }{@vercover});
@@ -416,6 +416,7 @@ sub saybrowsercols {
));
$title .= "\n$_" for notestotitle(@notes);
+ $prev .= ' #' if @notes and $prev =~ /^y/;
printf('supported + | annotated | partial | optional | missing |