X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/6e61b5be6d46cffa66793d5d78f51bcfad6e65ca..dc6b482b5e7e1d3d35b5193fc820c5e1afc29a6e:/browser.plp diff --git a/browser.plp b/browser.plp index 5c3f769..7e096b0 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.", @@ -193,11 +193,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} }; @@ -243,7 +243,7 @@ for my $browser (@browsers) { $span->[-1] eq $lastver ? () : '(development)', ), !defined $lastver && ' class="ex"', - showversions($lastver), + showversions($lastver // $span->[0]), ); } } @@ -455,9 +455,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 {