improve EPG search using drop-down options. Implement package management

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@210 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-06-29 22:53:15 +00:00
parent 050cb611bf
commit 43db44d742
9 changed files with 152 additions and 148 deletions

View File

@ -4,7 +4,6 @@ package require cgi
source /mod/var/mongoose/lib/epg.class
source /mod/var/mongoose/lib/spinner.class
source /mod/var/mongoose/lib/altrow
source /mod/var/mongoose/lib/cat
puts "Content-Type: text/html"
puts ""
@ -13,17 +12,25 @@ source /mod/var/mongoose/html/lib/header.jim
puts "<script type=text/javascript src=/js/highlight.js></script>"
source /mod/var/mongoose/lib/epg_popup
cgi_input
#cgi_dump
source /mod/var/mongoose/lib/epg_search
[spinner new {
text "Searching EPG..."
size "1.2em"
style "margin: 1em;"
}] start
source /mod/var/mongoose/lib/epg_popup
#set _cgi [dict create term "doctor who"]
#set env(REQUEST_URI) "test"
set term ""
catch { set term [dict get $_cgi term] }
set cmd "search"
if {[dict exists $_cgi full]} { set cmd "searchall" }
if {$searchfull} { set cmd "searchall" }
set ct 0
catch { set ct [dict get $_cgi ct] }
set crid ""
@ -31,107 +38,22 @@ catch { set crid [dict get $_cgi crid] }
set scrid ""
catch { set scrid [dict get $_cgi scrid] }
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=\"$term\"
class=\"text ui-widget-content ui-corner-all\">
<input type=submit value=Search>
<input type=checkbox name=full id=full"
if {[dict exists $_cgi full]} { puts -nonewline " checked" }
puts ">
<label for=full>Search descriptions as well as titles.</label>
"
puts {
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; font-size: 12px; }
</style>
<script type=text/javascript>
$('input:submit').button();
</script>
}
set db [sqlite3.open /var/lib/humaxtv/setup.db]
set res [$db query {
select itemBlob from TBL_USERCONFIG
where itemName like 'EPG\_KEYWORD\_%%' ESCAPE '\'
}]
proc cts {type img text} {
puts "<a href=$::env(REQUEST_URI)?ct=$type>
<img height=18 border=0 src=/images/173_3_00_G3_$img.png>&nbsp;$text</a>";
}
puts {
<br>
<table>
<tr><td rowspan=2 valign=top>Content Type Searches</td>
<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></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>"
puts "<table cellpadding=5>"
if {[llength $res] > 0} {
puts "<tr><td>Keyword Searches</td>"
foreach keyword $res {
set kw [string range [lindex $keyword 1] 1 end]
puts "<td><a href=$env(REQUEST_URI)?term=[cgi_quote_url $kw]>$kw
</a></td>"
}
puts "</tr>"
}
puts "</table>"
$db close
puts "</fieldset>"
puts "</form>"
[spinner new {
text "Loading EPG Data..."
size "1.2em"
style "margin: 1em;"
}] start
if {$ct > 0 } {
set records [epg fetch dump -type $ct]
} elseif {$crid ne ""} {
set records [epg fetch dump -crid $crid]
} elseif {$scrid ne ""} {
set records [epg fetch dump -scrid $scrid]
} elseif {$term ne ""} {
set records [epg fetch $cmd -extra $term]
} elseif {$searchterm ne ""} {
set records [epg fetch $cmd -extra $searchterm]
} else {
set records {}
}
set favlist [epg favlist]
puts {
if {[llength $records] > 0} {
puts {
<table class=borders id=results style="clear: both;margin: 0.5em 0 0 0">
<tr>
<th>Date</th>
@ -139,6 +61,9 @@ puts {
<th>Programme</th>
<th>Synopsis</th>
</tr>
}
} else {
puts "No results found."
}
proc rsort {v1 v2} {
@ -173,10 +98,11 @@ foreach record [lsort -command rsort $records] {
}
puts "</table>"
if {$term != ""} {
if {$searchterm != ""} {
puts "
<script type=text/javascript>
highlight(document.getElementById(\"results\"), \"$term\");
highlight(document.getElementById(\"results\"),
\"$searchterm\");
</script>
"
}

View File

@ -1,27 +1,4 @@
<!--#include virtual="/lib/header.shtml" -->
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; font-size: 12px; }
</style>
<div style="width: 75%">
<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
class="text ui-widget-content ui-corner-all">
<input type=submit value=Search>
<input type=checkbox name=full id=full>
<label for=full>Search descriptions as well as titles.</label>
</fieldset>
</form>
</div>
<script type=text/javascript>
$('input:submit').button();
</script>
<!--#exec cmd="/mod/var/mongoose/include/epg.jim" -->
<!--#include virtual="/lib/footer.shtml" -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

View File

@ -1,9 +1,4 @@
function reset_results()
{
$('#dresults').empty().val('Running package command, please wait...');
}
$(document).ready(function() {
$('button').button();
@ -15,9 +10,8 @@ $(document).ready(function() {
draggable: true, resizable: true,
buttons: { "Close":
function() {$(this).dialog('close');}},
close: function(e,u) { reset_results(); }
close: function(e,u) { window.location.reload(true); }
});
reset_results();
var opkg = '/cgi-bin/opkg.jim?cmd=';
@ -26,21 +20,13 @@ $(document).ready(function() {
$('#results').show('slow');
});
$('button.remove').click(function() {
$('#dresults').load(opkg +
encodeURIComponent('remove ' + $(this).attr('id')));
$dialog.dialog('open');
});
$('button.install').click(function() {
$('#dresults').load(opkg +
encodeURIComponent('install ' + $(this).attr('id')));
$dialog.dialog('open');
});
$('button.upgrade').click(function() {
$('#dresults').load(opkg +
encodeURIComponent('upgrade ' + $(this).attr('id')));
$('button.remove, button.install, button.upgrade').click(function() {
$('#dspinner').show();
$('#dresults').load(
opkg + encodeURIComponent(
$(this).attr('action') + ' ' + $(this).attr('id')
),
function() { $('#dspinner').hide('slow') });
$dialog.dialog('open');
});
});

View File

@ -11,7 +11,10 @@ Results...
</div>
</div>
<div id=dialogue style="display: none"><pre id=dresults></pre></div>
<div id=dialogue style="display: none; align: center">
<pre id=dresults></pre>
<div id=dspinner><img src=/img/loading.gif>Processing...</div>
</div>
<!--#exec cmd="/mod/var/mongoose/include/packages.jim" -->

View File

@ -1,17 +1,17 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/epg.class
source /mod/var/mongoose/lib/spinner.class
source /mod/var/mongoose/lib/altrow
source /mod/var/mongoose/lib/cat
source /mod/var/mongoose/lib/epg_search
[spinner new {
text "Loading EPG Data..."
text "Loading Now/Next Information..."
size "1.2em"
style "margin: 1em;"
}] start
#cat /mod/var/mongoose/lib/epg_popup
source /mod/var/mongoose/lib/epg_popup
set start [clock milliseconds]

View File

@ -48,6 +48,7 @@ foreach name [lsort [array names avail]] {
}
puts "<td align=center><button id=\"$name\"
action=[string tolower $type]
class=[string tolower $type]>$type</button></td>"
puts "</tr>"

111
var/mongoose/lib/epg_search Executable file
View File

@ -0,0 +1,111 @@
puts {
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; 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>
<table>
<tr><td rowspan=2 valign=top>Content Type Searches</td>
<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></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>"
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 "<table cellpadding=5>"
puts "<tr><td>Keyword Searches</td>"
foreach keyword $res {
set kw [string range [lindex $keyword 1] 1 end]
puts "<td><a href=/cgi-bin/epg_search.jim?term=[cgi_quote_url $kw]>$kw
</a></td>"
}
puts "</tr>"
puts "</table>"
}
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>
}