:>
<h1>Browser compatibility</h1>
-<p>Alternate view of Fyrd's <a href="http://caniuse.com/">when can I use...</a> page
-with <a href="http://stats.wikimedia.org/archive/squid_reports/">Wikimedia</a>
-browser usage statistics.</p>
+<p>Alternate view of Fyrd's <a href="http://caniuse.com/">when can I use...</a> page<:
+my ($canihas, $usage);
+given ($get{usage} // 'wm') {
+ when (!$_) {
+ # none
+ }
+ when (!/^\w+$/) {
+ printf "<p>Invalid browser usage data request: <em>%s</em>",
+ 'identifier must be alphanumeric name or <q>0</q>';
+ }
+ $canihas = do "browser-usage-$_.inc.pl" or do {
+ printf "<p>Browser usage data not found: <em>%s</em>", $! || $@;
+ break;
+ };
+ $usage = $_;
+ my $ref = $canihas->{-source} || 'unknown';
+ $ref = sprintf '<a href="%s">%s</a>', $_, $ref for $canihas->{-url} || ();
+ $ref .= " $_" for $canihas->{-date} || ();
+ print "\nwith $ref browser usage statistics";
+}
+:>.
+</p>
<div id="browser">
<:
my $caniuse = do 'browser-support.inc.pl' or die $! || $@;
my %CSTATS = (
- 'n' => 'l0',
- 'y' => 'l6',
- 'y x' => 'l5',
- 'a' => 'l4',
- 'a x' => 'l4',
+ 'n' => 'l1',
+ 'y' => 'l5',
+ 'y x' => 'l4',
+ 'a' => 'l3',
+ 'a x' => 'l3',
'p j' => 'l2',
'j' => 'l2',
'p' => 'l2',
- 'u' => 'l9',
+ 'u' => 'l0',
);
my %CSTATUS = (
- unoff => 'l0', # unofficial
- wd => 'l4', # draft
- cr => 'l5', # candidate
- pr => 'l5', # proposed
- rec => 'l6', # recommendation
- ietf => 'l6', # standard
+ unoff => 'l1', # unofficial
+ wd => 'l3', # draft
+ cr => 'l4', # candidate
+ pr => 'l4', # proposed
+ rec => 'l5', # recommendation
+ other => 'l5', # non-w3
+ ietf => 'l5', # standard
);
my %versions;
if (my ($somerow) = values %{ $caniuse->{data} }) {
my @browsers = grep { $versions{$_} }
qw(trident gecko webkit_saf ios_saf webkit_chr android presto op_mob op_mini);
-my $canihas = do 'browser-usage.inc.pl' || do {
- printf "<p>Browser usage data not found: <em>%s</em>.</p>\n", $_
- for $! || $@;
- +{
- map {
- $_ => +{
- map {
- ($_->[4] => 0 ), # future
- ($_->[3] => .5), # next
- ($_->[0] => 5 ), # past
- ($_->[1] => 10 ), # previous
- ($_->[2] => 30 ), # current
- } $caniuse->{agents}->{$_}->{versions}
- }
- } @browsers
- }; # fallback hash based on release semantics
-};
-my $scorediv = (max(map { sum(values %$_) } values %$canihas) // 1) / 100;
+$canihas ||= {
+ map {
+ $_ => +{
+ map {
+ my $zero = $#$_ - 2; # baseline index
+ ($_->[$zero - 2] => .5), # past
+ ($_->[$zero - 1] => 10 ), # previous
+ ($_->[$zero + 2] => 0 ), # future
+ ($_->[$zero + 1] => .5), # next
+ ($_->[$zero ] => 30 ), # current
+ } $caniuse->{agents}->{$_}->{versions}
+ }
+ } @browsers
+}; # fallback hash based on release semantics
+my $scorediv = (max(map { ref $_ eq 'HASH' && sum(values %$_) } values %$canihas) // 1) / 100;
print '<table class="mapped">';
print '<col>' x 3;
<div class="legend">
<table class="glyphs"><tr>
- <td class="X l6">supported
- <td class="X l5">prefixed
- <td class="X l4">partial
+ <td class="X l5">supported
+ <td class="X l4">prefixed
+ <td class="X l3">partial
<td class="X l2">external (js/plugin)
- <td class="X l0">missing
- <td class="X l9">unknown
+ <td class="X l1">missing
+ <td class="X l0">unknown
</table>
- <div>
+ <p><: if ($usage) { :>
Usage percentage:
<span class=" p0">0</span> -
<span class="p p0 p00">.01</span> -
<span class="p p1">10</span> -
<span class="p p2">20</span> -
<span class="p p5">majority</span>
- </div>
+<: } else { :>
+ <table class="glyphs"><tr>
+ <td class="p p1">previous version</td>
+ <td class="p p3">current</td>
+ <td class="p p0 p00">upcoming (within months)</td>
+ <td class=" p0">future (within a year)</td>
+ </table>
+<: } :> </p>
<div class="right">
<ul class="legend legend-set">
<li>default <strong>style</strong> is
<:= defined $get{style} && 'set to ' :><em><:= $style :></em>
+ <li><strong>usage</strong> source is
+ <:= !defined $get{usage} && 'default ' :><:= defined $usage ? "<em>$usage</em>" : 'not included (<em>0</em>)' :>
</ul>
</div>
</div>