X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/7eef0272a71f7610177d3a617f947758e415d565..18390ca4b265302bb60246c40736ac72c3d801bb:/browser.plp diff --git a/browser.plp b/browser.plp index 005ab16..73db2a9 100644 --- a/browser.plp +++ b/browser.plp @@ -9,51 +9,89 @@ Html({ description => "caniuse.", keywords => [qw'html css browser feature'], - stylesheet => [qw'light dark circus mono red'], + stylesheet => [qw'circus dark mono red light'], data => ['browser-support.inc.pl'], }); :>
Alternate view of Fyrd's when can I use... page -with Wikimedia -browser usage statistics.
+Alternate view of Fyrd's when can I use... page<: +my ($canihas, $usage); +given ($get{usage} // 'wm') { + when (!$_) { + # none + } + when (!/^\w+$/) { + printf "
Invalid browser usage data request: %s",
+ 'identifier must be alphanumeric name or 0
';
+ }
+ $canihas = do "browser-usage-$_.inc.pl" or do {
+ printf "
Browser usage data not found: %s", $! || $@; + break; + }; + $usage = $_; + my $ref = $canihas->{-source} || 'unknown'; + $ref = sprintf '%s', $_, $ref for $canihas->{-url} || (); + $ref .= " $_" for $canihas->{-date} || (); + print "\nwith $ref browser usage statistics"; +} +:>. +
+Browser usage data not found: %s.
\n", $_ - for $! || $@; -}; -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 '' x 3; for my $browser (@browsers) { - printf(' | %s', - $canihas->{$browser}->{$_}, showversions($_), + printf(' | %s', + $canihas->{$browser}->{$_}, + (map { + defined $_ && !$_ && ' class="ex"' + } $caniuse->{agents}->{$browser}->{verrelease}->{$_}), + showversions($_), ) for @{ $versions{$browser} }; } print ' | ' x 1; @@ -89,11 +131,12 @@ print " | ', $cell; } - printf ' | %s', $row->{description}, $row->{title}; + print ' | ', map {
+ sprintf('%s',
+ "#$id",
+ sprintf("try { %s; return false } catch(err) { return true }",
+ "document.getElementById('$id').classList.toggle('target')",
+ ),
+ $_,
+ );
+ } $row->{title};
+ print ' ';
+ s/\.?$/./, print " ';
for ($row->{status}) {
my $cell = $_ // '-';
$cell = sprintf '%s', $_, $cell for $row->{spec} // ();
- printf '$_ " for map { ref $_ ? @$_ : $_ || () } + $row->{description}, $row->{notes}; + printf 'Resources: %s.', join(', ', + map { qq($_->{title}) } @$_ + ) for grep { @$_ } $row->{links} // (); + print ' | %s', + printf ' | %s', $caniuse->{statuses}->{$_}, $CSTATUS{$_} // '', $cell; } for my $browser (@browsers) { my ($prev, @span); for my $ver (@{ $versions{$browser} }, undef) { unless (!defined $prev - or $data->{$browser}->{$prev} ~~ $data->{$browser}->{$ver}) { + or ref $data->{$browser} eq 'HASH' + && $data->{$browser}->{$prev} ~~ $data->{$browser}->{$ver}) { my $usage = sum(map { $canihas->{$browser}->{$_} } @span); printf ' | %s', join(' ', - $CSTATS{ $data->{$browser}->{$prev} }, - sprintf('opacity%.0f', $usage / $scorediv), + X => $CSTATS{ + ref $data->{$browser} ne 'HASH' ? 'u' : + $data->{$browser}->{$prev} // 'u' + }, + !$usage ? ('p0') : ('p', + sprintf('p%01d', $usage / 10), + sprintf('p%02d', $usage), + ), + sprintf('pp%02d', $usage / $scorediv), ), scalar @span, $usage, @@ -169,7 +235,7 @@ print ' |
---|
supported - | prefixed - | partial - | external (js/plugin) - | missing + | supported + | partial + | external (js/plugin) + | missing + | unknown + | prefixed |
<: if ($usage) { :> + Usage percentage: + 0 - + .01 - + 1-9 - + 10 - + 20 - + majority +<: } else { :> +
previous version | +current | +upcoming (within months) | +future (within a year) | +