X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/9bb91157b74f68b8345115f4665f3d5550b442e8..327c4c234570dabd716f92da15cf0ef716b9cb5d:/browser.plp diff --git a/browser.plp b/browser.plp index 3dc8d80..c10c20f 100644 --- a/browser.plp +++ b/browser.plp @@ -135,14 +135,14 @@ print "\n"; sub featurescore { # relative amount of support for given feature - state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 }; + state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, 'p p'=>2, p=>1 }; my $rank = 0; if (my $row = shift) { if ($canihas) { while (my ($browser, $versions) = each %$row) { ref $versions eq 'HASH' or next; while (my ($version, $_) = each %$versions) { - $rank += $canihas->{$browser}->{$version} * $statspts->{$_}; + $rank += ($canihas->{$browser}->{$version} || .001) * $statspts->{$_}; } } return $rank; @@ -172,7 +172,7 @@ sub saytitlecol { for ($row->{categories}) { my $cell = $_ ? lc $_->[0] : '-'; - print '', $cell; + printf '%s', join(' + ', @$_), $cell; } print '', map { @@ -181,15 +181,15 @@ sub saytitlecol { sprintf("try { %s; return false } catch(err) { return true }", "document.getElementById('$id').classList.toggle('target')", ), - $_, + Entity($_), ); } $row->{title}; print '
'; s/\.?$/./, print "

$_

" for map { ref $_ ? @$_ : $_ || () } - $row->{description}, $row->{notes}; - printf 'Resources: %s.', join(', ', - map { qq($_->{title}) } @$_ - ) for grep { @$_ } $row->{links} // (); + Entity($row->{description}), formathtml($row->{notes}); # sic + printf 'Resources: %s.', join(', ', map { + sprintf '%s', EscapeHTML($_->{url}), $_->{title} + } @$_) for grep { @$_ } $row->{links} // (); print '
'; } @@ -257,6 +257,16 @@ for my $id (sort { print '', $header; print ''; +sub formathtml { + my $ref = defined wantarray ? [@_] : \@_; + for (@$ref) { + s/& (?!\w)/&/gx; + s/< \s/</gx; + s/\n\K\n/
/g; + } + return @$ref; +} + sub paddedver { # normalised version number comparable as string (cmp) shift =~ /^(\d*)(.*)/; @@ -313,6 +323,6 @@ sub showversions { - - + +