X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/044c816621892378582d969646276a569ac4eb06..fe2afa53dfb9a89386d31bd3fd80f4bfdfa16030:/browser.plp diff --git a/browser.plp b/browser.plp index fc04389..a4af534 100644 --- a/browser.plp +++ b/browser.plp @@ -43,13 +43,14 @@ my %CSTATUS = ( rec => 'l6', # recommendation ietf => 'l6', # standard ); -my @browsers = qw(trident gecko webkit_saf webkit_chr presto); my %versions; if (my ($somerow) = values %{ $caniuse->{data} }) { while (my ($browser, $row) = each %{ $somerow->{stats} }) { $versions{$browser} = [ sort { paddedver($a) cmp paddedver($b) } keys %$row ]; } } +my @browsers = grep { $versions{$_} } + qw(trident gecko webkit_saf ios_saf webkit_chr android presto op_mob op_mini); my $canihas = do 'browser-usage.inc.pl' || do { printf "

Browser usage data not found: %s.

\n", $_ @@ -109,6 +110,7 @@ sub featurescore { if (my $row = shift) { if ($canihas) { while (my ($browser, $versions) = each %$row) { + ref $versions eq 'HASH' or next; while (my ($version, $_) = each %$versions) { $rank += $canihas->{$browser}->{$version} * $statspts->{$_}; } @@ -145,13 +147,21 @@ for my $id (sort { my $cell = $_ ? lc $_->[0] : '-'; print '', $cell; } - print '', $row->{title}; + print '', map { + sprintf('%s', + "#$id", + sprintf("try { %s; return false } catch(err) { return true }", + "document.getElementById('$id').classList.toggle('target')", + ), + $_, + ); + } $row->{title}; print '
'; s/\.?$/./, print "

$_

" for map { ref $_ ? @$_ : $_ || () } $row->{description}, $row->{notes}; printf 'Resources: %s.', join(', ', map { qq($_->{title}) } @$_ - ) for $row->{links} // (); + ) for grep { @$_ } $row->{links} // (); print '
'; for ($row->{status}) { my $cell = $_ // '-'; @@ -163,11 +173,15 @@ for my $id (sort { my ($prev, @span); for my $ver (@{ $versions{$browser} }, undef) { unless (!defined $prev - or $data->{$browser}->{$prev} ~~ $data->{$browser}->{$ver}) { + or ref $data->{$browser} eq 'HASH' + && $data->{$browser}->{$prev} ~~ $data->{$browser}->{$ver}) { my $usage = sum(map { $canihas->{$browser}->{$_} } @span); printf '%s', join(' ', - X => $CSTATS{ $data->{$browser}->{$prev} }, + X => $CSTATS{ + ref $data->{$browser} ne 'HASH' ? 'u' : + $data->{$browser}->{$prev} // 'u' + }, !$usage ? ('p0') : ('p', sprintf('p%01d', $usage / 10), sprintf('p%02d', $usage), @@ -195,7 +209,7 @@ print ''; sub paddedver { # normalised version number comparable as string (cmp) shift =~ /^(\d*)(.*)/; - return sprintf('%02d', $1) . $2; + return sprintf('%02d', $1 || 0) . $2; } sub showversions { @@ -218,6 +232,7 @@ sub showversions { partial external (js/plugin) missing + unknown