webif/webif/lib/epg_search

128 lines
2.7 KiB
Plaintext
Executable File

puts {
<style type=text/css>
.ui-button, .ui-button-text { font-size: 12px; }
#moresearch { display: none; }
#morebutton { position: relative; top: -12px; }
</style>
}
set searchterm ""
catch { set searchterm [dict get $_cgi term] }
set searchfull 0
catch { if {[dict exists $_cgi full]} { set searchfull 1 } }
puts "
<form method=get action=/cgi-bin/epg/search.jim>
<fieldset>
<legend>EPG Search</legend>
<label for=term>Query</label>
<input type=text name=term id=term size=20 maxlength=255 value=\"$searchterm\"
class=\"text ui-widget-content ui-corner-all\">
<input type=submit value=Search>
<input type=checkbox name=full id=full"
if {$searchfull == 1} { puts -nonewline " checked" }
puts ">
<label for=full>Search descriptions as well as titles.</label>
<font class=footnote style=\"margin-left: 5em\">
Click down arrow below for more options.
</font>
<div id=moresearch class=hidden>
"
proc cts {type img text} {
puts "<a href=\"/cgi-bin/epg/search.jim?ct=$type\">
<img height=18 border=0 src=/images/173_3_00_G3_$img.png>
&nbsp;$text</a>";
}
puts {
<br>
<fieldset>
<legend>Content Type Searches</legend>
<table>
<tr>
<td>
}
cts 1 "Movie" "Film/Drama"
puts "</td><td>"
cts 2 "News" "News/Current affairs"
puts "</td><td>"
cts 4 "Sports" "Sport"
puts "</td><td>"
cts 9 "Education" "Education/Science/Factual"
puts "</td><td>"
cts 10 "Leisure" "Leisure"
puts "</td><td>"
puts "<a href=/go/epg>Now/Next</a>"
puts "</td></tr><tr><td>"
cts 7 "Art" "Arts/Culture"
puts "</td><td>"
cts 3 "Show" "Show/Game show"
puts "</td><td>"
cts 5 "Children" "Children"
puts "</td><td>"
cts 8 "Society" "Social/Political/Economic"
puts "</td><td>"
cts 6 "Music" "Music/Ballet/Dance"
puts "</tr></table></fieldset>"
set db [sqlite3.open /var/lib/humaxtv/setup.db]
set res [$db query {
select itemBlob from TBL_USERCONFIG
where itemName like 'EPG\_KEYWORD\_%%' ESCAPE '\'
}]
$db close
if {[llength $res] > 0} {
puts "
<fieldset>
<legend>Keyword Searches</legend>
<table cellpadding=5>
<tr>
"
foreach keyword $res {
set kw [string range [lindex $keyword 1] 1 end]
# Clean the keyword string.
regexp -nocase {^(\w+)} $kw kw
puts "<td><a href=\"/cgi-bin/epg/search.jim?term=[\
cgi_quote_url $kw]\">$kw
</a></td>"
}
puts "
</tr>
</table>
</fieldset>
"
}
puts "
</div>
"
puts "</fieldset>"
puts "<center><img id=morebutton src=/img/more_show.png></center>"
puts "</form>"
puts {
<script type=text/javascript>
$('input:submit').button();
$('#morebutton').click(function(e) {
e.preventDefault();
$('#moresearch').slideToggle('slow');
if ($('#morebutton').attr('src') == '/img/more_show.png')
$('#morebutton').attr('src', '/img/more_hide.png');
else
$('#morebutton').attr('src', '/img/more_show.png');
});
</script>
}