only set up input bindings for clickable keys
[sheet.git] / cc.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 use open IO => ':utf8';
6
7 our $VERSION = 'v1.0';
8
9 $header{content_type} = 'text/html; charset=utf-8';
10
11 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
12  "http://www.w3.org/TR/html4/loose.dtd">
13 <html>
14
15 <head>
16 <title>country code cheat sheet</title>
17 <meta http-equiv="content-type" content="utf-8">
18 <link rel="stylesheet" type="text/css" media="all" href="/base.css">
19 </head>
20
21 <body>
22 <h1>Country codes</h1>
23
24 <:
25 my $cc = do 'cc.inc.pl';
26
27 sub quote {
28         local $_ = shift;
29         s/"/&quot;/g;
30         s/</&lt;/g;
31         s/>/&gt;/g;
32         return $_;
33 }
34
35 {
36         printf '<table class="glyphs">';
37         print '<col>';
38         for my $section (qw{thead}) {
39                 print "<$section><tr><th>↱";
40                 print '<th>', $_ for 'a' .. 'z';
41                 print "\n";
42         }
43         print '<tbody>';
44         for my $row ('a' .. 'z') {
45                 print '<tr><th>', $row;
46                 for my $col ('a' .. 'z') {
47                         my $code = $row . $col;
48                         my $country = $cc->{$code} or do {
49                                 print $code =~ /^x|^q[m-z]|^aa|^zz/ ? '<td class="X Co">' : '<td>';
50                                 next;
51                         };
52                         my $img = sprintf '<img src="/flag/%s.png" alt="%s">', $code, $code
53                                 if -e "flag/$code.png";
54                         printf "\n".'<td class="%s" title="%s">%s',
55                                 $img ? 'X '.$country->[1] : '', quote($country->[0]), $img;
56                 }
57                 print "\n";
58         }
59         print "</table>\n";
60 }
61
62 :>
63 <hr>
64
65 <div class="legend">
66         <table class="glyphs"><tr>
67         <td class="X c-af">africa
68         <td class="X c-eu">europe
69         <td class="X c-as">asia
70         <td class="X c-oc">oceania
71         <td class="X c-aa">antarctica
72         <td class="X c-sa">south america
73         <td class="X c-na">north america
74         <td class="X Xi">reserved
75         <td class="X Co">user-assigned
76         </table>
77 </div>
78
79 <p class="footer">
80         <a href="/" rel="home">sheet.shiar.nl</a>/charset
81         <a href="git://git.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= $VERSION :></a>
82         created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
83         <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
84            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a>
85 </p>
86
87 </html>