browser: version notes in support description hover
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 4 Feb 2015 05:16:13 +0000 (06:16 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 5 Feb 2015 21:46:21 +0000 (22:46 +0100)
Display notes_by_num option set for recent caniuse entries.

browser.plp

index 1b9c2d2f26cd440ebff0d3bdffb4d9f1bb5caf5d..beff4a9a99a251344883eb8d660de8f713541def 100644 (file)
@@ -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 '<td class="%s" colspan="%d" title="%s">%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('<td class="%s" colspan="%d" title="%s">%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 = ();
                }