Source of compare.plp

<(common.inc.plp)><:

my ($page, @colgroups) = split m{/+}, $Request || 'image';
$page !~ /\W/ or Html(), Abort('Invalid codec type request', 400);
my @feat = 'default';
my $title = "$page codecs";
my $info = eval { Data("compare/$page") };
if ($@) {
	$info = {};
}

Html({
	title => "$title cheat sheet",
	version => $info->{version} // '1.1',
	description => $info->{intro},
	keywords => [@{ $info->{keywords} // [] }, qw' feature comparison support benchmark '],
	data => ["data/compare/$page.json"],
	raw => '<style>td,th {width:8%} tbody th {white-space:nowrap}</style>',
});

%{$info}
	or Abort("Requested codec type <q>$page</q> not available", '404 request not found');

say "<h1>\u$title</h1>";
say "<p>$_</p>" for $info->{intro} // ();

my %BOOLSCORE = (101 => [5, '✔'], -1 => [1, '✘'], 0 => [0, 'n/a']);
:>

<div class="section">
<table class="mapped">
<:
@colgroups = @{ $info->{codec}->{default} } unless @colgroups;
my @codecs = map { @{ $info->{codec}->{$_} // [] } } @colgroups;
my @codeccols = @{$info->{codec}}{@codecs};

{
	print '<col>';
	printf "<colgroup span=%d>", scalar @{ $info->{codec}->{$_} }
		for @colgroups;
}
say '<thead><tr><th rowspan=2>';
say "\t", '<th>', $_->{name} for @codeccols;
print '<tr>';
print '<td>', substr($_->{available} // '', 0, 4) for @codeccols;
say '</thead>';

while (defined (my $feat = shift @feat)) {
	my $featinfo = $info->{feature}->{$feat} or next;
	unshift @feat, @{$_} for $featinfo->{children} // ();
	print '<tbody>' if $featinfo->{children}
		and not $info->{feature}->{ $feat[0] }->{children};
	$featinfo->{score} or next;
	printf '<tr><th>%s', $featinfo->{name} // $feat;
	for (@codecs) {
		my ($score, $data, $title) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_};
		my $level = $score && (int($score / 20) || 1); # 1-39..100 = 1..5
		if (not defined $data) {
			if (my $override = $BOOLSCORE{$score}) {
				($score, $data) = @{$override};
			}
			else {
				$data = '•' x ($level - 1); # ●
				$data .= '◦' if $score % 10; # ◐
			}
		}
		printf '<td class="l%d"', $level;
		printf ' title="%s"', EscapeHTML($_) for $title // ();
		print '>', $data;
	}
	say '</td>';
}

:></table>
</div>