summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-01 21:32:01 +0100
committerYorhel <git@yorhel.nl>2008-12-01 21:32:01 +0100
commit531db3e8ddc8523df730a3412fe6ccee21a71259 (patch)
tree939d943c9b2a0cc803a49db52b0e733ed1b1927e
parent3f747b5fce24fad0635be727c431e1fb234c3fa6 (diff)
Interface for the advanced VN search feature
We're getting there...
-rw-r--r--lib/VNDB/DB/Misc.pm17
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm86
-rw-r--r--static/f/script.js78
-rw-r--r--static/f/select.pngbin0 -> 1196 bytes
-rw-r--r--static/f/style.css83
5 files changed, 240 insertions, 24 deletions
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm
index a58534c6..9ebac75f 100644
--- a/lib/VNDB/DB/Misc.pm
+++ b/lib/VNDB/DB/Misc.pm
@@ -6,7 +6,7 @@ use warnings;
use Exporter 'import';
our @EXPORT = qw|
- dbStats dbRevisionInsert dbItemInsert dbRevisionGet dbItemMod
+ dbStats dbRevisionInsert dbItemInsert dbRevisionGet dbItemMod dbLanguages
|;
@@ -151,6 +151,21 @@ sub dbItemMod {
}
+# Returns a list of languages actually in use
+sub dbLanguages {
+ my $self = shift;
+ return [
+ map $_->{language}, @{$self->dbAll(q|
+ SELECT DISTINCT rr.language
+ FROM releases r
+ JOIN releases_rev rr ON rr.id = r.latest
+ WHERE r.hidden = FALSE|
+ )}
+ ];
+}
+
+
+
1;
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index 410e5de4..f65132d2 100644
--- a/lib/VNDB/Handler/VNBrowse.pm
+++ b/lib/VNDB/Handler/VNBrowse.pm
@@ -72,22 +72,7 @@ sub list {
if $q && @$list == 1;
$self->htmlHeader(title => 'Browse visual novels', search => $f->{q});
-
- div class => 'mainbox';
- h1 'Browse visual novels';
- form class => 'search', action => '/v/all', 'accept-charset' => 'UTF-8', method => 'get';
- fieldset;
- input type => 'text', name => 'q', id => 'q', class => 'text', value => $f->{q};
- input type => 'submit', class => 'submit', value => 'Search!';
- end;
- end;
- p class => 'browseopts';
- for ('all', 'a'..'z', 0) {
- a href => "/v/$_", $_ eq $char ? (class => 'optselected') : (), $_ ? uc $_ : '#';
- }
- end;
- end;
-
+ _filters($self, $f, $char);
$self->htmlBrowse(
class => 'vnbrowse',
items => $list,
@@ -125,5 +110,74 @@ sub list {
}
+sub _filters {
+ my($self, $f, $char) = @_;
+
+ div class => 'mainbox';
+ h1 'Browse visual novels';
+ form class => 'search', action => '/v/all', 'accept-charset' => 'UTF-8', method => 'get';
+ fieldset;
+ input type => 'text', name => 'q', id => 'q', class => 'text', value => $f->{q};
+ input type => 'submit', class => 'submit', value => 'Search!';
+ end;
+ end;
+ p class => 'browseopts';
+ for ('all', 'a'..'z', 0) {
+ a href => "/v/$_", $_ eq $char ? (class => 'optselected') : (), $_ ? uc $_ : '#';
+ }
+ end;
+ a id => 'advselect', href => '#';
+ lit '<i>&#9656;</i> advanced search';
+ end;
+ div id => 'advoptions', class => 'hidden';
+
+ h2;
+ lit 'Categories <p>(boolean and, selecting more gives less results. The categories are explained on <a href="/d1">this page</a>)</p>';
+ end;
+ ul id => 'catselect';
+ for my $c (qw| e g t p h l s |) {
+ $c !~ /[thl]/ ? li : br;
+ txt $self->{categories}{$c}[0];
+ ul;
+ li id => "cat_$c$_", $self->{categories}{$c}[1]{$_}
+ for (sort keys %{$self->{categories}{$c}[1]});
+ end;
+ end if $c !~ /[gph]/;
+ }
+
+ h2;
+ lit 'Languages <p>(boolean or, selecting more gives more results)</p>';
+ end;
+ for(sort @{$self->dbLanguages}) {
+ span;
+ input type => 'checkbox', id => "lang_$_";
+ label for => "lang_$_";
+ acronym class => "icons lang $_", title => $self->{languages}{$_}, ' ';
+ txt $self->{languages}{$_};
+ end;
+ end;
+ }
+
+ h2;
+ lit 'Platforms <p>(boolean or, selecting more gives more results)</p>';
+ end;
+ for(sort keys %{$self->{platforms}}) {
+ next if $_ eq 'oth';
+ span;
+ input type => 'checkbox', id => "plat_$_";
+ label for => "plat_$_";
+ acronym class => "icons $_", title => $self->{platforms}{$_}, ' ';
+ txt $self->{platforms}{$_};
+ end;
+ end;
+ }
+
+ br style => 'clear: left';
+ end;
+ end;
+ end;
+}
+
+
1;
diff --git a/static/f/script.js b/static/f/script.js
index 5b8e4e04..0bdd6364 100644
--- a/static/f/script.js
+++ b/static/f/script.js
@@ -15,6 +15,77 @@ clearInterval(t);f()}},10);window.onload=f;}
+function searchInit() {
+ cl('advselect', function() {
+ var e = x('advoptions');
+ e.className = e.className.indexOf('hidden')>=0 ? '' : 'hidden';
+ this.getElementsByTagName('i')[0].innerHTML = e.className.indexOf('hidden')>=0 ? '&#9656;' : '&#9662;';
+ return false;
+ });
+
+ var l = x('catselect').getElementsByTagName('li');
+ for(i=0;i<l.length;i++)
+ if(l[i].id.substr(0,4) == 'cat_')
+ l[i].onclick = function() {
+ searchParse(1, this.innerHTML);
+ };
+
+ l = x('advoptions').getElementsByTagName('input');
+ for(i=0;i<l.length;i++)
+ if(l[i].id.substr(0,5) == 'lang_' || l[i].id.substr(0,5) == 'plat_')
+ l[i].onclick = function() {
+ searchParse(0, this.parentNode.getElementsByTagName('acronym')[0].title);
+ };
+
+ x('q').onkeyup = searchParse;
+ searchParse();
+}
+
+function searchParse(add, term) {
+ var q = x('q').value;
+ var i;
+
+ if(add == 0 || add === 1) {
+ var qn = q;
+ if(!add)
+ eval('qn = qn.replace(/'+term+'/gi, "")');
+ else {
+ eval('qn = qn.replace(/(^|[^-])'+term+'/gi, "$1-'+term+'")');
+ if(qn == q)
+ eval('qn = qn.replace(/-'+term+'/gi, "")');
+ }
+ if(qn == q)
+ q += ' '+term;
+ else
+ q = qn;
+
+ q = q.replace(/^ +/, "");
+ q = q.replace(/ +$/, "");
+ q = q.replace(/ +/g, " ");
+
+ x('q').value = q;
+ }
+
+ q = q.toLowerCase();
+ var l = x('catselect').getElementsByTagName('li');
+ for(i=0;i<l.length;i++)
+ if(l[i].id.substr(0,4) == 'cat_') {
+ var cat = l[i].innerHTML.toLowerCase();
+ l[i].className = q.indexOf('-'+cat) >= 0 ? 'exc' : q.indexOf(cat) >= 0 ? 'inc' : '';
+ }
+
+ l = x('advoptions').getElementsByTagName('input');
+ for(i=0;i<l.length;i++)
+ if(l[i].id.substr(0,5) == 'lang_' || l[i].id.substr(0,5) == 'plat_')
+ l[i].checked = q.indexOf(l[i].parentNode.getElementsByTagName('acronym')[0].title.toLowerCase()) >= 0 ? true : false;
+
+ return false;
+}
+
+
+
+
+
/* I M A G E V I E W E R */
function ivInit() {
@@ -163,6 +234,8 @@ function jtSel(which, nolink) {
/* O N L O A D E V E N T */
DOMLoad(function() {
+
+ // search box
var i = x('sq');
i.onfocus = function () {
if(this.value == 'search') {
@@ -178,6 +251,11 @@ DOMLoad(function() {
};
+ // Advanced VN search
+ if(x('advselect'))
+ searchInit();
+
+
// show/hide NSFW VN image
cl('nsfw_show', function() {
x('nsfw_show').style.display = 'none';
diff --git a/static/f/select.png b/static/f/select.png
new file mode 100644
index 00000000..9473c8a9
--- /dev/null
+++ b/static/f/select.png
Binary files differ
diff --git a/static/f/style.css b/static/f/style.css
index 2d961d69..04ce815d 100644
--- a/static/f/style.css
+++ b/static/f/style.css
@@ -63,6 +63,11 @@ p.locked {
font-style: italic;
margin: 0!important;
}
+h2 p {
+ font: 8pt "Tahoma";
+ font-weight: normal;
+ display: inline;
+}
@@ -574,7 +579,7 @@ div.vndescription p {
margin: 0;
cursor: pointer;
list-style-type: none;
- /*background: url(/f/select.png) no-repeat;*/
+ padding: 0;
}
a.help {
vertical-align: super;
@@ -583,11 +588,13 @@ a.help {
font-weight: bold;
padding-left: 1px;
}
-form #jt_box_categories li li { padding: 0; background: none; }
-form #jt_box_categories li li b { width: 13px; font-weight: bold; }
-#maincontent form #jt_box_categories li li a { color: #ccc; text-decoration: none; display: block; width: 160px; border: none }
-#jt_box_categories li li.inc { background-position: 0px -16px; color: #090; }
-#jt_box_categories li li.exc { background-position: 0px -33px; color: #900; }
+#maincontent #jt_box_categories li li a {
+ color: #ccc;
+ text-decoration: none;
+ display: block;
+ width: 160px;
+ border: none
+}
#jt_box_relations table { margin-bottom: 10px; }
#jt_box_relations h2 { margin: 0 0 3px -10px; }
@@ -629,10 +636,72 @@ form #jt_box_categories li li b { width: 13px; font-weight: bold; }
#scr_table select { width: 400px; }
-/* VN browse */
+
+
+
+/****** VN browse ********/
.vnbrowse .tc2 { text-align: right; padding: 0; }
.vnbrowse .tc3 { padding: 0; }
+#q { width: 300px }
+#advselect {
+ text-align: center;
+ display: block;
+ margin: 10px auto 3px auto;
+ border: none;
+ outline: none;
+}
+#advoptions {
+ width: 90%;
+ padding: 0 30px 5px 30px;
+ margin: 0 auto;
+ border-top: 1px solid #258;
+}
+#advoptions.hidden { display: none }
+#advoptions h2 {
+ clear: left;
+ padding-top: 10px;
+ margin-left: -20px;
+ margin-top: 0;
+ margin-bottom: 3px;
+}
+#advoptions span {
+ display: block;
+ float: left;
+ width: 170px;
+}
+#advoptions span input {
+ margin-right: 3px;
+}
+
+ul#catselect, ul#catselect ul {
+ list-style-type: none;
+ padding: 0;
+ margin: 0;
+}
+ul#catselect li {
+ display: block;
+ width: 170px;
+ float: left;
+ clear: none;
+ font-weight: bold;
+}
+ul#catselect li li {
+ display: list-item;
+ width: auto;
+ float: none;
+ clear: left;
+ font-weight: normal;
+ padding: 0 0 0 18px;
+ margin: 0;
+ cursor: pointer;
+ list-style-type: none;
+ background: url(/f/select.png) no-repeat;
+}
+ul#catselect li li.inc { background-position: 0px -16px; color: #0c0; }
+ul#catselect li li.exc { background-position: 0px -33px; color: #c00; }
+
+