X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/0c4ca53d0803c3d9db0a06b57f650e65c3327467..ac5213bf8d4067b6f3a02e3cdcb90ce729c1e64d:/browser.plp diff --git a/browser.plp b/browser.plp index e4e0b28..1f5cfc0 100644 --- a/browser.plp +++ b/browser.plp @@ -16,33 +16,47 @@ Html({ :>

Browser compatibility

-

Alternate view of Fyrd's when can I use... page -<: -my $canihas = do 'browser-usage.inc.pl' - or printf "

Browser usage data not found: %s.

\n", $! || $@; - -print "with $_ browser usage statistics." for map { - my $ref = $_->{-source} || 'unknown'; - $ref = sprintf '%s', $_, $ref for $_->{-url} || (); - $ref .= " $_" for $_->{-date} || (); - $ref -} $canihas || (); -:> +

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"; +} +:>.

<: my $caniuse = do 'browser-support.inc.pl' or die $! || $@; +$_->{verrelease} = { + # mark last two (future) versions as unreleased, ensure current isn't + map { $_->[-1] => 0, $_->[-2] => 0, $_->[-3] => undef } $_->{versions} +} for values %{ $caniuse->{agents} }; my %CSTATS = ( 'n' => 'l1', 'y' => 'l5', - 'y x' => 'l4', + 'y x' => 'l5 ex', 'a' => 'l3', - 'a x' => 'l3', + 'a x' => 'l3 ex', 'p j' => 'l2', 'j' => 'l2', 'p' => 'l2', + 'p p' => 'l2', 'u' => 'l0', ); my %CSTATUS = ( @@ -104,8 +118,12 @@ print '', $header; print "\n"; 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; @@ -174,7 +192,7 @@ for my $id (sort { for ($row->{status}) { my $cell = $_ // '-'; $cell = sprintf '%s', $_, $cell for $row->{spec} // (); - printf '%s', + printf '%s', $caniuse->{statuses}->{$_}, $CSTATUS{$_} // '', $cell; } for my $browser (@browsers) { @@ -236,14 +254,14 @@ sub showversions {
supported - prefixed partial external (js/plugin) missing unknown + prefixed
-
+

<: if ($usage) { :> Usage percentage: 0 - .01 - @@ -251,12 +269,21 @@ sub showversions { 10 - 20 - majority -

+<: } else { :> + + + + + +
previous versioncurrentupcoming (within months)future (within a year)
+<: } :>

  • default style is <:= defined $get{style} && 'set to ' :><:= $style :> +
  • usage source is + <:= !defined $get{usage} && 'default ' :><:= defined $usage ? "$usage" : 'not included (0)' :>