browser: full score for prefixed features
[sheet.git] / browser.plp
index c340160833f3875e6536b014012af927124dc974..73db2a9e1c06b2863e2ef2facb1eea4886dccc9e 100644 (file)
@@ -42,16 +42,21 @@ given ($get{usage} // 'wm') {
 <div id="browser">
 <:
 my $caniuse = do 'browser-support.inc.pl' or die $! || $@;
+$_->{verrelease} = {
+       # mark last two (future) versions as unreleased, ensure current isn't
+       map { $_->[-1] => 0, $_->[-2] => 0, $_->[-3] => undef } $_->{versions}
+} for values %{ $caniuse->{agents} };
 
 my %CSTATS = (
        'n'   => 'l1',
        'y'   => 'l5',
-       'y x' => 'l4',
+       'y x' => 'l5 ex',
        'a'   => 'l3',
-       'a x' => 'l3',
+       'a x' => 'l3 ex',
        'p j' => 'l2',
        'j'   => 'l2',
        'p'   => 'l2',
+       'p p' => 'l2',
        'u'   => 'l0',
 );
 my %CSTATUS = (
@@ -113,8 +118,12 @@ print '<thead>', $header;
 print "\n<tr>";
 print '<td>' x 3;
 for my $browser (@browsers) {
-       printf('<td title="%.1f%%">%s',
-               $canihas->{$browser}->{$_}, showversions($_),
+       printf('<td title="%.1f%%"%s>%s',
+               $canihas->{$browser}->{$_},
+               (map {
+                       defined $_ && !$_ && ' class="ex"'
+               } $caniuse->{agents}->{$browser}->{verrelease}->{$_}),
+               showversions($_),
        ) for @{ $versions{$browser} };
 }
 print '<td>' x 1;
@@ -122,7 +131,7 @@ print "</thead>\n";
 
 sub featurescore {
        # relative amount of support for given feature
-       state $statspts = { y=>10, 'y x'=>9, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 };
+       state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 };
        my $rank = 0;
        if (my $row = shift) {
                if ($canihas) {
@@ -183,7 +192,7 @@ for my $id (sort {
        for ($row->{status}) {
                my $cell = $_ // '-';
                $cell = sprintf '<a href="%s">%s</a>', $_, $cell for $row->{spec} // ();
-               printf '<td title="%s" class="%s">%s',
+               printf '<td title="%s" class="%s">%s',
                        $caniuse->{statuses}->{$_}, $CSTATUS{$_} // '', $cell;
        }
        for my $browser (@browsers) {
@@ -245,14 +254,14 @@ sub showversions {
 <div class="legend">
        <table class="glyphs"><tr>
        <td class="X l5">supported
-       <td class="X l4">prefixed
        <td class="X l3">partial
        <td class="X l2">external (js/plugin)
        <td class="X l1">missing
        <td class="X l0">unknown
+       <td class="X l0 ex">prefixed
        </table>
 
-       <div>
+       <p><: if ($usage) { :>
                Usage percentage:
                <span class="  p0">0</span> -
                <span class="p p0 p00">.01</span> -
@@ -260,7 +269,14 @@ sub showversions {
                <span class="p p1">10</span> -
                <span class="p p2">20</span> -
                <span class="p p5">majority</span>
-       </div>
+<: } else { :>
+               <table class="glyphs"><tr>
+                       <td class="p p1">previous version</td>
+                       <td class="p p3">current</td>
+                       <td class="p p0 p00">upcoming (within months)</td>
+                       <td class="  p0">future (within a year)</td>
+               </table>
+<: } :>        </p>
 
        <div class="right">
                <ul class="legend legend-set">