#!/mod/bin/jimsh package require cgi source /mod/webif/lib/setup require epg.class spinner.class altrow jqplugin iphone-style-checkboxes freezeheader jscss service.js service.css header require totop [spinner new { text "Loading EPG Data..." size "1.2em" style "margin: 1em;" }] start require epg_popup set service [cgi_get service 4170] set records [epg dbfetch dump \ -service $service \ -sort "strftime('%%H%%J', start, 'unixepoch'), strftime('%%M', start, 'unixepoch')" \ -debug 0 ] if {[llength $records] == 0} { puts "No data for service.." exit } # Load the channel information from the first entry set tr [lindex $records 0] $tr get_channel_info set channel_num [$tr get channel_num] set channel_name [$tr get channel_name] puts "
[$tr channel_icon 40 {vertical-align:middle}] | $channel_num - $channel_name | Show synopsis? |
" set t [clock seconds] set firstday [clock format $t -format {%Y%m%d}] set daymap {} loop i 0 8 { puts " | [clock format $t -format {%a}] " puts "[clock format $t -format {%e %b}] | "
set day [clock format $t -format {%Y%m%d}]
set daymap($day) $i
set dayrmap($i) $day
incr t 86400
}
puts "
" incr day -1 loop i $daymap($currday) $day { set j $($i + 1) if {[dict exists $contprog $dayrmap($j)]} { jcprog $dayrmap($j) } puts " | " } } set currhour -1 set currday -1 set oldcell 0 foreach e $records { set start [$e get start] set day [clock format $start -format "%Y%m%d"] if {$day ni $daymap} continue set hour [clock format $start -format "%H"] if {$hour != $currhour} { if {$currhour ne "-1"} { if {$daymap($currday) < 7} { skiptoday 7 if {[dict exists $contprog $dayrmap(7)]} { jcprog $dayrmap(7) } } puts -nonewline " | " } puts "
---|---|
$hour:00 | " set currhour $hour set currday $firstday set oldcell 0 } if {$day ne $currday} { skiptoday $daymap($day) set currday $day set oldcell 0 } # Continuations from previous hour... if {!$oldcell && [dict exists $contprog $day]} { if {[cprog]} { set oldcell 1 } } prog $e $oldcell $hour set oldcell 1 } puts " |