diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim index 5bf6479..aa2650d 100755 --- a/var/mongoose/cgi-bin/browse.jim +++ b/var/mongoose/cgi-bin/browse.jim @@ -2,7 +2,7 @@ package require cgi source /mod/webif/lib/setup -require ts.class pretty_size system.class settings.class escape +require ts.class pretty_size system.class settings.class escape browse.class puts "Content-Type: text/html" puts "" @@ -42,8 +42,6 @@ proc icon {img {hover ""} {extra ""} {class "va"}} { } proc directory {file bfile tbfile} { - global flatten - puts "
" set img "/images/711_1_09_Media_Folder.png" if {$bfile eq $::dustbin} { set img "/img/Dustbin_Folder.png" } @@ -55,38 +53,14 @@ proc directory {file bfile tbfile} { puts "$bfile " - set noflat 0 - if $flatten { - if {[string match {\[*\]} [file tail $file]]} { set noflat 1 } - if {[file exists "$file/.noflatten"]} { set noflat 1 } - if $noflat { icon "/img/flat-tyre.png" "No-flatten" } - } + lassign [{dir iconset} $file] icons attrs - set autoshrink 0 - if {[file exists "$file/.autoshrink"]} { - set autoshrink 1 - icon "/img/compress.png" "Auto-shrink" - } - - set autodedup 0 - if {[file exists "$file/.autodedup"]} { - set autodedup 1 - icon "/img/dedup.png" "Auto-dedup" - } - - set autodecrypt 0 - if {[file exists "$file/.autodecrypt"]} { - set autodecrypt 1 - icon "/img/decrypt.png" "Auto-decrypt" - } + puts [join $icons ""] puts -nonewline " @@ -106,10 +80,10 @@ proc entry {file} {{i 0}} { } if [file isdirectory "$file"] { directory $file $bfile $tbfile - continue + return } set ext [file extension $file] - if {$ext in $::ignore || $ext ni $::include} { continue } + if {$ext in $::ignore || $ext ni $::include} { return } file stat $file st set rsz $st(size) diff --git a/var/mongoose/cgi-bin/epg/search.jim b/var/mongoose/cgi-bin/epg/search.jim index c68d83e..9b35144 100755 --- a/var/mongoose/cgi-bin/epg/search.jim +++ b/var/mongoose/cgi-bin/epg/search.jim @@ -60,7 +60,7 @@ if {$ct > 0 } { } elseif {$scrid ne ""} { set records [epg fetch dump -scrid $scrid] } elseif {$searchterm ne ""} { - set records [epg fetch $cmd -extra $searchterm] + set records [epg dbfetch $cmd -term $searchterm] } else { set records {} } diff --git a/var/mongoose/cgi-bin/settings.jim b/var/mongoose/cgi-bin/settings.jim index 33895f3..bba63ce 100755 --- a/var/mongoose/cgi-bin/settings.jim +++ b/var/mongoose/cgi-bin/settings.jim @@ -30,6 +30,7 @@ set channel_group [$settings channel_group] set epg_style [$settings epg_style] set pkgdev [$settings pkgdev] set notoolbar [$settings notoolbar] +set nomobile [$settings nomobile] # Handle updates @@ -67,6 +68,7 @@ handle_int_update channel_group $channel_group "Channel Group" handle_str_update epg_style $epg_style "EPG Type" handle_int_update pkgdev $pkgdev "Development Package Display" handle_int_update notoolbar $notoolbar "Disable toolbar" +handle_int_update nomobile $nomobile "Disable mobile link" set acluser [cgi_get acluser "-"] set aclpass [cgi_get aclpass "-"] @@ -153,6 +155,17 @@ puts "> " +puts -nonewline " + + Mobile link on main page? + +
+ + +" + puts "
diff --git a/var/mongoose/cgi-bin/settings.js b/var/mongoose/cgi-bin/settings.js index 1a05b18..a395f3f 100644 --- a/var/mongoose/cgi-bin/settings.js +++ b/var/mongoose/cgi-bin/settings.js @@ -94,5 +94,24 @@ $(document).ready(function () { .delay(2000).fadeOut('slow'); }); }); + + $('#mobile_toggle').change(function() { + var arg = '1'; + if ($(this).attr('checked')) + arg = '0'; + + $(this).disable(); + + $('#mobile_output') + .empty() + .show('slow') + .load('/cgi-bin/settings.jim?nomobile=' + arg, + function() { + $('#mobile_toggle').enable(); + $('#mobile_output') + .css('font-style', 'italic') + .delay(2000).fadeOut('slow'); + }); + }); }); diff --git a/var/mongoose/cgi-bin/status.jim b/var/mongoose/cgi-bin/status.jim index 639f746..a59ce8f 100755 --- a/var/mongoose/cgi-bin/status.jim +++ b/var/mongoose/cgi-bin/status.jim @@ -135,7 +135,7 @@ if {![system instandby] && $play < 1} { if {[system instandby]} { if {$runmode eq "cgi"} { lappend output [concat \ - "\n" + "\n" \ " \n" \ " System is in standby.\n" \ diff --git a/var/mongoose/html/diag/diag.jim b/var/mongoose/html/diag/diag.jim index 558c848..2364337 100755 --- a/var/mongoose/html/diag/diag.jim +++ b/var/mongoose/html/diag/diag.jim @@ -122,6 +122,7 @@ View: foreach file [lsort [concat \ [glob -nocomplain /var/log/*.log] \ [glob -nocomplain /mod/tmp/*.log] \ + [glob -nocomplain /mnt/hd3/*.log] \ ]] { puts " diff --git a/var/mongoose/html/img/desktop.png b/var/mongoose/html/img/desktop.png new file mode 100644 index 0000000..f757c05 Binary files /dev/null and b/var/mongoose/html/img/desktop.png differ diff --git a/var/mongoose/html/img/mobile.png b/var/mongoose/html/img/mobile.png new file mode 100644 index 0000000..745560c Binary files /dev/null and b/var/mongoose/html/img/mobile.png differ diff --git a/var/mongoose/html/index.shtml b/var/mongoose/html/index.shtml index 9502360..b784832 100644 --- a/var/mongoose/html/index.shtml +++ b/var/mongoose/html/index.shtml @@ -1,6 +1,6 @@ -
+
Status... @@ -19,8 +19,6 @@ $(document).ready(function() { - -
diff --git a/var/mongoose/html/m/browse.jim b/var/mongoose/html/m/browse.jim new file mode 100755 index 0000000..7ab0712 --- /dev/null +++ b/var/mongoose/html/m/browse.jim @@ -0,0 +1,184 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require ts.class pretty_size system.class settings.class escape browse.class + +cgi_input + +set ignore {.nts .thm .hmi} +set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov .hmt} + +set dir [cgi_get dir [system mediaroot]] + +set model [system model] +set dustbin [system dustbin 1] + +proc icon {img {hover ""} {extra ""} {class "va"}} { + puts -nonewline "\"$hover\"" +} + +proc directory {file bfile tbfile {img /images/711_1_09_Media_Folder.png}} { + if {$bfile eq $::dustbin} { set img "/img/Dustbin_Folder.png" } + lassign [{dir iconset} $file] icons attrs + puts "
  • + +

    $bfile

    + " + if {[llength $icons]} { + puts "

    [join $icons ""]

    " + } + puts "

    + +

    +
  • + " +} + +proc entry {file {i 0}} { + set bfile [file tail $file] + regsub -all " +" $bfile "" tbfile + if {[string index $bfile 0] == "\025"} { + set bfile [string range $bfile 1 end] + } + if [file isdirectory "$file"] { + directory $file $bfile $tbfile + return + } + set ext [file extension $file] + if {$ext in $::ignore || $ext ni $::include} { return } + + file stat $file st + set rsz $st(size) + set sz [pretty_size $rsz] + + set base [file rootname $file] + + if {$ext eq ".ts" && [file exists "${base}.nts"]} { + set type ts + set ts [ts fetch $file 1] + set img Video_TS + set omenu opt + } elseif {$ext eq ".hmt"} { + if {[file exists "${base}.ts"]} { continue } + # Sole hmt file indicates failure to track. + set type bad + set ts 0 + set img Video_Failed + set omenu oopt + } else { + set type gen + set ts 0 + set img Video_Other + set omenu oopt + } + + set new 0 + if {$type eq "ts"} { + if {[$ts flag "New"] > 0} { set new 1 } + } elseif {$type eq "gen"} { + if {![file exists "${base}.hmi"]} { set new 1 } + } + + if {$new} { append img _New } + + set fscl "fs" + set synopsis "" + if {$type eq "ts"} { + set fscl "fs fsts" + set synopsis [cgi_quote_html [$ts get synopsis]] + } + + puts "
  • + +

    $bfile

    +

    + $sz +

    +

    + " + + # Icons + + set locked 0 + set encd 0 + set odencd 1 + set def unknown + set bx 0 + set dlna 0 + if {$type eq "ts"} { + # HD / SD + if {[$ts get definition] eq "HD"} { + set def HD + set img "172_1_00_HD" + } else { + set def SD + set img "172_1_26_SD" + } + icon "/images/$img.png" + + # Locked + if {[$ts flag "Locked"] > 0} { + set locked 1 + icon "/images/178_1_00_Icon_Lock.png" "Locked" + } + + # Encrypted + if {[$ts flag "Encrypted"] > 0} { + set encd 1 + icon "/images/749_1_26_Video_Encryption.png" "" + } + if {![$ts flag "ODEncrypted"]} { + set odencd 0 + icon "/img/Decrypted.png" "Decrypted" + } + + # Guidance + if {[$ts flag "Guidance"] > 0} { + icon "/images/174_1_26_GuidancePolicy.png" + } + + # Indexed + if {$::model eq "HDR" && [llength [$ts dlnaloc]]} { + icon "/img/dlna.png" "Indexed by DLNA Server" + set dlna 1 + } + + # Shrunk (shown when necessary via Ajax) + icon "/img/compress.png" "Shrunk" \ + "id=\"sp_$tbfile\"" "va hidden" + } + + puts "

  • " +} + +mheader + +puts " + $dir +
      +
    • $dir +

      + +

      +
    • +" + +# Parent directory +directory [join [lrange [split $dir /] 0 end-1] /] "\[parent directory\]" \ + _parent "/images/711_3_09_Media_Folder_UP.png" + +set files [readdir -nocomplain $dir] +set files [lsort $files] + +foreach file $files { entry "$dir/$file" } + +puts "
    " + +mfooter + diff --git a/var/mongoose/html/m/channel.jim b/var/mongoose/html/m/channel.jim index 8d4761d..1b33298 100755 --- a/var/mongoose/html/m/channel.jim +++ b/var/mongoose/html/m/channel.jim @@ -3,6 +3,7 @@ package require cgi source /mod/webif/lib/setup require epg.class +source include/epgcell.jim cgi_input @@ -26,6 +27,8 @@ puts " " foreach e $records { + $e copy_channel_info $tr + set st [$e get start] set nday [clock format $st -format "%F"] if {$day ne $nday} { @@ -34,24 +37,8 @@ foreach e $records { [clock format $st -format "%a %d %b %Y"] " } - set et $($st + [$e get duration]) - puts " -
  • -

    [$e get name]

    -

    [$e get text]

    - " - set guidance [$e get warning] - if {$guidance ne ""} { - puts "

    - $guidance

    " - } - puts " -

    - [clock format $st -format "%H:%M"] - - [clock format $et -format "%H:%M"] -

    -
  • - " + + epgcell $e 1 } puts "" diff --git a/var/mongoose/html/m/event_d.jim b/var/mongoose/html/m/event_d.jim new file mode 100755 index 0000000..2d59f71 --- /dev/null +++ b/var/mongoose/html/m/event_d.jim @@ -0,0 +1,155 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require epg.class + +cgi_input + +set sid [cgi_get sid 0] +set eid [cgi_get eid 0] + +mheader + +set record [lindex [epg fetch dump -service $sid -event $eid] 0] +$record get_channel_info +set others [$record othertimes] + +puts " + +
    +

    EPG Event

    +
    + +
    + + + + + + + + + + + + + + + + + +" + +if {[$record get warning] != ""} { + puts " + + + + + " +} + +if {[$record get event_crid] != ""} { + puts " + + + + " +} + +if {[$record get series_crid] != ""} { + puts " + + + + " +} + +if {[$record get rec_crid] != ""} { + set rec [$record recommended] + if {$rec != ""} { + puts "" + } +} + +puts " + + + +
    Programme[$record get name]
    Synopsis[$record get text]
    Start[clock format [$record get start] -format {%c %Z}] +" + +foreach o $others { + if {[$o ended]} { continue } + $o get_channel_info + $o process_sched + if {[$o get series_crid] eq ""} { set ro 1 } else { set ro 2 } + puts -nonewline "
        " + puts -nonewline "Also: " + puts -nonewline "" + puts -nonewline "[clock format [$o get start] -format {%c %Z}]" + puts -nonewline " on " + puts -nonewline [$o channel_icon 16] + puts -nonewline "[$o get channel_name] " + puts "" + puts "" +} + +puts " +
    Duration[clock format [$record get duration] -format %T] +" +if {[$record showing]} { + puts [progressbar [$record percent]] +} +puts " +
    Type[$record get content_type] ([$record get content_code])
    Warning[$record get warning]
    CRID + [$record get channel_crid][$record get event_crid] +
    Series CRID + [$record get channel_crid][$record get series_crid] +
    Recommends + [$rec get name] + ([$rec get channel_crid][$rec get event_crid]) +
    + [$record channel_icon 50] + [join [$record icon_set] " "] +
    +" + +# Buttons + +if {[$record get start] < [clock seconds]} { + set rec 0 +} elseif {[$record get series_crid] ne ""} { + set rec 2 +} else { + set rec 1 +} + +$record process_sched +set sch [$record get sched_type] + +if {!$sch} { + if {$rec == 2} { + puts " + Record Series" + } + if {$rec > 0} { + puts " + Record Programme" + puts " + Set Reminder" + } +} +puts "Close" + +puts "
    " + +epg cleanup + +mfooter + diff --git a/var/mongoose/html/m/include/epgcell.jim b/var/mongoose/html/m/include/epgcell.jim new file mode 100755 index 0000000..ea3d34b --- /dev/null +++ b/var/mongoose/html/m/include/epgcell.jim @@ -0,0 +1,37 @@ + +proc epgcell {e {aside 0}} { + $e get_channel_info + set st [$e get start] + set et $($st + [$e get duration]) + puts " +
  • + [$e channel_icon 80] +

    [$e get name]

    +

    + [clock format $st -format {%a %d %b %Y %H:%M}] + - + [clock format $et -format {%H:%M}] +

    +

    + [join [$e icon_set 14] ""] + [$e get text]

    + " + set guidance [$e get warning] + if {$guidance ne ""} { + puts "

    + $guidance

    " + } + if {[$e showing]} { + puts "

    [progressbar [$e percent]]

    " + } + if {$aside} { + puts " +

    + [clock format $st -format "%H:%M"] - + [clock format $et -format "%H:%M"] +

    + " + } +} + diff --git a/var/mongoose/html/m/include/searchform.jim b/var/mongoose/html/m/include/searchform.jim new file mode 100644 index 0000000..5bb5ad9 --- /dev/null +++ b/var/mongoose/html/m/include/searchform.jim @@ -0,0 +1,32 @@ + +puts -nonewline " + + + +
    + + + +
    + +" + diff --git a/var/mongoose/html/m/include/searchstyle.jim b/var/mongoose/html/m/include/searchstyle.jim new file mode 100644 index 0000000..e974dee --- /dev/null +++ b/var/mongoose/html/m/include/searchstyle.jim @@ -0,0 +1,8 @@ + +puts -nonewline " + +" + diff --git a/var/mongoose/html/m/index.jim b/var/mongoose/html/m/index.jim index deb7616..634120a 100755 --- a/var/mongoose/html/m/index.jim +++ b/var/mongoose/html/m/index.jim @@ -5,6 +5,8 @@ require settings.class plugin mheader +source include/searchstyle.jim + puts "
    " diff --git a/var/mongoose/html/m/lib/footer.jim b/var/mongoose/html/m/lib/footer.jim index dc463ab..85196a9 100755 --- a/var/mongoose/html/m/lib/footer.jim +++ b/var/mongoose/html/m/lib/footer.jim @@ -1,15 +1,17 @@ #!/mod/bin/jimsh -puts { -
  • +puts {
    } -
    -} +if {!$_dialog} { + puts "
    " -if {![catch { - set rendertime [expr [expr [clock milliseconds] - $renderstart] / 1000.0] - }]} { - puts "Rendered in: $rendertime seconds" + if {![catch { + set rendertime $(([clock milliseconds] - $renderstart) / 1000.0) + }]} { + puts " + Rendered in: $rendertime seconds" + } + puts "
    " } puts { diff --git a/var/mongoose/html/m/lib/header.jim b/var/mongoose/html/m/lib/header.jim index 1dee4b3..ebe41b2 100755 --- a/var/mongoose/html/m/lib/header.jim +++ b/var/mongoose/html/m/lib/header.jim @@ -34,23 +34,44 @@ puts { } -set pageid [string range $env(SCRIPT_NAME) 3 end-4] +if [dict exists $env SCRIPT_NAME] { + set pageid [string range $env(SCRIPT_NAME) 3 end-4] +} else { + set pageid test +} -puts " - +set _dialog 0 +if {[string range $pageid end-1 end] eq "_d"} { + set _dialog 1 +} +puts "" + +if {$_dialog} { + puts "
    \n" +} else { + puts "
    - +
    + +
    +
    + +
    +
    +

    [system model] ([system hostname])

    -
    -" +} set renderstart [clock milliseconds] diff --git a/var/mongoose/html/m/schedule.jim b/var/mongoose/html/m/schedule.jim new file mode 100755 index 0000000..16e7c45 --- /dev/null +++ b/var/mongoose/html/m/schedule.jim @@ -0,0 +1,85 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require epg.class + +proc eventtab {type title} { + set events [rsv list $type] + if {[set num [llength $events]] <= 0} return + + puts "
  • $title ($num)
  • \n"; + + foreach event $events { + set name [$event name] + set rsvicon [$event icon] + set RKIcon [$event RKIcon] + + set icons "" + if {$type eq "pending"} { + switch [$event get action] { + 0 { set icon "add" } + 1 { set icon "close" } + 2 { set icon "ar" } + 3 { set icon "pad" } + 4 { set icon "folder" } + } + append icons "" + } + if {$rsvicon ne ""} { + append icons "" + } + if {$RKIcon ne ""} { + append icons "" + } + + set s [$event get nsttime] + set d [$event get nduration] + set e $($s + $d) + set n [clock seconds] + + set recording 0 + if {$d > 0 && $n > $s && $n < $e} { + set recording 1 + } + + set last "[clock format $s -format {%a %d %b %Y %H:%M %Z}]" + if {$n > $e && [$event get ersvtype] <= 3} { + set ds "--- -- --- ---- --:--" + set dur "--:--:--
    + (Last: $last)" + } else { + set ds $last + set dur "[clock format [$event get nduration] \ + -format %T]" + } + puts " +
  • + [epg channelicon [$event channel_name] 80] +

    $icons $name

    +

    + $ds $dur +

    + "; + if {$recording} { + set perc $(($n - $s) * 100 / $d) + puts "

    + + [progressbar $perc] +

    + " + } + puts "
  • "; + } +} + +mheader + +puts "
      " +eventtab "pending" "Pending Events" +eventtab "TBL_RESERVATION" "Active Events" +puts "
    " + +mfooter + diff --git a/var/mongoose/html/m/schedule_d.jim b/var/mongoose/html/m/schedule_d.jim new file mode 100755 index 0000000..f91cac7 --- /dev/null +++ b/var/mongoose/html/m/schedule_d.jim @@ -0,0 +1,118 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require epg.class + +cgi_input + +set table [cgi_get table TBL_RESERVATION] +set slot [cgi_get slot 0] +set event [rsv slot $table $slot] + +mheader + +puts " + +
    +

    Scheduled Event

    +
    + +
    +" + +puts " + + + + + + + + + + + + +" + +set s [$event get nsttime] +set d [$event get nduration] +set e $($s + $d) +set n [clock seconds] + +if { $n > $e } { + puts " + + + + +" + +set crid [join [lrange [split [$event get szCRID] /] 1 end]] +if {$crid != ""} { + puts "" +} +puts "" +puts "" +puts "
    Event [$event get ulslot][join [$event iconset] ""]
    Channel +" +if {[$event get usLcn] ne ""} { + puts "[epg channelicon [$event channel_name] 50] + - [$event get usLcn] - [$event channel_name] + " +} + +puts " +
    Event Name[$event name]" +if {[$event get ucRecKind] == 4 && [$event name] ne [$event folder]} { + puts "(Folder: [$event folder])" +} + +puts "
    Start" +} else { + puts "" +} +puts "[clock format $s -format "%a %d %b %Y"] + [clock format $s -format "%H:%M %Z"]" + +if {$d > 0 && $n > $s && $n < $e} { + puts "
    " + set perc [expr [expr $n - $s] * 100 / $d] + puts "" + puts [progressbar $perc] +} + +puts " +
    Duration[clock format [$event get nduration] -format %T]
    " + if {[$event isseries]} { puts "Series" } else { puts "Event" } + puts " CRID + + [$event get szCRID] +
    Events" +set flag 0 +foreach ev [split [$event get szEventToRecord] "|"] { + if {$ev eq ""} { continue } + set ev [string range $ev 1 end] + if {$flag} { puts "
    " } + incr flag + set crid [join [lrange [split $ev /] 1 end]] + puts "$ev" +} +puts "
    Accepted" +if {[$event get aulEventToRecordInfo] ne ""} { + puts "Yes" +} +puts "
    " + +# Buttons +puts "Cancel Event" +puts "Close" + +epg cleanup + +mfooter + diff --git a/var/mongoose/html/m/script.js b/var/mongoose/html/m/script.js index 28e5380..7958b25 100644 --- a/var/mongoose/html/m/script.js +++ b/var/mongoose/html/m/script.js @@ -1,11 +1,127 @@ +function s(query) {return $("div.ui-page-active " + query);} + $(document).bind('pageinit', function() { $('div.status').last().load('/cgi-bin/status.jim', function() { $(this).slideDown('slow'); }); + $('a.refresh').on('click', function(e) { + e.preventDefault(); + $.mobile.showPageLoadingMsg(); + window.location.reload(true); + }); +}); + +$(document).delegate('#indexpage', 'pageinit', function() { + $('#epgsearch').on('click', function(e) { + e.preventDefault(); + $('#xepgsearch').toggle('slow'); + }); +}); + +$(document).delegate('#event_dpage', 'pageinit', function() { + $('a.schedule').click(function(e) { + e.preventDefault(); + $.mobile.showPageLoadingMsg(); + $('#epginfo_extra').load('/cgi-bin/epg/schedule.jim?' + + 'service=' + + encodeURIComponent($(this).attr('sid')) + + '&event=' + + encodeURIComponent($(this).attr('eid')) + + '&type=' + + $(this).attr('stype'), function() { + $('a.schedule').fadeOut('slow'); + }); + }); +}); + +$(document).delegate('#schedule_dpage', 'pageinit', function() { + $('#delevent').click(function(e) { + e.preventDefault(); + if (!confirm('Confirm event cancellation?')) + return; + $.mobile.showPageLoadingMsg(); + $.get('/sched/cancel.jim' + + '?slot=' + $(this).attr('slot') + + '&table=' + $(this).attr('tab'), function() { + $('.ui-dialog').dialog('close'); + $.mobile.showPageLoadingMsg(); + window.location.reload(true); + }); + }); +}); + +function insert_folder_size(folder, size) +{ + folder = folder.replace(/ /g, ''); + folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1'); + //console.log("Folder: (%s) = (%s)", folder, size); + if (size.search(/\d$/) == -1) + size += 'iB'; + else + size += ' bytes'; + if (folder == "") + $('span.dirsize').text(size); + else + $('#' + folder).text(size); +} + +function folder_size_callback(data, status, xhr) +{ + //console.log("Status: %s", status); + //console.dir(data); + $.each(data, insert_folder_size); +} + +function set_folder_new(folder, cnt) +{ + folder = folder.replace(/ /g, ''); + folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1'); + //console.log("Folder: (%s) = (%s)", folder, cnt); + $('#img' + folder).attr('src', '/img/Folder_New.png'); +} + +function new_folder_callback(data, status, xhr) +{ + //console.log("Status: %s", status); + //console.dir(data); + $.each(data, set_folder_new); +} + +function insert_shrunk(file, perc) +{ + if (perc == 0) + { + file = file.replace(/[ ]/g, ''); + file = file.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1'); + //console.log("File: (%s) = (%s)", file, perc); + $('#sp_' + file).show(); + } +} + +function shrunk_callback(data, status, xhr) +{ + //console.log("Status: %s", status); + //console.dir(data); + $.each(data, insert_shrunk); +} + +$(document).delegate('#browsepage', 'pageinit', function() { + var dir = $('span.dir').last().text(); + + //console.log('DIR: %O', dir); + + // Load folder sizes + $.getJSON('/cgi-bin/browse/sizes.jim?dir=' + encodeURIComponent(dir), + folder_size_callback); + + // Flag folders with unwatched items + $.getJSON('/cgi-bin/browse/newdir.jim?dir=' + encodeURIComponent(dir), + new_folder_callback); + + // Flag shrunk recordings + $.getJSON('/cgi-bin/browse/shrunk.jim?dir=' + encodeURIComponent(dir), + shrunk_callback); }); -//$(document).delegate('#channelpage', 'pageinit', function() { - //console.log('pageinit for channelpage'); -//}); diff --git a/var/mongoose/html/m/search.jim b/var/mongoose/html/m/search.jim new file mode 100755 index 0000000..61519d5 --- /dev/null +++ b/var/mongoose/html/m/search.jim @@ -0,0 +1,36 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require epg.class +source include/epgcell.jim + +cgi_input + +set term [cgi_get epgsearchterm ""] +set full [cgi_get epgsearchfull 0] + +mheader + +source include/searchstyle.jim +puts "
    • " +source include/searchform.jim +puts "
    • " + +set cmd search +if {$full} { set cmd searchall } +if {$term ne ""} { + #set records [epg fetch $cmd -extra $term] + set records [epg dbfetch $cmd -term $term] +} else { + set records {} +} + +foreach e $records { + epgcell $e +} + +puts "
    " + +mfooter + diff --git a/var/mongoose/html/m/style.css b/var/mongoose/html/m/style.css index af953dc..e46c5e0 100644 --- a/var/mongoose/html/m/style.css +++ b/var/mongoose/html/m/style.css @@ -1,4 +1,32 @@ +html body +{ + line-height: 1.55em; + font-family: "Lucida Grande", verdana, lucida, helvetica, sans-serif; + background-color: #f8f8f8; + margin: 1em; + padding: 0; + font-size: small; +} + +html>body +{ + font-size: small; +} + +p.datetime +{ + font-style: italic; +} + +img.progress +{ + background: transparent url(/img/percentback.png) top left no-repeat; + padding: 0; + margin: 0; + background-position: 1px 0; +} + .va { vertical-align: middle; @@ -37,3 +65,32 @@ li.sticky top: 0; } +table.keyval +{ + position: relative; + left: -10px; +} + +table.keyval th, th.key +{ + background: #ccff99; + font-weight: bold; + text-align: right; + color: black; +} + +table.keyval td +{ + background: #ffffcc; + color: black; +} + +.also +{ + font-size: 0.8em; + font-style: italic; + color: #333; + background: transparent; + text-decoration: none; +} + diff --git a/var/mongoose/html/sched/info.jim b/var/mongoose/html/sched/info.jim index f2d5f18..2691754 100755 --- a/var/mongoose/html/sched/info.jim +++ b/var/mongoose/html/sched/info.jim @@ -2,7 +2,7 @@ package require cgi source /mod/webif/lib/setup -require rsv.class progressbar +require rsv.class progressbar epg.class puts "Content-Type: text/html" puts "" @@ -15,46 +15,17 @@ set slot [cgi_get slot 0] set event [rsv slot $table $slot] -set rsvicon [$event icon] -if {$rsvicon ne ""} { - set rsvicon "" - if {[$event get ersvtype] == 3} { - if {[$event padded]} { - set padding "<- [expr [$event get ulPreOffset] / 60], [expr [$event get ulPostOffset] / 60] ->" - append rsvicon \ - "\"$padding\"" - } else { - append rsvicon \ - "" - } - } -} - -set RKIcon [$event RKIcon] -if {$RKIcon ne ""} { - set RKIcon "" -} - -if {[$event get ucRecKind] == 4} { - set series 1 -} else { - set series 0 -} - puts " - + " + puts "" } puts "" @@ -127,7 +93,7 @@ proc eventrow {event {table TBL_RESERVATION}} { set ds "[clock format $s -format "%a %d %b %Y"]
    [clock format $s -format "%H:%M %Z"]" - if { $n > $e && [$event get ersvtype] <= 3} { + if {$n > $e && [$event get ersvtype] <= 3} { puts "" } - puts "" + puts "" puts "" diff --git a/var/mongoose/include/menuicons.jim b/var/mongoose/include/menuicons.jim index 5b0d088..4b75d7e 100755 --- a/var/mongoose/include/menuicons.jim +++ b/var/mongoose/include/menuicons.jim @@ -3,7 +3,13 @@ source /mod/webif/lib/setup require settings.class -proc menuitem {title icon link {width 217} {height 0} {extra ""}} { +proc menuitem {title icon link {width 217} {height 0} {extra ""}} {{num 0}} { + incr num + if {$title eq ""} return + if {$num > 4} { + puts {
    } + set num 0 + } if {$extra ne ""} { append extra " " } puts -nonewline "
    @@ -42,7 +48,9 @@ if {[file exists "/mod/bin/ir"]} { menuitem "Remote" "/img/remote.png" /plugin/ir/remote.jim 217 228 } -puts {
    } +if {[[settings] nomobile] eq "0"} { + menuitem "Mobile Version" "/img/mobile.png" /m/ 217 228 +} menuitem "Service Management" "/img/spanner.png" \ /services.shtml 217 228 @@ -50,8 +58,7 @@ menuitem "Package Management" "/img/packages.png" \ /pkg/index.shtml 217 228 menuitem "Settings" "/images/326_1_00_Menu_Settings.png" \ /cgi-bin/settings.jim 217 228 + menuitem "Diagnostics" "/img/diagnostics.png" \ /diag/diag.jim 217 228 -puts {
    } - diff --git a/var/mongoose/lib/browse.class b/var/mongoose/lib/browse.class new file mode 100644 index 0000000..fc1b332 --- /dev/null +++ b/var/mongoose/lib/browse.class @@ -0,0 +1,54 @@ + +require system.class + +#if {![exists -proc class]} { package require oo } +#class browse {} + +set _flatten [system pkginst flatten] + +proc _addicon {img {hover ""} {class va}} { + set icon "\"$hover\"" + return $icon +} + +proc {dir iconset} {dir} { + set icons {} + set attrs {} + + set noflat 0 + if $::_flatten { + if {[string match {\[*\]} [file tail $dir]]} { set noflat 1 } + if {[file exists "$dir/.noflatten"]} { set noflat 1 } + if $noflat { lappend icons \ + [_addicon "/img/flat-tyre.png" "No-flatten" } + lappend attrs "noflat=$noflat" + } + + set autoshrink 0 + if {[file exists "$dir/.autoshrink"]} { + set autoshrink 1 + lappend icons [_addicon "/img/compress.png" "Auto-shrink"] + lappend attrs "autoshrink=$autoshrink" + } + + set autodedup 0 + if {[file exists "$dir/.autodedup"]} { + set autodedup 1 + lappend icons [_addicon "/img/dedup.png" "Auto-dedup"] + lappend attrs "autodedup=$autodedup" + } + + set autodecrypt 0 + if {[file exists "$dir/.autodecrypt"]} { + set autodecrypt 1 + lappend icons [_addicon "/img/decrypt.png" "Auto-decrypt"] + lappend attrs "autodecrypt=$autodecrypt" + } + + return [list $icons $attrs] +} + diff --git a/var/mongoose/lib/epg.class b/var/mongoose/lib/epg.class index 1642e2b..8f5811a 100644 --- a/var/mongoose/lib/epg.class +++ b/var/mongoose/lib/epg.class @@ -3,7 +3,7 @@ source /mod/webif/lib/setup if {![exists -proc class]} { package require oo } if {![exists -proc sqlite3.open]} { package require sqlite3 } -require settings.class progressbar rsv.class +require settings.class progressbar rsv.class mwildcard set ::epgpath /mnt/hd1/dvbepg/epg.dat @@ -155,6 +155,13 @@ epg method get_channel_info {} { } } +epg method copy_channel_info {s} { + set channel_num [$s get channel_num] + set channel_name [$s get channel_name] + set channel_crid [$s get channel_crid] + set channel_hsvc [$s get channel_hsvc] +} + epg method get_rsv {} { if {$hsvc == 0} { $self get_channel_info } if {$hsvc == 0} { return } @@ -334,6 +341,7 @@ proc {epg exec} {mode args} { proc {epg dbfetch} {mode args} { set records {} set extra "" + set params {} set select " select distinct *, @@ -384,6 +392,18 @@ proc {epg dbfetch} {mode args} { append q "and f.eFavGroup = $v " set sort "order by f.favIdx, start" } + -term { + set v [mwildcard $v] + append q "and (" + append q "e.name like '%s' " + lappend params "%$v%" + if {$mode eq "searchall"} { + append q \ + "or e.text like '%s' " + lappend params "%$v%" + } + append q ") " + } default { error "Invalid option, $arg" } } } @@ -394,10 +414,12 @@ proc {epg dbfetch} {mode args} { #puts "QUERY -$query-" set records {} - catch { - foreach rec [$::channeldb query $query] { + if {[catch { + foreach rec [$::channeldb query $query {*}$params] { lappend records [epg new $rec] } + } msg]} { + puts "MSG: $msg" } return $records } diff --git a/var/mongoose/lib/mwildcard b/var/mongoose/lib/mwildcard new file mode 100644 index 0000000..d9f8fc9 --- /dev/null +++ b/var/mongoose/lib/mwildcard @@ -0,0 +1,5 @@ + +proc mwildcard {v} { + return [string map {"%" "\\%" "*" "%" "_" "\\_" "?" "_"} $v] +} + diff --git a/var/mongoose/lib/rsv.class b/var/mongoose/lib/rsv.class index db85a25..25653a1 100755 --- a/var/mongoose/lib/rsv.class +++ b/var/mongoose/lib/rsv.class @@ -69,6 +69,10 @@ rsv method clear_ulslot {} { set ulslot -1 } +rsv method isseries {} { + if {$ucRecKind == 4} { return 1 } else { return 0 } +} + rsv method _strip {str} { if {[string range $str 1 2] eq "i7"} { set str [string range $str 3 end] @@ -143,6 +147,41 @@ rsv method RKIcon {} { return $RKIcon } +rsv method pendingicon {{width 30}} { + switch $action { + 0 { set icon "add" } + 1 { set icon "close" } + 2 { set icon "ar" } + 3 { set icon "pad" } + 4 { set icon "folder" } + } + return "" +} + +rsv method iconset {{height 20}} { + set iconlist {} + set icon [$self icon] + if {$icon ne ""} { + lappend iconlist "" + if {$ersvtype == 3} { + if {[$self padded]} { + set padding "<- [expr $ulPreOffset / 60], [expr $ulPostOffset / 60] ->" + lappend iconlist \ + "\"$padding\"" + } else { + lappend iconlist \ + "" + } + } + } + set icon [$self RKIcon] + if {$icon ne ""} { + lappend iconlist "" + } + return $iconlist +} + rsv method set_delete {} { set action 1 } diff --git a/var/mongoose/lib/settings.class b/var/mongoose/lib/settings.class index f256a7d..ee13603 100644 --- a/var/mongoose/lib/settings.class +++ b/var/mongoose/lib/settings.class @@ -23,6 +23,7 @@ class settings { smtp_server "" pkgdev 0 notoolbar 0 + nomobile 0 } settings method hostname {{name ""}} { @@ -121,6 +122,10 @@ settings method notoolbar {{val -1}} { return [$self _nval_setting notoolbar $val] } +settings method nomobile {{val -1}} { + return [$self _nval_setting nomobile $val] +} + settings method sortorder {{val -1}} { return [$self _nval_setting sortorder $val] }
    Event [$event get ulslot]$rsvicon $RKIcon[join [$event iconset] ""]
    Channel " if {[$event get usLcn] ne ""} { - puts " - + puts "[epg channelicon [$event channel_name] 50] - [$event get usLcn] - [$event channel_name] " } @@ -104,10 +75,10 @@ puts " set crid [join [lrange [split [$event get szCRID] /] 1 end]] if {$crid != ""} { puts "
    " - if $series { puts "Series" } else { puts "Event" } + if {[$event isseries]} { puts "Series" } else { puts "Event" } puts " CRID" puts -nonewline " diff --git a/var/mongoose/html/sched/sched.jim b/var/mongoose/html/sched/sched.jim index c299c75..3dba1d5 100755 --- a/var/mongoose/html/sched/sched.jim +++ b/var/mongoose/html/sched/sched.jim @@ -56,42 +56,8 @@ proc eventrow {event {table TBL_RESERVATION}} { ar=[expr ! [$event padded]]" altrow $attrs - set rsvicon [$event icon] - set RKIcon [$event RKIcon] - if {[$event get ucRecKind] == 4} { - set series 1 - } else { - set series 0 - } - - if {$rsvicon ne ""} { - set rsvicon "" - if {[$event get ersvtype] == 3} { - if {[$event padded]} { - set padding "<- [expr [$event get ulPreOffset] / 60], [expr [$event get ulPostOffset] / 60] ->" - append rsvicon \ - "\"$padding\"" - } else { - append rsvicon \ - "" - } - } - } - if {$RKIcon ne ""} { - set RKIcon "" - } - if {$table eq "pending"} { - switch [$event get action] { - 0 { set icon "add" } - 1 { set icon "close" } - 2 { set icon "ar" } - 3 { set icon "pad" } - 4 { set icon "folder" } - } - puts " - [$event pendingicon][$event get ulslot] --- -- --- ----
    --:--" @@ -147,7 +113,7 @@ proc eventrow {event {table TBL_RESERVATION}} { puts "[clock format [$event get nduration] -format %T]
    $rsvicon $RKIcon[join [$event iconset] ""]