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 <<'';
}
} @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 '<table class="mapped">';
print '<col span="3">'; # should match first thead row
print "\n<tr>";
for my $browser (@browsers) {
for (@{ $versions{$browser} }) {
- my $lastver = $_->[-1];
- my $release = $caniuse->{agents}->{$browser}->{verrelease}->{$lastver};
- my $future = defined $release;
+ my $lastver = first {
+ !defined $caniuse->{agents}->{$browser}->{verrelease}->{$_} # stable
+ } reverse @{$_};
printf('<td title="%s"%s>%s',
join(' ',
sprintf('%.1f%%', sum(@{ $canihas->{$browser} }{@$_}) * $usagepct),
- $future ? 'development' : (),
- 'version ' . join(', ', @{$_}),
+ 'version ' . showversions(@{$_}, undef),
+ $_->[-1] eq $lastver ? () : '(development)',
),
- $future && ' class="ex"',
+ !defined $lastver && ' class="ex"',
showversions($lastver),
);
}
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};
map { split / /, $_ }
$prev
));
- $title .= "\n".EscapeHTML($_) for @notes;
+ $title .= "\n$_" for notestotitle(@notes);
printf('<td class="%s" colspan="%d" title="%s">%s',
join(' ',
sprintf('p%01d', $usage * ($usagepct - .0001) / 10),
sprintf('p%02d', $usage * ($usagepct - .0001)),
),
- sprintf('pp%02d', $usage / $usagemax),
),
scalar @span,
$title,
- showversions($span[0]->[0], @span > 1 ? ($span[-1]->[-1]) : ()),
+ showversions($span[0]->[0], @span > 1 ? $span[-1]->[-1] : ()),
);
undef $prev;
@span = ();
sub sayusagecol {
my ($id) = @_;
- print '<td>', int featurescore($caniuse->{data}->{$id}->{stats}) * $usagepct;
+ print '<td>', int $caniuse->{data}->{$id}->{usage};
}
say '<tbody>';
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 '<tr id="%s">', $id;
}
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);
}