summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-02-06 15:18:09 +0100
committerYorhel <git@yorhel.nl>2011-02-06 15:18:09 +0100
commitbe9f4b48838755ee1d6cd4c1cf625f2c5d7b8802 (patch)
tree0b8c9c739fe36978d2d3998a8ed7fc85a17f6c08
parent8b3eb97627131a9be85cf784484d8d51d9b417c0 (diff)
Added filter selector to tag pages (excl. tags tab)
-rw-r--r--ChangeLog1
-rw-r--r--data/script.js17
-rw-r--r--lib/VNDB/Handler/Tags.pm23
-rw-r--r--lib/VNDB/Util/Misc.pm5
4 files changed, 32 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 4cb2b349..c58d1574 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
- Added category field to tags (content/ero/technical)
- Group tags on /v+/tagmod by their category
- Added tag visibility options by category on /v+
+ - Added filter selector to tag pages (excl. tags tab)
2.17 - 2011-02-04
- Allow moderators to overrule VN tag votes
diff --git a/data/script.js b/data/script.js
index d124b9a6..56050be0 100644
--- a/data/script.js
+++ b/data/script.js
@@ -1790,14 +1790,19 @@ function filLoad() {
var p = tag('p', {'class':'browseopts'});
var c = tag('div', null);
+ var idx = 0;
for(var i=1; i<l.length; i++) {
+ if(!l[i])
+ continue;
+ idx++;
+
// category link
- var a = tag('a', { href: '#', onclick: filSelectCat, fil_num: i, fil_onshow:[] }, l[i][0]);
+ var a = tag('a', { href: '#', onclick: filSelectCat, fil_num: idx, fil_onshow:[] }, l[i][0]);
p.appendChild(a);
p.appendChild(tag(' '));
// category contents
- var t = tag('table', {'class':'formtable', fil_num: i}, null);
+ var t = tag('table', {'class':'formtable', fil_num: idx}, null);
setClass(t, 'hidden', true);
a.fil_t = t;
for(var j=1; j<l[i].length; j++) {
@@ -1818,7 +1823,7 @@ function filLoad() {
}
c.appendChild(t);
- fil_cats[i] = a;
+ fil_cats[idx] = a;
}
addBody(tag('div', { id: 'fil_div', 'class':'hidden' },
@@ -1944,6 +1949,8 @@ function filDeSerialize() {
f[fn] = '';
for(var fn in f) {
var c = byId('fil_check_'+fn);
+ if(!c)
+ continue;
c.checked = f[fn] == '' ? false : true;
var v = f[fn].split('~');
for(var i=0; i<v.length; i++)
@@ -2178,13 +2185,15 @@ function filVN() {
for(var i=0; i<len.length; i++) // l10n /_vnlength_.+/
len[i] = [ len[i], mt('_vnlength_'+len[i]) ];
+ var ontagpage = location.pathname.indexOf('/v/') < 0;
+
return [
mt('_vnbrowse_fil_title'),
[ mt('_vnbrowse_general'),
filFSelect( 'length', mt('_vnbrowse_length'), 6, len),
filFOptions('hasani', mt('_vnbrowse_anime'), [[1, mt('_vnbrowse_anime_yes')],[0, mt('_vnbrowse_anime_no')]])
],
- [ mt('_vnbrowse_tags'),
+ ontagpage ? null : [ mt('_vnbrowse_tags'),
[ '', ' ', tag(mt('_js_fil_booland')) ],
[ '', ' ', PREF_CODE != '' ? tag(mt('_vnbrowse_tagactive')) : null ],
filFTagInput('tag_inc', mt('_vnbrowse_taginc')),
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index 974754c9..af936f63 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -34,12 +34,14 @@ sub tagpage {
{ get => 'o', required => 0, default => 'd', enum => [ 'a','d' ] },
{ get => 'p', required => 0, default => 1, template => 'int' },
{ get => 'm', required => 0, default => -1, enum => [qw|0 1 2|] },
+ { get => 'fil', required => 0 },
);
return $self->resNotFound if $f->{_err};
my $tagspoil = $self->reqCookie('tagspoil')||'';
$f->{m} = $tagspoil =~ /^[0-2]$/ ? $tagspoil : 0 if $f->{m} == -1;
+ $f->{fil} //= $self->authPref('filter_vn');
- my($list, $np) = $t->{meta} || $t->{state} != 2 ? ([],0) : $self->filFetchDB(vn => undef, undef, {
+ my($list, $np) = $t->{meta} || $t->{state} != 2 ? ([],0) : $self->filFetchDB(vn => $f->{fil}, undef, {
what => 'rating',
results => 50,
page => $f->{p},
@@ -111,23 +113,32 @@ sub tagpage {
_childtags($self, $t) if @{$t->{childs}};
if(!$t->{meta} && $t->{state} == 2) {
+ form action => "/g$t->{id}", 'accept-charset' => 'UTF-8', method => 'get';
div class => 'mainbox';
a class => 'addnew', href => "/g/links?t=$tag", mt '_tagp_rawvotes';
h1 mt '_tagp_vnlist';
+
p class => 'browseopts';
- a href => "/g$t->{id}?m=0", $f->{m} == 0 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 0);return true;", mt '_tagp_spoil0';
- a href => "/g$t->{id}?m=1", $f->{m} == 1 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 1);return true;", mt '_tagp_spoil1';
- a href => "/g$t->{id}?m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2';
+ a href => "/g$t->{id}?fil=$f->{fil};m=0", $f->{m} == 0 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 0);return true;", mt '_tagp_spoil0';
+ a href => "/g$t->{id}?fil=$f->{fil};m=1", $f->{m} == 1 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 1);return true;", mt '_tagp_spoil1';
+ a href => "/g$t->{id}?fil=$f->{fil};m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2';
+ end;
+
+ a id => 'filselect', href => '#v';
+ lit '<i>&#9656;</i> '.mt('_js_fil_filters').'<i></i>';
end;
+ input type => 'hidden', class => 'hidden', name => 'fil', id => 'fil', value => $f->{fil};
+
if(!@$list) {
p; br; br; txt mt '_tagp_novn'; end;
}
p; br; txt mt '_tagp_cached'; end;
end 'div';
- $self->htmlBrowseVN($list, $f, $np, "/g$t->{id}?m=$f->{m}", 1) if @$list;
+ end 'form';
+ $self->htmlBrowseVN($list, $f, $np, "/g$t->{id}?fil=$f->{fil};m=$f->{m}", 1) if @$list;
}
- $self->htmlFooter;
+ $self->htmlFooter(prefs => ['filter_vn']);
}
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index 9f281ee7..85861f8b 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -34,9 +34,6 @@ sub filFetchDB {
my $prefname = 'filter_'.$type;
my $pref = $self->authPref($prefname);
- # simply call the DB if we're not applying filters
- return $dbfunc->($self, %$pre, %$post) if !$pref && !$overwrite;
-
my $filters = fil_parse $overwrite // $pref, @{$filfields{$type}};
# compatibility
@@ -50,7 +47,7 @@ sub filFetchDB {
exists($pre->{$_}) ? ($_ => $pre->{$_}) : (),
), @{$filfields{$type}}}) if defined $overwrite;
- return $dbfunc->($self, %$pre, %$filters, %$post) if defined $overwrite;
+ return $dbfunc->($self, %$pre, %$filters, %$post) if defined $overwrite or !keys %$filters;;
# since incorrect filters can throw a database error, we have to special-case
# filters that originate from a preference setting, so that in case these are