X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/d1ddd28cfe6234991725a44aa82ee956748398f8..2f52ab48dabb037b6ef93468a8ba2db6bc9c9428:/browser.plp diff --git a/browser.plp b/browser.plp index 0f5b704..5afabaf 100644 --- a/browser.plp +++ b/browser.plp @@ -47,9 +47,11 @@ my $caniuse = from_json($source, { my %CSTATS = ( n => 'di-b', y => 'di-aa', - a => 'di-d', - j => 'di-prop', - p => 'di-prop', + a => 'di-d', + 'a x' => 'di-d', + j => 'di-prop', + p => 'di-prop', + 'p j' => 'di-prop', 'y x' => 'di-a', ); my %CSTATUS = ( @@ -68,10 +70,10 @@ if (my ($somerow) = values %{ $caniuse->{data} }) { } } -my $canihas = do 'browser-usage.inc.pl'; -for ($! || $@ || ()) { - printf "

Browser usage data not found: %s.

\n", $_; -} +my $canihas = do 'browser-usage.inc.pl' or do { + printf "

Browser usage data not found: %s.

\n", $_ + for $! || $@; +}; my $scorediv = (max(map { sum(values %$_) } values %$canihas) // 1) / 100; print ''; @@ -84,6 +86,7 @@ print ''; print '
feature'; printf '%s', scalar @{ $versions{$_} }, $caniuse->{agents}->{$_}->{browser} for @browsers; +print '%'; # preceding row without any colspan to work around gecko bug print '
' x $_ for 3, (map { scalar @{ $versions{$_} } } @browsers), 1; @@ -91,9 +94,18 @@ print "\n"; sub featurescore { # relative amount of support for given feature - state $statspts = { y=>10, 'y x'=>9, a=>5, j=>2, p=>1 }; + state $statspts = { y=>10, 'y x'=>9, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 }; my $rank = 0; if (my $row = shift) { + if ($canihas) { + while (my ($browser, $versions) = each %$row) { + while (my ($version, $_) = each %$versions) { + $rank += $canihas->{$browser}->{$version} * $statspts->{$_}; + } + } + return $rank; + } + while (my ($browser, $vercols) = each %versions) { my $div = 0; # multiplier exponent (decreased to lower value) my @vers = map { $row->{$browser}->{$_} } @$vercols;