X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/3d1587c2e784bae0642f9d788d82936282ca61ea..d2ca80f8d1714a6ea6f8184cfa58b67bf0720f2c:/browser.plp
diff --git a/browser.plp b/browser.plp
index d623a34..9a865d4 100644
--- a/browser.plp
+++ b/browser.plp
@@ -39,7 +39,6 @@ given ($get{usage} // 'wm') {
:>.
-
<:
my $caniuse = do 'browser-support.inc.pl' or die $! || $@;
$_->{verrelease} = {
@@ -59,6 +58,20 @@ my %CSTATS = (
'p p' => 'l2',
'u' => 'l0',
);
+my %DSTATS = (
+ u => 'unknown',
+ n => 'unsupported',
+ p => 'plugin required',
+ j => 'javascript required',
+ a => 'partial',
+ y => 'supported',
+ x => sub {
+ join(' ',
+ 'requires prefix',
+ (map "-$_-", $caniuse->{agents}->{$_[0]}->{prefix} // ()),
+ );
+ },
+);
my %CSTATUS = (
unoff => 'l1', # unofficial
wd => 'l3', # draft
@@ -103,8 +116,11 @@ my $header = join('',
'
feature',
(map {
my $name = $caniuse->{agents}->{$_}->{browser};
- sprintf(' | %s',
+ sprintf(' | %s',
scalar @{ $versions{$_} },
+ join(' ', map {"b-a-$_"} grep {$_}
+ $_, $caniuse->{agents}->{$_}->{prefix},
+ ),
join(' ',
sprintf('%.1f%%', sum(values %{ $canihas->{$_} })),
$name,
@@ -122,8 +138,11 @@ print '', $header;
print "\n";
print '' x 3;
for my $browser (@browsers) {
- printf(' | %s',
- $canihas->{$browser}->{$_},
+ printf(' | %s',
+ join(' ',
+ sprintf('%.1f%%', $canihas->{$browser}->{$_}),
+ "version $_",
+ ),
(map {
defined $_ && !$_ && ' class="ex"'
} $caniuse->{agents}->{$browser}->{verrelease}->{$_}),
@@ -131,11 +150,12 @@ for my $browser (@browsers) {
) for @{ $versions{$browser} };
}
print ' | ' x 1;
-print " | \n";
+say '';
+say ' | ', $header, '';
sub featurescore {
# relative amount of support for given feature
- state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 };
+ state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, 'p p'=>2, p=>1 };
my $rank = 0;
if (my $row = shift) {
if ($canihas) {
@@ -181,15 +201,15 @@ sub saytitlecol {
sprintf("try { %s; return false } catch(err) { return true }",
"document.getElementById('$id').classList.toggle('target')",
),
- $_,
+ Entity($_),
);
} $row->{title};
print '
';
s/\.?$/./, print "
$_
" for map { ref $_ ? @$_ : $_ || () }
- $row->{description}, $row->{notes};
- printf 'Resources: %s.', join(', ',
- map { qq(
$_->{title}) } @$_
- ) for grep { @$_ } $row->{links} // ();
+ Entity($row->{description}), formathtml($row->{notes}); # sic
+ printf 'Resources: %s.', join(', ', map {
+ sprintf '
%s', EscapeHTML($_->{url}), $_->{title}
+ } @$_) for grep { @$_ } $row->{links} // ();
print '
';
}
@@ -214,7 +234,7 @@ sub saybrowsercols {
unless (!defined $prev
or ref $data eq 'HASH' && $data->{$prev} ~~ $data->{$ver}) {
my $usage = sum(map { $canihas->{$browser}->{$_} } @span);
- printf '
%s',
+ printf ' | %s',
join(' ',
X => $CSTATS{ ref $data eq 'HASH' && $data->{$prev} || 'u' },
!$usage ? ('p0') : ('p',
@@ -224,7 +244,12 @@ sub saybrowsercols {
sprintf('pp%02d', $usage / $scorediv),
),
scalar @span,
- $usage,
+ sprintf('%.1f%% %s', $usage, join(', ',
+ map { ref $_ eq 'CODE' ? $_->($browser) : $_ }
+ map { $DSTATS{$_} // () }
+ map { split / /, $_ }
+ ref $data eq 'HASH' && $data->{$prev} || 'u'
+ )),
showversions(@span),
undef $prev;
@span = ();
@@ -242,6 +267,7 @@ sub sayusagecol {
print ' | ', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100;
}
+say ' | ';
for my $id (sort {
featurescore($caniuse->{data}->{$b}->{stats})
<=> featurescore($caniuse->{data}->{$a}->{stats})
@@ -254,8 +280,18 @@ for my $id (sort {
sayusagecol($id);
say '';
}
-print '', $header;
-print '';
+say '';
+say '';
+
+sub formathtml {
+ my $ref = defined wantarray ? [@_] : \@_;
+ for (@$ref) {
+ s/& (?!\w)/&/gx;
+ s/< \s/</gx;
+ s/\n\K\n/
/g;
+ }
+ return @$ref;
+}
sub paddedver {
# normalised version number comparable as string (cmp)
@@ -272,8 +308,7 @@ sub showversions {
return join('â', @span);
}
-:>
-
+:>
@@ -313,6 +348,6 @@ sub showversions {
-
-
+
+