<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>
+<:
+my $canihas = do 'browser-usage.inc.pl'
+ or printf "<p>Browser usage data not found: <em>%s</em>.</p>\n", $! || $@;
+
+print "with $_ browser usage statistics." for map {
+ my $ref = $_->{-source} || 'unknown';
+ $ref = sprintf '<a href="%s">%s</a>', $_, $ref for $_->{-url} || ();
+ $ref .= " $_" for $_->{-date} || ();
+ $ref
+} $canihas || ();
+:>
+</p>
<div id="browser">
<:
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 {
+ ($_->[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 { ref $_ eq 'HASH' && sum(values %$_) } values %$canihas) // 1) / 100;
print '<table class="mapped">';
print '<col>' x 3;
our %count;
our $mobile;
+if (m{<td class=hl>} .. m{</?td>}) {
+ $count{-url} = 'http://stats.wikimedia.org/archive/squid_reports/';
+ $count{-source} = 'Wikimedia';
+ $count{-date} = $1 if m{ period: (?:\d+ )?(\w+ \d+) };
+ next;
+}
+
# select relevant columns
/>Browser versions(.*)/ ... m{</table>} && last or next;
my ($tr, $id, $count2, $count) = split /(?:<[^>]*>)+/;