X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/219cb22723b29e968bc740d1f34b3b09265a9c08..f73ec42018bd7c627db8742c92636074033f19e4:/browser.plp diff --git a/browser.plp b/browser.plp index a78e0ec..a101d74 100644 --- a/browser.plp +++ b/browser.plp @@ -80,17 +80,18 @@ my %CSTATUS = ( other => 'l0', # non-w3 ); 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 ]; - } +while (my ($browser, $row) = each %{ $caniuse->{agents} }) { + $versions{$browser} = [ + sort { paddedver($a) cmp paddedver($b) } grep { defined } + @{ $row->{versions} } + ]; } print <<'';

Alternate rendition of Fyrd's when can I use... page my ($canihas, $usage); -my $minusage = $get{threshold} // .7; +my $minusage = $get{threshold} // 1; given ($get{usage} // 'wm') { when (!$_) { # none @@ -195,13 +196,14 @@ $canihas ||= { } } @browsers }; # fallback hash based on release semantics -my $usagemax = (max(map { ref $_ eq 'HASH' && sum(values %$_) } values %$canihas) // 1) / 100; 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 }); +$_->{usage} = featurescore($_->{stats}) * $usagepct + for values %{ $caniuse->{data} }; print ''; print ''; # should match first thead row @@ -311,6 +313,15 @@ sub formatnotes { return @html; } +sub notestotitle { + my @notes = @_; + for (@notes) { + EscapeHTML($_); + s{ \[ ([^]]*) \] \( [^)]* \) }{$1}gx; # strip link urls + } + return @notes; +} + sub saytitlecol { my ($id) = @_; my $row = $caniuse->{data}->{$id}; @@ -396,7 +407,7 @@ sub saybrowsercols { map { split / /, $_ } $prev )); - $title .= "\n".EscapeHTML($_) for @notes; + $title .= "\n$_" for notestotitle(@notes); printf(''; for my $id (sort { - featurescore($caniuse->{data}->{$b}->{stats}) - <=> featurescore($caniuse->{data}->{$a}->{stats}) + $caniuse->{data}->{$b}->{usage} <=> $caniuse->{data}->{$a}->{usage} } keys %{ $caniuse->{data} }) { $caniuse->{data}->{$id}->{stats} or next; # skip metadata [summary] printf '', $id;
%s', join(' ', @@ -405,7 +416,6 @@ sub saybrowsercols { sprintf('p%01d', $usage * ($usagepct - .0001) / 10), sprintf('p%02d', $usage * ($usagepct - .0001)), ), - sprintf('pp%02d', $usage / $usagemax), ), scalar @span, $title, @@ -421,13 +431,12 @@ sub saybrowsercols { sub sayusagecol { my ($id) = @_; - print '', int featurescore($caniuse->{data}->{$id}->{stats}) * $usagepct; + print '', int $caniuse->{data}->{$id}->{usage}; } say '