simuformat (2293B)
1 #!/usr/bin/perl -w -CSAio 2 3 use utf8; 4 5 my @seps = @ARGV; 6 @ARGV = (); 7 8 print <<FOO; 9 <html> 10 <head> 11 <style type="text/css"> 12 table { 13 border-spacing: 0; 14 } 15 small { 16 font-size: 50%; 17 } 18 thead td, thead th { 19 border-bottom: 4px solid black; 20 } 21 tbody tr > td:nth-child(3) { 22 border-right: 4px solid black; 23 } 24 td { 25 text-align: center; 26 } 27 FOO 28 if (@seps) { 29 print join(", ", map { "tr:nth-child($_) > *" } @seps); 30 print <<FOO; 31 { 32 border-bottom: 1px solid black; 33 } 34 FOO 35 print join(", ", map { "tr:nth-child(" . ($_ + 1) . ") > *" } @seps); 36 print <<FOO; 37 { 38 border-top: 1px solid black; 39 } 40 FOO 41 print join(", ", map { "tr > *:nth-child(" . ($_ + 6) . ")" } @seps); 42 print <<FOO; 43 { 44 border-right: 1px solid black; 45 } 46 FOO 47 print join(", ", map { "tr > *:nth-child(" . ($_ + 7) . ")" } @seps); 48 print <<FOO; 49 { 50 border-left: 1px solid black; 51 } 52 FOO 53 } 54 print <<FOO; 55 td.no { 56 background: red; 57 } 58 td.yes { 59 background: cyan; 60 border: 1px solid darkcyan; 61 font-weight: bold; 62 } 63 td.points { 64 background: inherit; 65 } 66 td.sep { 67 background: black; 68 width: 3px; 69 height: 3px; 70 } 71 </style> 72 </head> 73 <body> 74 <table> 75 FOO 76 my $headed = 0; 77 my $j = 0; 78 while (<<>>) { 79 chomp; 80 my ($team, $games, $actualpoints, $fingames, $points, $elo, @probs) = split / /; 81 print "<thead><tr><th>Joukkue</th><th>O</th><th>P</th><th>Elo</th><th>O</th><th>Ennuste</th>" . join('', map { '<th>' . $_ . '.</th>' } 1..($#probs + 1)) . "</tr></thead>\n<tbody>\n" unless $headed++; 82 print "<tr><th>$team</th><td class=\"games\">$games</td><td class=\"actualpoints\">$actualpoints</td><td class=\"elo\">$elo</td><td class=\"fingames\">$fingames</td><td class=\"points\">$points</td>" . join("", map { $_ eq '+' ? '<td class="yes">' . $_ . '</td>' : $_ eq '-' ? '<td class="no">' . $_ . '</td>' : sprintf('<td style="border: 1px solid rgb(%.1f%%, 80%%, %.1f%%); padding: -1px; background-color: rgb(%.1f%%, 100%%, %.1f%%)">%s</td>', 80 - 80 * sqrt($_ / 100), 80 - 80 * sqrt($_ / 100), 100 - 100 * sqrt($_ / 100), 100 - 100 * sqrt($_ / 100), ($_ < 0.005 ? $_ > 0 ? sprintf("<small>10<sup>%.0f</sup></small>", log($_) / log(10)) : '<small>ε</small>' : $_ < 9.995 ? sprintf("%.2f", $_) : sprintf("%.1f", $_)) ) } @probs) . "</tr>\n"; 83 } 84 85 my $now = `LC_CTIME=fi_FI.UTF-8 date`; 86 print <<FOO; 87 </tbody> 88 </table> 89 <small>Viimeksi päivitetty $now</small> 90 </body> 91 </html> 92 FOO