From 4f687e4d1e81b665196251bb0cfa48c062357d20 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Mon, 12 Oct 2009 17:31:18 +0200 Subject: htmlSearchBox: Copy over search query when switching search type <@EchoMateria> for example I searched for 'Maika' in Visual Novels <@EchoMateria> then remembered that it was a producer not a game and clicked Producers instead <@EchoMateria> can you set it so that entry in the search field would stay and it would search for it in the producers instead? --- lib/VNDB/Util/CommonHTML.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 90c9db13..3d032d37 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -537,13 +537,20 @@ sub htmlHistory { sub htmlSearchBox { my($self, $sel, $v) = @_; + # escape search query for use as a query string value + (my $q = $v||'') =~ s/&/%26/g; + $q =~ s/\?/%3F/g; + $q =~ s/;/%3B/g; + $q =~ s/ /%20/g; + $q = "?q=$q" if $q; + fieldset class => 'search'; p class => 'searchtabs'; - a href => '/v/all', $sel eq 'v' ? (class => 'sel') : (), mt '_searchbox_vn'; - a href => '/r', $sel eq 'r' ? (class => 'sel') : (), mt '_searchbox_releases'; - a href => '/p/all', $sel eq 'p' ? (class => 'sel') : (), mt '_searchbox_producers'; - a href => '/g', $sel eq 'g' ? (class => 'sel') : (), mt '_searchbox_tags'; - a href => '/u/all', $sel eq 'u' ? (class => 'sel') : (), mt '_searchbox_users'; + a href => "/v/all$q", $sel eq 'v' ? (class => 'sel') : (), mt '_searchbox_vn'; + a href => "/r$q", $sel eq 'r' ? (class => 'sel') : (), mt '_searchbox_releases'; + a href => "/p/all$q", $sel eq 'p' ? (class => 'sel') : (), mt '_searchbox_producers'; + a href => '/g'.($q?"/list$q":''), $sel eq 'g' ? (class => 'sel') : (), mt '_searchbox_tags'; + a href => "/u/all$q", $sel eq 'u' ? (class => 'sel') : (), mt '_searchbox_users'; end; input type => 'text', name => 'q', id => 'q', class => 'text', value => $v; input type => 'submit', class => 'submit', value => mt '_searchbox_submit'; -- cgit v1.2.3