X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/bd77795ed44d7b642c66b05e0982bff026fdc68f..0f352cba4bd2bd1271275c60853c500a233eeef5:/browser.plp diff --git a/browser.plp b/browser.plp index ea23d0a..d9da982 100644 --- a/browser.plp +++ b/browser.plp @@ -16,59 +16,77 @@ Html({ :>
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 $! || $@; - +{ - 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 '', $cell; } - print ' | ', $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 map { ref $_ ? @$_ : $_ || () } $row->{description}, $row->{notes}; @@ -157,7 +183,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) {
@@ -218,15 +244,15 @@ sub showversions {
|
+
+<: } else { :>
+ <: if ($usage) { :> Usage percentage: 0 - .01 - @@ -234,12 +260,21 @@ sub showversions { 10 - 20 - majority -
|
---|