From 153fca5bc148960bb538bfc43b79b944608d2b2f Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 4 Feb 2015 06:16:13 +0100 Subject: [PATCH] browser: version notes in support description hover Display notes_by_num option set for recent caniuse entries. --- browser.plp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/browser.plp b/browser.plp index 1b9c2d2..beff4a9 100644 --- a/browser.plp +++ b/browser.plp @@ -312,7 +312,8 @@ sub saystatuscol { sub saybrowsercols { my ($id, $browser) = @_; - my $data = $caniuse->{data}->{$id}->{stats}->{$browser}; + my $feature = $caniuse->{data}->{$id}; + my $data = $feature->{stats}->{$browser}; if (ref $data eq 'ARRAY') { # special case for unsupported my $release = $caniuse->{agents}->{$browser}->{verrelease}; @@ -333,7 +334,22 @@ sub saybrowsercols { ); unless (!defined $prev or $prev ~~ $compare) { my $usage = sum(@{ $canihas->{$browser} }{ map { @{$_} } @span }); - printf '%s', + + # strip #\d note references from support class + my @notes; + push @notes, $feature->{notes_by_num}->{$1} + while $prev =~ s/\h \# (\d+) \b//x; + + # prepare version hover details + my $title = sprintf('%.1f%% %s', $usage * $usagepct, join(', ', + map { ref $_ eq 'CODE' ? $_->($browser) : $_ } + map { $DSTATS{$_} // () } + map { split / /, $_ } + $prev + )); + $title .= "\n".EscapeHTML($_) for @notes; + + printf('%s', join(' ', X => $CSTATS{$prev}, !$usage ? ('p0') : ('p', @@ -343,13 +359,9 @@ sub saybrowsercols { sprintf('pp%02d', $usage / $usagemax), ), scalar @span, - sprintf('%.1f%% %s', $usage * $usagepct, join(', ', - map { ref $_ eq 'CODE' ? $_->($browser) : $_ } - map { $DSTATS{$_} // () } - map { split / /, $_ } - $prev - )), + $title, showversions($span[0]->[0], @span > 1 ? ($span[-1]->[-1]) : ()), + ); undef $prev; @span = (); } -- 2.30.0