2011-10-03 09:37:24 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2012-05-21 20:23:41 +00:00
|
|
|
source /mod/webif/lib/setup
|
2011-10-03 09:37:24 +00:00
|
|
|
|
|
|
|
header
|
|
|
|
|
|
|
|
require epg.class spinner.class altrow epg_search totop
|
|
|
|
|
2012-11-06 22:58:17 +00:00
|
|
|
puts {
|
|
|
|
<link type="text/css" href="/css/xepg.css" rel="Stylesheet" />
|
|
|
|
<script type=text/javascript src=/js/enadis.js></script>
|
|
|
|
}
|
2011-10-03 09:37:24 +00:00
|
|
|
|
|
|
|
[spinner new {
|
2012-11-06 22:58:17 +00:00
|
|
|
text "Loading EPG Information..."
|
2011-10-03 09:37:24 +00:00
|
|
|
size "1.2em"
|
|
|
|
style "margin: 1em;"
|
|
|
|
}] start
|
|
|
|
|
|
|
|
require epg_popup
|
|
|
|
|
2012-11-06 22:58:17 +00:00
|
|
|
set now [clock seconds]
|
|
|
|
set stt [cgi_get stt $now]
|
|
|
|
if {$stt <= $now} {
|
|
|
|
set stt $now
|
2011-10-03 09:37:24 +00:00
|
|
|
set current 1
|
|
|
|
} else {
|
|
|
|
set current 0
|
|
|
|
}
|
|
|
|
|
2012-05-30 19:51:20 +00:00
|
|
|
set favgroup [[settings] channel_group]
|
2011-10-03 09:37:24 +00:00
|
|
|
|
2013-01-05 22:27:00 +00:00
|
|
|
set hours [expr 1.0 * [[settings] xepghours]]
|
|
|
|
if {$hours == 0} { set hours 4.0 }
|
2011-10-03 09:37:24 +00:00
|
|
|
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)
|
|
|
|
|
2012-11-06 22:58:17 +00:00
|
|
|
set chanpx 160
|
2011-10-03 22:47:44 +00:00
|
|
|
set eventpx 1000
|
2011-10-03 09:37:24 +00:00
|
|
|
set totalpx $($chanpx + $eventpx)
|
2011-10-03 22:47:44 +00:00
|
|
|
set contwidth $($totalpx + 50)
|
2011-10-03 09:37:24 +00:00
|
|
|
|
|
|
|
set hourpx $($eventpx / $hours)
|
|
|
|
set minpx $($hourpx / 60.0)
|
|
|
|
set secpx $($minpx / 60.0)
|
|
|
|
|
|
|
|
set start [clock milliseconds]
|
|
|
|
if {$::qepg} {
|
2012-05-30 19:51:20 +00:00
|
|
|
if {$favgroup} {
|
|
|
|
set records [epg dbfetch dump \
|
|
|
|
-trange "$stt:$ett" -fav $favgroup]
|
|
|
|
} else {
|
|
|
|
set records [epg dbfetch dump -trange "$stt:$ett"]
|
|
|
|
}
|
|
|
|
|
2011-10-03 09:37:24 +00:00
|
|
|
} else {
|
|
|
|
require channelsort
|
|
|
|
set records [channelsort [epg fetch dump -trange "$stt:$ett"]]
|
|
|
|
}
|
|
|
|
set got [clock milliseconds]
|
|
|
|
|
2012-11-06 22:58:17 +00:00
|
|
|
proc but {label time {active 1}} {
|
|
|
|
puts -nonewline "<button style=\"margin-right: 2em\" tt=$time"
|
|
|
|
if {$active} {
|
|
|
|
puts -nonewline " class=nav"
|
|
|
|
} else {
|
|
|
|
puts -nonewline " disabled class=\"nav ui-state-disabled\""
|
|
|
|
}
|
|
|
|
puts " active=$active>$label</button>"
|
2011-10-03 09:37:24 +00:00
|
|
|
}
|
2012-11-06 22:58:17 +00:00
|
|
|
|
2013-01-05 22:27:00 +00:00
|
|
|
puts "<!-- Hours $hours ($seconds) -->"
|
2012-11-06 22:58:17 +00:00
|
|
|
puts "<div id=buttons style=\"width: $eventpx; margin-left: ${chanpx}px;\">"
|
|
|
|
|
2012-11-09 21:56:36 +00:00
|
|
|
but "<< -1 Week" $($stt - 3600 * 24 * 7) \
|
2012-11-12 22:42:33 +00:00
|
|
|
$($stt - $now + 3600 >= 3600 * 24 * 7)
|
2012-11-09 21:56:36 +00:00
|
|
|
but "<< -1 Day" $($stt - 3600 * 24) $($stt - $now >= 3600 * 23)
|
2012-11-06 22:58:17 +00:00
|
|
|
but "<< Earlier", $($stt - 3600 * 4) $($stt > $now)
|
|
|
|
but "< Now >" $now $($current == 0)
|
|
|
|
but ">> Later" $ett;
|
|
|
|
but ">> +1 Day" $($stt + 3600 * 24) $($stt < $now + 8 * 3600 * 24)
|
|
|
|
but ">> +1 Week" $($stt + 3600 * 24 * 7) $($stt < $now + 8 * 3600 * 24)
|
|
|
|
|
2011-10-03 09:37:24 +00:00
|
|
|
puts "</div>"
|
|
|
|
|
|
|
|
puts "
|
2012-11-06 22:58:17 +00:00
|
|
|
<script type=text/javascript>
|
|
|
|
\$('button.nav').button();
|
|
|
|
</script>
|
2011-10-03 22:47:44 +00:00
|
|
|
<div id=xepg style=\"min-width: ${contwidth}px; overflow: auto\">
|
|
|
|
<div id=xepgnow></div>
|
2011-10-03 09:37:24 +00:00
|
|
|
<div id=xegrid>
|
|
|
|
"
|
|
|
|
|
|
|
|
puts "<div id=epgdate style=\"width: ${eventpx}px; margin-left: ${chanpx}px;\">"
|
2012-11-06 22:58:17 +00:00
|
|
|
puts [clock format $stt -format {%a %d/%m/%Y}]
|
|
|
|
puts "<input type=hidden id=xepg_dp stt=$stt>"
|
2011-10-03 09:37:24 +00:00
|
|
|
puts "</div>"
|
|
|
|
|
|
|
|
puts "<div class=xechan style=\"width: ${chanpx}px;\"> </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 {
|
|
|
|
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] "
|
|
|
|
puts "$chnum
|
2012-02-07 22:48:54 +00:00
|
|
|
<a href=/cgi-bin/epg/service.jim?service=[$e get service_id]
|
2011-10-03 22:47:44 +00:00
|
|
|
title=\"[$e get channel_name]\">
|
2011-10-03 09:37:24 +00:00
|
|
|
[$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%)" }
|
|
|
|
|
2013-04-04 22:20:41 +00:00
|
|
|
set lbg $bg
|
|
|
|
if {[$e scheduled]} { set lbg "blueshade" }
|
|
|
|
|
|
|
|
puts "<div class=\"xeprog $lbg\"
|
2011-10-03 09:37:24 +00:00
|
|
|
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>
|
2012-11-06 22:58:17 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
puts "
|
2011-10-03 09:37:24 +00:00
|
|
|
|
|
|
|
<script type=text/javascript>
|
|
|
|
\$(document).ready(function() {
|
|
|
|
|
|
|
|
\$('#epgswitch').button().click(function() {
|
|
|
|
window.location = '/epg.shtml';
|
|
|
|
});
|
2012-11-06 22:58:17 +00:00
|
|
|
|
|
|
|
\$('button.nav').click(function() {
|
|
|
|
window.location = '/cgi-bin/xepg.jim?stt=' + \$(this).attr('tt') +
|
|
|
|
'&pos=' + \$('#xegrid').scrollTop();
|
2011-10-03 09:37:24 +00:00
|
|
|
});
|
2012-11-06 22:58:17 +00:00
|
|
|
|
|
|
|
\$('#xepg_dp').datepicker({
|
|
|
|
buttonImage: '/img/cal.gif',
|
|
|
|
buttonImageOnly: true,
|
|
|
|
showOn: 'button',
|
|
|
|
dateFormat: '@',
|
|
|
|
minDate: '[expr $now * 1000]',
|
|
|
|
maxDate: '[expr ($now + 7 * 86400) * 1000]',
|
|
|
|
onSelect: function(val, sel) {
|
|
|
|
var stt = \$(this).attr('stt');
|
|
|
|
// Extract date part
|
2013-04-03 22:42:15 +00:00
|
|
|
dval = Math.round(val / 86400000.0);
|
2012-11-06 22:58:17 +00:00
|
|
|
// Extract current time part
|
|
|
|
var tm = ~~(stt % 86400);
|
|
|
|
|
|
|
|
var ret = dval * 86400 + tm;
|
|
|
|
|
|
|
|
window.location = '/cgi-bin/xepg.jim?stt=' + ret;
|
|
|
|
}
|
2011-10-03 09:37:24 +00:00
|
|
|
});
|
2012-11-06 22:58:17 +00:00
|
|
|
|
|
|
|
\$('img.ui-datepicker-trigger').hover(
|
|
|
|
function() { \$(this).css('cursor', 'pointer'); },
|
|
|
|
function() { \$(this).css('cursor', 'auto'); }
|
|
|
|
);
|
|
|
|
|
2011-10-03 09:37:24 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
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>
|
|
|
|
"
|
|
|
|
|
2012-05-30 19:51:20 +00:00
|
|
|
epg cleanup
|
|
|
|
|
2011-10-03 09:37:24 +00:00
|
|
|
set end [clock milliseconds]
|
|
|
|
puts "<font class=footnote>
|
|
|
|
Retrieved in: [expr [expr $got - $start] / 1000.0] seconds.
|
|
|
|
</font>"
|
|
|
|
|
|
|
|
footer
|
|
|
|
|