- if (my $table = eval { Data($inc) }) {
- printf '<img src="/%s" />', $_ for $table->{image} || ();
- $inc = $table->{title};
+ my $table = $idx{$inc};
+ my $title = $table && $table->{title} || $inc;
+
+ unless (@sample) {
+ if ($table and my $img = $table->{image}) {
+ EscapeHTML $name = $table->{imagealt} // $img =~ m{.*/([^/.]*)};
+ print qq{<img src="/$img" alt="$name" />};
+ }
+ printf '<figcaption>%s</figcaption>', $title;
+ say '</a></figure>';
+ }
+ else {
+ print $title;
+ print '</a>', "\n\t";
+ my $keys = Shiar_Sheet::Keyboard->new($table);
+ for my $mode ($keys->{mode} ? sort keys %{ $keys->{mode} } : '') {
+ my %inventory;
+ $inventory{$_}++ for grep { /^g[2-9]/ } map { s/ (?!ext).*//r }
+ values %{ $keys->{def}{$mode} };
+ print '<span class=graph>';
+ print "<label>$_</label>" for $keys->{key}{$mode} =~ s/\s.*//r || ();
+ for my $g (sort keys %inventory) {
+ printf '<span class="%s" style="width:%.0f%%" title="%3$d %4$s"> %s</span>',
+ $g, $_/$most*100, $_,
+ join(' ', map {
+ $keys->{flag}{$_}[0] || 'extra' # legend label of each class
+ } reverse split / /, $g)
+ for $inventory{$g};
+ }
+ say '</span>';
+ }
+ print "\t<td class=ni>";
+ print join ' ', map { $caticon{$_} // () } split m{/}, $keys->{category};
+ say '';
+ $keys->print_key('', $_, ($keys->{def}{''}{$_} // 'ni') =~ s/ mode\S*//r)
+ for @sample;
+ say '</tr>';