summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/script.js24
-rw-r--r--data/style.css6
-rw-r--r--lib/VNDB/Func.pm8
-rw-r--r--lib/VNDB/Handler/Chars.pm59
-rw-r--r--lib/VNDB/Handler/VNPage.pm15
5 files changed, 87 insertions, 25 deletions
diff --git a/data/script.js b/data/script.js
index cdb02447..aa7b91a0 100644
--- a/data/script.js
+++ b/data/script.js
@@ -2738,6 +2738,30 @@ if(byId('expandall')) {
}
+// charspoil handling (ugly)
+if(byId('charspoil_sel')) {
+ var k = byClass('charspoil');
+ var h = byName(byId('charspoil_sel'), 'a');
+ var setall = function(spoil) {
+ for(var i=0; i<k.length; i++)
+ setClass(k[i], 'hidden',
+ hasClass(k[i], 'charspoil_0') ? false :
+ hasClass(k[i], 'charspoil_1') ? spoil < 1 : spoil < 2);
+ for(var i=0; i<h.length; i++)
+ setClass(h[i], 'sel', spoil == i);
+ };
+ for(var i=0; i<h.length; i++) {
+ h[i].num = i;
+ h[i].onclick = function() {
+ setall(this.num);
+ setCookie('tagspoil', this.num);
+ return false;
+ };
+ };
+ setall(getCookie('tagspoil'));
+}
+
+
// set note input box (/u+/list)
if(byId('not') && byId('vns'))
byId('vns').onchange = function () {
diff --git a/data/style.css b/data/style.css
index 0bc9973d..08199de0 100644
--- a/data/style.css
+++ b/data/style.css
@@ -854,7 +854,7 @@ div.scr_uploader { visibility: hidden; overflow: hidden; width: 1px; height: 1px
-/***** Char page *****/
+/***** Char page (also used on VN page) *****/
div.chardetails { margin: 0 auto; width: 800px; }
div.charimg { float: left; width: 250px; margin: 0 10px; text-align: center }
@@ -864,6 +864,10 @@ div.charimg p { text-align: center; padding: 0px; margin: 0; }
div.chardetails table { float: left; width: 530px; }
div.chardetails table td.key { width: 80px; }
div.chardetails.charsep { padding-top: 5px; margin-top: 5px; border-top: 1px solid $border$ }
+#charspoil_sel { clear: right; float: right; }
+#charspoil_sel a { margin: 0 0 0 10px; border: 0; outline: none }
+#maincontent #charspoil_sel a.sel { color: $maintext$; }
+
/***** Char edit *****/
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index edb6e3aa..64b56625 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -7,7 +7,7 @@ use TUWF ':html';
use Exporter 'import';
use POSIX 'strftime', 'ceil', 'floor';
use VNDBUtil;
-our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags |);
+our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags charspoil |);
# three ways to represent the same information
@@ -174,5 +174,11 @@ sub childtags {
}
+# generates the class elements for character spoiler hiding
+sub charspoil {
+ return "charspoil charspoil_$_[0]".($_[0] ? ' hidden' : '');
+}
+
+
1;
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index 9b0f7f0a..ca9cf105 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -67,12 +67,17 @@ sub page {
div class => 'mainbox';
$self->htmlItemMessage('c', $r);
+ p id => 'charspoil_sel';
+ a href => '#', class => 'sel', mt '_vnpage_tags_spoil0'; # _vnpage!?
+ a href => '#', mt '_vnpage_tags_spoil1';
+ a href => '#', mt '_vnpage_tags_spoil2';
+ end;
h1 $r->{name};
h2 class => 'alttitle', $r->{original} if $r->{original};
$self->charTable($r);
end;
- # TODO: ordering of these instances? + spoiler handling
+ # TODO: ordering of these instances?
my $inst = [];
if(!$r->{main}) {
$inst = $self->dbCharGet(instance => $r->{id}, what => 'extended traits vns');
@@ -83,7 +88,7 @@ sub page {
if(@$inst) {
div class => 'mainbox';
h1 mt '_charp_instances';
- $self->charTable($_, 1, $_ != $inst->[0]) for @$inst;
+ $self->charTable($_, 1, $_ != $inst->[0], 0, !$r->{main} ? $_->{main_spoil} : $_->{main_spoil} > $r->{main_spoil} ? $_->{main_spoil} : $r->{main_spoil}) for @$inst;
end;
}
@@ -93,9 +98,10 @@ sub page {
# Also used from Handler::VNPage
sub charTable {
- my($self, $r, $link, $sep, $vn) = @_;
+ my($self, $r, $link, $sep, $vn, $spoil) = @_;
+ $spoil ||= 0;
- div class => 'chardetails'.($sep ? ' charsep' : '');
+ div class => 'chardetails '.charspoil($spoil).($sep ? ' charsep' : '');
# image
div class => 'charimg';
@@ -148,7 +154,7 @@ sub charTable {
}
# traits
- # TODO: handle spoilers and 'sexual' traits
+ # TODO: handle 'sexual' traits
my %groups;
my @groups;
for (@{$r->{traits}}) {
@@ -161,15 +167,16 @@ sub charTable {
td class => 'key'; a href => '/i'.($groups{$g}[0]{group}||$groups{$g}[0]{tid}), $groups{$g}[0]{groupname} || $groups{$g}[0]{name}; end;
td;
for (@{$groups{$g}}) {
- txt ', ' if $_->{tid} != $groups{$g}[0]{tid};
- a href => "/i$_->{tid}", $_->{name};
+ span class => charspoil $_->{spoil};
+ txt ', ' if $_->{tid} != $groups{$g}[0]{tid};
+ a href => "/i$_->{tid}", $_->{name};
+ end;
}
end;
end;
}
# vns
- # TODO: handle spoilers!
if(@{$r->{vns}} && (!$vn || $vn && (@{$r->{vns}} > 1 || $r->{vns}[0]{rid}))) {
my %vns;
push @{$vns{$_->{vid}}}, $_ for(sort { !defined($a->{rid})?1:!defined($b->{rid})?-1:$a->{rtitle} cmp $b->{rtitle} } @{$r->{vns}});
@@ -182,23 +189,31 @@ sub charTable {
my @r = @{$vns{$g}};
# special case: all releases, no exceptions
if(!$vn && @r == 1 && !$r[0]{rid}) {
- txt mt("_charrole_$r[0]{role}").' - ';
- a href => "/v$r[0]{vid}/chars", $r[0]{vntitle};
+ span class => charspoil $r[0]{spoil};
+ txt mt("_charrole_$r[0]{role}").' - ';
+ a href => "/v$r[0]{vid}/chars", $r[0]{vntitle};
+ end;
next;
}
# otherwise, print VN title and list releases separately
- a href => "/v$r[0]{vid}/chars", $r[0]{vntitle} if !$vn;
- for(@r) {
- br if !$vn || $_ != $r[0];
- b class => 'grayedout', '> ';
- txt mt("_charrole_$_->{role}").' - ';
- if($_->{rid}) {
- b class => 'grayedout', "r$_->{rid}:";
- a href => "/r$_->{rid}", $_->{rtitle};
- } else {
- txt mt '_charp_vns_other';
- }
- }
+ my $minspoil = 5;
+ $minspoil = $minspoil > $_->{spoil} ? $_->{spoil} : $minspoil for (@r);
+ span class => charspoil $minspoil;
+ a href => "/v$r[0]{vid}/chars", $r[0]{vntitle} if !$vn;
+ for(@r) {
+ span class => charspoil $_->{spoil};
+ br if !$vn || $_ != $r[0];
+ b class => 'grayedout', '> ';
+ txt mt("_charrole_$_->{role}").' - ';
+ if($_->{rid}) {
+ b class => 'grayedout', "r$_->{rid}:";
+ a href => "/r$_->{rid}", $_->{rtitle};
+ } else {
+ txt mt '_charp_vns_other';
+ }
+ end;
+ }
+ end;
}
end;
end;
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 5d692974..763fc82d 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -539,11 +539,24 @@ sub _chars {
for my $r (@{$self->{char_roles}}) {
$rol{$r} = [ grep grep($_->{role} eq $r, @{$_->{vns}}) && !$done{$_->{id}}++, @$l ];
}
+ my $first = 0;
for my $r (@{$self->{char_roles}}) {
next if !@{$rol{$r}};
div class => 'mainbox';
+ if(!$first++) {
+ p id => 'charspoil_sel';
+ a href => '#', class => 'sel', mt '_vnpage_tags_spoil0'; # _vnpage!?
+ a href => '#', mt '_vnpage_tags_spoil1';
+ a href => '#', mt '_vnpage_tags_spoil2';
+ end;
+ }
h1 mt "_charrole_$r";
- $self->charTable($_, 1, $_ != $rol{$r}[0], 1) for (@{$rol{$r}});
+ for my $c (@{$rol{$r}}) {
+ my $minspoil = 5;
+ $minspoil = $_->{vid} == $v->{id} && $_->{spoil} < $minspoil ? $_->{spoil} : $minspoil
+ for(@{$c->{vns}});
+ $self->charTable($c, 1, $c != $rol{$r}[0], 1, $minspoil);
+ }
end;
}
}