browser: abbreviate multiple releases in versions row titles
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 27 Apr 2017 15:37:56 +0000 (17:37 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 29 May 2017 17:21:27 +0000 (19:21 +0200)
Individual version numbers are not really of interest (and may not actually
match usage data), and are much better represented as ranges (especially
with the huge amount of Chrome increments).

browser.plp

index a101d741e4fb2071e0499b9cd65b9c85601cae90..8ff9886f483331f52054a8ff4e325c7b03df3180 100644 (file)
@@ -243,8 +243,8 @@ for my $browser (@browsers) {
                printf('<td title="%s"%s>%s',
                        join(' ',
                                sprintf('%.1f%%', sum(@{ $canihas->{$browser} }{@$_}) * $usagepct),
-                               $future ? 'development' : (),
-                               'version ' . join(', ', @{$_}),
+                               'version ' . showversions(@{$_}, undef),
+                               $future ? '(development)' : (),
                        ),
                        $future && ' class="ex"',
                        showversions($lastver),
@@ -419,7 +419,7 @@ sub saybrowsercols {
                                ),
                                scalar @span,
                                $title,
-                               showversions($span[0]->[0], @span > 1 ? ($span[-1]->[-1]) : ()),
+                               showversions($span[0]->[0], @span > 1 ? $span[-1]->[-1] : ()),
                        );
                        undef $prev;
                        @span = ();
@@ -457,13 +457,14 @@ sub paddedver {
 }
 
 sub showversions {
-       my @span = ($_[0], @_>1 ? $_[-1] : ());
-       s/-.*// for $span[0];
+       # title to describe minumum version and optional maximum for multiple cells
+       my @span = (map { split /-/ } grep { defined } @_);
        for (@span) {
                s/^\./0./;
                s/x$/.*/;
-               s/.*-//;
        }
+       return $span[0] if @_ <= 1;
+       splice @span, 1, -1;
        return join('‒', @span);
 }