summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorzx14 <zx14@vndb.org>2018-11-04 12:42:48 +0700
committerAlexander-- <alexander.r@gmx.com>2018-11-04 12:43:50 +0700
commit1c8077bfe8c4ad6e8c94ddc94bf505d1396ca3ac (patch)
tree728c28c3c7cd2f704862037d9840187bbe44ec0f /lib/VNDB/Handler
parent9f4b31ae6aa3f33856978b09481b97c5b13f4359 (diff)
JS-less tag visibility toggles
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/VNPage.pm55
1 files changed, 38 insertions, 17 deletions
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 20f29f7a..2abc1c9a 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -457,25 +457,46 @@ sub page {
my $t = $self->dbTagStats(vid => $v->{id}, sort => 'rating', reverse => 1, minrating => 0, results => 999);
if(@$t) {
div id => 'tagops';
- # NOTE: order of these links is hardcoded in JS
+ # NOTE: order of these inputs is hardcoded in JS
my $tags_cat = $self->authPref('tags_cat') || $self->{default_tags_cat};
- a href => "#$_", $tags_cat =~ /\Q$_/ ? (class => 'tsel') : (), lc $self->{tag_categories}{$_} for keys %{$self->{tag_categories}};
- my $spoiler = $self->authPref('spoilers') || 0;
- a href => '#', class => 'sec'.($spoiler == 0 ? ' tsel' : ''), lc 'Hide spoilers';
- a href => '#', $spoiler == 1 ? (class => 'tsel') : (), lc 'Show minor spoilers';
- a href => '#', $spoiler == 2 ? (class => 'tsel') : (), lc 'Spoil me!';
- a href => '#', class => 'sec'.($self->authPref('tags_all') ? '': ' tsel'), 'summary';
- a href => '#', $self->authPref('tags_all') ? (class => 'tsel') : (), 'all';
- end;
- div id => 'vntags';
- for (@$t) {
- my $spoil = $_->{spoiler} > 1.3 ? 2 : $_->{spoiler} > 0.4 ? 1 : 0;
- span class => sprintf 'tagspl%d cat_%s %s', $spoil, $_->{cat}, $spoil > 0 ? 'hidden' : '';
- a href => "/g$_->{id}", style => sprintf('font-size: %dpx', $_->{rating}*3.5+6), $_->{name};
- b class => 'grayedout', sprintf ' %.1f', $_->{rating};
- end;
- txt ' ';
+ for (keys %{$self->{tag_categories}}) {
+ input id => "cat_$_", type => 'checkbox', class => 'visuallyhidden', $tags_cat =~ /\Q$_/ ? (checked => 'checked') : ();
+ label for => "cat_$_", lc $self->{tag_categories}{$_};
}
+ my $spoiler = $self->authPref('spoilers') || 0;
+ input id => 'tag_spoil_none', type => 'radio', class => 'visuallyhidden', name => 'tag_spoiler', $spoiler == 0 ? (checked => 'checked') : ();
+ label for => 'tag_spoil_none', class => 'sec', lc 'Hide spoilers';
+ input id => 'tag_spoil_some', type => 'radio', class => 'visuallyhidden', name => 'tag_spoiler', $spoiler == 1 ? (checked => 'checked') : ();
+ label for => 'tag_spoil_some', lc 'Show minor spoilers';
+ input id => 'tag_spoil_all', type => 'radio', class => 'visuallyhidden', name => 'tag_spoiler', $spoiler == 2 ? (checked => 'checked') : ();
+ label for => 'tag_spoil_all', lc 'Spoil me!';
+
+ input id => 'tag_toggle_summary', type => 'radio', class => 'visuallyhidden', name => 'tag_all', $self->authPref('tags_all') ? () : (checked => 'checked');
+ label for => 'tag_toggle_summary', class => 'sec', lc 'summary';
+ input id => 'tag_toggle_all', type => 'radio', class => 'visuallyhidden', name => 'tag_all', $self->authPref('tags_all') ? (checked => 'checked') : ();
+ label for => 'tag_toggle_all', class => 'lst', lc 'all';
+ div id => 'vntags';
+ my %counts = ();
+ for (@$t) {
+ my $cnt0 = $counts{$_->{cat} . '0'} || 0;
+ my $cnt1 = $counts{$_->{cat} . '1'} || 0;
+ my $cnt2 = $counts{$_->{cat} . '2'} || 0;
+ my $spoil = $_->{spoiler} > 1.3 ? 2 : $_->{spoiler} > 0.4 ? 1 : 0;
+ SWITCH: {
+ $counts{$_->{cat} . '2'} = ++$cnt2;
+ if ($spoil == 2) { last SWITCH; }
+ $counts{$_->{cat} . '1'} = ++$cnt1;
+ if ($spoil == 1) { last SWITCH; }
+ $counts{$_->{cat} . '0'} = ++$cnt0;
+ }
+ my $cut = $cnt0 > 15 ? ' cut cut2 cut1 cut0' : ($cnt1 > 15 ? ' cut cut2 cut1' : ($cnt2 > 15 ? ' cut cut2' : ''));
+ span class => sprintf 'tagspl%d cat_%s%s', $spoil, $_->{cat}, $cut;
+ a href => "/g$_->{id}", style => sprintf('font-size: %dpx', $_->{rating}*3.5+6), $_->{name};
+ b class => 'grayedout', sprintf ' %.1f', $_->{rating};
+ end;
+ txt ' ';
+ }
+ end;
end;
}
end 'div'; # /mainbox