EPG update

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@436 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-10-03 09:37:24 +00:00
parent 2fb26975e2
commit 3b8720c6d4
13 changed files with 410 additions and 244 deletions

View File

@ -27,7 +27,7 @@ $(document).ready(function() {
});
});
$('#delete_button').click(function() {
var backup = $('input.restore').val();
var backup = $('input.restore:checked').val();
if (confirm('Confirm deletion of ' + backup))
{
$('#results').load('/cgi-bin/backup/delete.jim?' +
@ -39,7 +39,7 @@ $(document).ready(function() {
}
});
$('#restore_button').click(function() {
var backup = $('input.restore').val();
var backup = $('input.restore:checked').val();
if (confirm('!!!!!!!!!!!!!!!!!!!!!!!!! PLEASE CONFIRM !!!!!!!!!!!!!!!!!!!!!!!!!\n\nAre you sure you wish to erase all scheduled recordings and favourite channels and then restore them from\n' + backup + '?'))
{
$('#restore_working').slideDown();

View File

@ -16,6 +16,7 @@ set settings [settings new]
set hostname [$settings hostname]
set smtp_server [$settings smtp_server]
set channel_group [$settings channel_group]
set epg_style [$settings epg_style]
set pkgdev [$settings pkgdev]
# Handle updates
@ -51,6 +52,7 @@ proc handle_str_update {var old {text "Value"}} {
handle_str_update hostname $hostname Hostname
_handle_update ascii smtp_server $smtp_server "SMTP Server"
handle_int_update channel_group $channel_group "Channel Group"
handle_str_update epg_style $epg_style "EPG Type"
if {[dict exists $_cgi pkgdevoff] && ![dict exists $_cgi pkgdev]} {
set _cgi(pkgdev) 0
}
@ -107,13 +109,36 @@ puts "
</tr>
"
puts "
<tr>
<form class=auto id=epg_style method=get action=$env(REQUEST_URI)>
<th class=key>Default Now/Next style</th>
<td><select id=epg_style name=epg_style
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=standard"
if {$epg_style ne "grid"} { puts " selected" }
puts ">Standard\n"
puts "<option value=grid"
if {$epg_style eq "grid"} { puts " selected" }
puts ">Grid\n"
puts "
</select>
<small>
<input name=epg_style value=\"set\" type=submit>
</small>
<div id=epg_style_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=channel_group method=get action=$env(REQUEST_URI)>
<th class=key>Channel Group for EPG</th>
<td><select id=channel_group name=channel_group
class=\"text ui-widget-content ui-corner-all\"
value=[$settings channel_group]>
class=\"text ui-widget-content ui-corner-all\">
"
set i 0

226
var/mongoose/cgi-bin/xepg.jim Executable file
View File

@ -0,0 +1,226 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
puts "Content-Type: text/html"
puts ""
header
require epg.class spinner.class altrow epg_search totop
cgi_input
puts {<link type="text/css" href="/css/xepg.css" rel="Stylesheet" />}
[spinner new {
text "Loading Now/Next Information..."
size "1.2em"
style "margin: 1em;"
}] start
require epg_popup
set stt [cgi_get stt [clock seconds]]
if {$stt <= [clock seconds]} {
set stt [clock seconds]
set current 1
} else {
set current 0
}
set favlist [epg favlist]
set hours 4.0
set seconds $($hours * 3600)
set ostt $stt
set stt [expr int($stt / 1800.0) * 1800]
set ett $(int($stt + $seconds))
set offset $(($ostt - $stt) / 1800.0)
set chanpx 120
set eventpx 780
set totalpx $($chanpx + $eventpx)
set hourpx $($eventpx / $hours)
set minpx $($hourpx / 60.0)
set secpx $($minpx / 60.0)
set start [clock milliseconds]
if {$::qepg} {
set records [epg dbfetch dump -trange "$stt:$ett"]
} else {
require channelsort
set records [channelsort [epg fetch dump -trange "$stt:$ett"]]
}
set got [clock milliseconds]
puts "<div id=buttons style=\"width: $eventpx; margin-left: ${chanpx}px;\">"
if {$stt > [clock seconds]} {
puts "<button id=earlier>&lt;&lt;&lt; Earlier</button>"
}
puts "<button id=later>Later &gt;&gt;&gt;</button>"
puts "</div>"
puts "
<div id=xepg> <div id=xepgnow></div>
<div id=xegrid>
"
puts "<div id=epgdate style=\"width: ${eventpx}px; margin-left: ${chanpx}px;\">"
puts [clock format $stt -format {%a %D}]
puts "</div>"
puts "<div class=xechan style=\"width: ${chanpx}px;\">&nbsp;</div>"
for {set i 0} {$i < $hours * 2} {incr i} {
puts "<div class=xetime id=xe$i
style=\"width: [expr $minpx * 30]px\">"
puts "[clock format $($stt + 1800 * $i) -format "%H:%M"]</div>"
}
set lim 0
set lcn 0
set bg "odd"
foreach e $records {
if {$favlist != "" && [$e get service_id] ni $favlist} {
continue
}
set chnum [$e get channel_num]
if {$chnum == 0} { continue }
if {$chnum != $lcn} {
puts "<div class=xechan style=\"width: ${chanpx}px;\">"
puts "[$e channel_icon 30]&nbsp;"
puts "$chnum
<a href=/cgi-bin/epg_service.jim?service=[$e get service_id]>
[$e get channel_name]
</a></div>"
set lcn $chnum
set le 0
set pos 0
if {$bg eq "odd"} { set bg "even" } else { set bg "odd" }
}
set es [$e get start]
set ee [expr $es + [$e get duration]]
if {$es < $le} continue
if {$es < $stt} { set es $stt }
if {$ee > $ett} { set ee $ett }
set le $ee
set left [expr int(($es - $stt) * $secpx)]
set right [expr int(($ee - $stt - 1) * $secpx)]
set px $($right - $left)
if {$pos < $left} {
set px $($px + $left - $pos - 1)
} elseif {$pos > $left} {
set px $($px - ($pos - $left - 1))
}
incr pos $px
$e process_sched
set recopts 1
if {[$e get series_crid] ne ""} { set recopts 2 }
set perc [$e percent]
set showing 0
if {$perc > 0 && $perc < 100} { set showing 1 }
set txt "[cgi_quote_html [$e get name]] <span>([\
clock format $es -format "%H:%M"] - [\
clock format $ee -format "%H:%M"])"
if {$showing} { append txt " ($perc%)" }
append txt "</span>"
set htxt "[cgi_quote_html [$e get name]] ([\
clock format $es -format "%H:%M"] - [\
clock format $ee -format "%H:%M"])"
if {$showing} { append hxt " ($perc%)" }
puts "<div class=\"xeprog $bg\"
style=\"width: [expr $px - 4]px;\" title=\"$htxt\">
<a class=event href=# xs=[$e get service_id]
xe=[$e get event_id] sch=[$e get sched_type]
rec=$recopts>"
puts $txt
puts "</a>"
puts "</div>"
}
puts "<div id=keypos style=\"float: left; clear: left;\"></div>"
puts "</div>"
puts "</div>"
set earlier $($stt - 3600 * 4)
puts "
<div style=\"clear: both;\">
<small><button id=epgswitch>
Switch to standard now/next display.
</button></small>
</div>
<script type=text/javascript>
\$(document).ready(function() {
\$('#epgswitch').button().click(function() {
window.location = '/epg.shtml';
});
\$('#earlier').button().click(function() {
window.location = '/cgi-bin/xepg.jim?stt=$earlier';
});
\$('#later').button().click(function() {
window.location = '/cgi-bin/xepg.jim?stt=$ett';
});
"
if {$current} {
puts {
var kt = $('#xe0');
var ktpos = kt.position();
var height = $('#keypos').position().top - ktpos.top;
}
puts "var nowpos = ktpos.left + (kt.width() * $offset);"
puts {
if (window.console)
console.log('NOWPOS: %d', nowpos);
$('#xepgnow')
.css('left', nowpos + 'px')
.css('top', ktpos.top)
.height(height)
.show('slow');
}
}
puts "
});
</script>
"
puts "
<a href=/cgi-bin/settings.jim>
<img border=0 height=14 src=/images/421_1_00_CH_Title_2R_Arrow.png>
Visit settings to change EPG options.
</a><br>
"
set end [clock milliseconds]
puts "<font class=footnote>
Retrieved in: [expr [expr $got - $start] / 1000.0] seconds.
</font>"
epg cleanup
footer

View File

@ -1,71 +0,0 @@
table.epggrid td
{
white-space: nowrap;
padding: 2px;
}
td.epgdate
{
border-left: 1px solid #669933;
border-right: 1px solid #669933;
border-top: 1px solid #669933;
}
td.epgtime
{
border-left: 1px solid #669933;
}
td.epgchan, td.epgchan img
{
border-top: 1px solid #669933;
vertical-align: middle;
}
td.epgprog
{
margin: 0 0.2em;
padding: 0 0.2em;
border: 1px solid #ccc;
border-radius: 10px;
-moz-border-radius: 10px;
}
td.epgprog div
{
overflow: hidden;
}
.meter-wrap
{
position: relative;
}
.meter-wrap
{
background: transparent;
}
.meter-value
{
margin: 0;
padding: 0;
height: 28px;
background-color: #0a0;
width: 40%;
border-radius: 5px;
-moz-border-radius: 5px;
}
.meter-text
{
position: absolute;
top:0;
left:0;
color: #fff;
width: 100%;
padding-top: 3px;
vertical-align: middle;
}

View File

@ -70,13 +70,13 @@ table.borders, table.borders td, table.borders th
empty-cells: show;
}
table tr.odd, table td.odd, table th.odd
.odd
{
background: #ccff99;
color: black;
}
table tr.even, table td.even, table th.even
.even
{
background: #ffffcc;
color: black;

View File

@ -0,0 +1,113 @@
div#xepg
{
position: relative;
}
div#xepgnow
{
display: none;
position: absolute;
width: 2px;
height: 100%;
background: yellow;
top: 0px;
left: 0px;
z-index: 9999;
box-shadow: 2px 2px 11px #666;
-moz-box-shadow: 2px 2px 11px #666;
-webkit-box-shadow: 2px 2px 11px #666;
opacity:0.7;
/*filter:alpha(opacity=70);*/
}
div.xetick
{
display: none;
position: absolute;
width: 1px;
height: 100%;
background: #ccc;
top: 0px;
left: 0px;
/*
z-index: 9999;
box-shadow: 2px 2px 11px #666;
-moz-box-shadow: 2px 2px 11px #666;
-webkit-box-shadow: 2px 2px 11px #666;
opacity:0.7;
*/
/*filter:alpha(opacity=70);*/
}
div#epgdate
{
border-left: 1px solid #669933;
border-right: 1px solid #669933;
border-top: 1px solid #669933;
clear: left;
float: left;
}
/*
div#xegrid
{
}
*/
div.xerow
{
}
div.xechan
{
vertical-align: middle;
float: left;
clear: left;
white-space: nowrap;
overflow: hidden;
height: 25px;
padding: 3px 0;
margin: 3px 0;
}
div.xechan img
{
vertical-align: middle;
}
div.xetime
{
float: left;
border-left: 1px solid #669933;
}
div.xeprog
{
overflow: hidden;
white-space: nowrap;
float: left;
vertical-align: middle;
height: 25px;
padding: 4px 0 3px 2px;
margin: 3px 0 3px 2px;
border: 1px solid #ccc;
border-radius: 10px;
-moz-border-radius: 10px;
}
div.xeprog span
{
font-style: italic;
font-size: 0.7em;
}
div#buttons
{
padding: 0.5em;
}
button#later
{
margin-left: 2em;
}

View File

@ -48,11 +48,11 @@ $(document).ready(function() {
</div>
<div style="float: left">
<center>
<a href=/epg.shtml>
<a href=<!--#exec cmd="/mod/var/mongoose/include/epgloc.jim" -->>
<img src=/images/328_1_26_Menu_TV_Guide.png border=0 width=217 height=228>
</a>
<br>
<a href=/epg.shtml>
<a href=<!--#exec cmd="/mod/var/mongoose/include/epgloc.jim" -->>
<b>EPG</b>
</a>
<br>

View File

@ -1,4 +0,0 @@
<!--#include virtual="/lib/header.shtml" -->
<!--#exec cmd="/mod/var/mongoose/include/xepg.jim" -->
<!--#include virtual="/lib/footer.shtml" -->

View File

@ -14,7 +14,7 @@ require epg_popup
set start [clock milliseconds]
set now [clock seconds]
set then $($now + 7200)
set then $($now + 14400)
if {$::qepg} {
set records [epg dbfetch dump -trange "$now:$then"]
} else {
@ -26,6 +26,11 @@ set got [clock milliseconds]
set favlist [epg favlist]
puts {
<small><button id=switch>Switch to grid-style Now/Next</button></small>
<script type=text/javascript>
$('#switch').button().click(function() {
window.location = '/cgi-bin/xepg.jim'; });
</script>
<table class=borders>
<tr>
<th colspan=3>Channel</th>

11
var/mongoose/include/epgloc.jim Executable file
View File

@ -0,0 +1,11 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require settings.class
if {[[settings] epg_style] eq "grid"} {
puts -nonewline "/cgi-bin/xepg.jim"
} else {
puts -nonewline "/epg.shtml"
}

View File

@ -1,159 +0,0 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require epg.class spinner.class altrow epg_search totop
puts {<link type="text/css" href="/css/epg.css" rel="Stylesheet" />}
[spinner new {
text "Loading Now/Next Information..."
size "1.2em"
style "margin: 1em;"
}] start
require epg_popup
set start [clock milliseconds]
set stt [clock seconds]
set stt [expr int($stt / 1800) * 1800]
set ett $($stt + 14400)
if {$::qepg} {
set records [epg dbfetch dump -trange "$stt:$ett"]
} else {
require channelsort
set records [channelsort [epg fetch dump -trange "$stt:$ett"]]
}
set got [clock milliseconds]
set favlist [epg favlist]
puts {
<table class=epggrid style="float: left; clear: both">
<tr>
<td></td>
<td class=epgdate colspan=48>
}
puts [clock format $stt -format {%a %D}]
puts { </td></tr><tr><td></td> }
for {set i 0} {$i < 48} {incr i} {
puts "<td class=epgdummy></td>"
}
puts "</tr><tr><td></td>"
for {set i 0} {$i < 8} {incr i} {
puts "<td class=epgtime colspan=6>
[clock format $($stt + 1800 * $i) -format "%H:%M"]</td>"
}
puts "</tr>"
set lcn 0
set bg "odd"
foreach record $records {
if {$favlist != "" && [$record get service_id] ni $favlist} {
continue
}
set chnum [$record get channel_num]
if {$chnum == 0} { continue }
if {$chnum != $lcn} {
if {$lcn > 0} { puts "</tr>" }
puts "<tr>";
puts "<td class=epgchan>[$record channel_icon 30]&nbsp;"
puts "$chnum
<a href=/cgi-bin/epg_service.jim?service=[$record get service_id]>
[$record get channel_name]
</a></td>"
set lcn $chnum
set le 0
if {$bg eq "odd"} { set bg "even" } else { set bg "odd" }
}
set es [$record get start]
set ee [expr $es + [$record get duration]]
set txt "[cgi_quote_html [$record get name]] ([\
clock format $es -format "%H:%M"] - [\
clock format $ee -format "%H:%M"])"
if {$es < $le} { continue }
if {$es < $stt} { set es $stt }
if {$ee > $ett} { set ee $ett }
set le $ee
set columns [expr int(($ee - $es) / 300)]
if {$columns < 1} { set columns 1 }
set pxwidth $($columns * 13)
set perc [$record percent]
set showing [$record showing]
if {$showing} {
append txt " ($perc%)"
}
puts "<td class=\"epgprog $bg\" colspan=$columns>\n"
if {$showing} {
puts "
<div class=\"meter-wrap\" style=\"width: ${pxwidth}px\">
<div class=\"meter-value\" style=\"width: ${perc}%\">
<div class=\"meter-text\""
} else {
puts "<div style=\"width: ${pxwidth}px\""
}
puts " title=\"${txt}\" alt=\"${txt}\">\n"
puts "<a class=event href=# xs=[$record get service_id]
xe=[$record get event_id] sch=2 rec=1>"
puts $txt
puts "</a>\n"
puts "</div>"
if {$showing} { puts "</div></div>" }
puts "</td>\n"
}
if {$lcn > 0} { puts "</tr>" }
puts "</table><br><br>"
puts {
<small><button id=epgswitch>
Switch to standard now/next display.
</button></small>
<script type=text/javascript>
$(document).ready(function() {
$('#epgswitch').button().click(function() {
window.location = '/epg.shtml';
});
$('#earlier').button().click(function() {
window.location = '/xepg.shtml?stt=<?php echo $stt - 3600*4; ?>';
});
$('#later').button().click(function() {
window.location = '/xepg.shtml?stt=<?php echo $ett; ?>';
});
});
</script>
}
puts "
<a href=/cgi-bin/settings.jim>
<img border=0 height=14 src=/images/421_1_00_CH_Title_2R_Arrow.png>
Visit settings to change EPG options.
</a><br>
"
set end [clock milliseconds]
puts "<font class=footnote>
Retrieved in: [expr [expr $got - $start] / 1000.0] seconds.
Rendered in: [expr [expr $end - $start] / 1000.0] seconds.
</font>"
epg cleanup

View File

@ -55,7 +55,14 @@ cts 9 "Education" "Education/Science/Factual"
puts "</td><td>"
cts 10 "Leisure" "Leisure"
puts "</td><td><a href=/epg.shtml>Now/Next</a>"
puts "</td><td>"
if {[[settings] epg_style] eq "grid"} {
puts "<a href=/cgi-bin/xepg.jim>"
} else {
puts "<a href=/epg.shtml>"
}
puts "Now/Next</a>"
puts "</td></tr><tr><td>"

View File

@ -19,6 +19,7 @@ if {![file exists /mod/etc/webif.db]} {
class settings {
hostname ""
channel_group 0
epg_style "standard"
smtp_server ""
pkgdev 0
}
@ -99,6 +100,18 @@ settings method channel_group {{group -1}} {
return [$self _nval_setting channel_group $group]
}
settings method epg_style {{style -1}} {
if {$style != -1} {
if {$style eq "grid"} { set style 1 } else { set style 0}
return [$self _nval_setting epg_style $style]
}
set val [$self _nval_setting epg_style]
if {$val == 1} {
return "grid"
}
return "standard"
}
settings method pkgdev {{val -1}} {
return [$self _nval_setting pkgdev $val]
}