From 8146627f18498fd114a9620ea9f44e2f3c1ebf2f Mon Sep 17 00:00:00 2001 From: hummypkg Date: Mon, 28 Nov 2011 15:24:38 +0000 Subject: [PATCH] join is working, more webif functions git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@538 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/cgi-bin/browse.jim | 38 ++++++--- var/mongoose/cgi-bin/browse/browse.js | 53 +++++++++--- var/mongoose/cgi-bin/browse/join.jim | 81 +++++++++++++++++-- var/mongoose/cgi-bin/browse/join_backend.jim | 9 ++- var/mongoose/cgi-bin/browse/join_progress.jim | 23 ++++++ var/mongoose/lib/system.class | 5 ++ 7 files changed, 180 insertions(+), 31 deletions(-) create mode 100755 var/mongoose/cgi-bin/browse/join_progress.jim diff --git a/CONTROL/control b/CONTROL/control index 8b1208b9..18558f65 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -4,7 +4,7 @@ Section: web Version: 0.8.2 Architecture: mipsel Maintainer: af123@hummypkg.org.uk -Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.7),hmt(>=1.1.1),ssmtp +Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4-1),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.7),hmt(>=1.1.1),ssmtp Replaces: af123-webif Conflicts: af123-webif Suggests: ffmpeg,webif-iphone,nicesplice diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim index 698317e5..9dbe074f 100755 --- a/var/mongoose/cgi-bin/browse.jim +++ b/var/mongoose/cgi-bin/browse.jim @@ -7,6 +7,8 @@ require ts.class pretty_size system.class puts "Content-Type: text/html" puts "" +set nicesplice [system pkginst nicesplice] + set ignore {.nts .thm .hmt .hmi} set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov} @@ -162,7 +164,7 @@ puts { if {[system model] eq "HDR"} { puts {
  • Decrypt
  • } } -if {[file exists /mod/bin/nicesplice]} { +if $nicesplice { puts {
  • Crop
  • } } puts { @@ -271,28 +273,40 @@ foreach file [lsort [glob -nocomplain "$dir"]] { entry $file } +puts "Select all | none" + puts "" +puts "
    " + +puts { + +} + +# Join +if $nicesplice { + puts { } +} + +puts "
    " + # De-duplicate puts { - -} - -# Join -if {[file exists /mod/bin/nicesplice]} { - puts { } + } # Streamer file if {[file exists /mnt/hd3/Streamer_down_file]} { - puts { - -} + puts { + + } } +puts "
    " + footer diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index 16294a3b..33b10d7d 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -1,3 +1,23 @@ +(function($) +{ + $.fn.enable = function() + { + return this.each(function() { + $(this) + .removeClass('ui-state-disabled') + .removeProp('disabled'); + }); + }; + + $.fn.disable = function() + { + return this.each(function() { + $(this) + .addClass('ui-state-disabled') + .prop('disabled', true); + }); + }; +})(jQuery); function epginfo_callback(data, status, xhr) { @@ -343,9 +363,16 @@ var menuclick = function(action, el, pos) encodeURIComponent($('#save_stream').attr('file'))); }); - $('#join').button() - .prop('disabled', true) - .addClass('ui-state-disabled') + $('#selectall').click(function(e) { + e.preventDefault(); + $('input.fs').attr('checked', true).trigger('change'); + }); + $('#deselectall').click(function(e) { + e.preventDefault(); + $('input.fs:checked').attr('checked', false).trigger('change'); + }); + + $('#join').button().disable() .click(function() { var files = new Array(); var els = $('input.fsts:checked + a').each(function() { @@ -356,17 +383,25 @@ var menuclick = function(action, el, pos) files.join(); }); + $('#delete').button().disable() + .click(function() { + console.log("delete"); + }); + $('input.fs').change(function() { + var num = $('input.fs:checked').size(); + if (num > 0) + $('#delete').enable(); + else + $('#delete').disable(); + var num = $('input.fsts:checked').size(); if (num > 1) - $('#join') - .removeProp('disabled') - .removeClass('ui-state-disabled'); + $('#join').enable(); else - $('#join') - .prop('disabled', true) - .addClass('ui-state-disabled'); + $('#join').disable(); }); + }); diff --git a/var/mongoose/cgi-bin/browse/join.jim b/var/mongoose/cgi-bin/browse/join.jim index 61dfd12b..152292b0 100755 --- a/var/mongoose/cgi-bin/browse/join.jim +++ b/var/mongoose/cgi-bin/browse/join.jim @@ -7,7 +7,7 @@ require ts.class pretty_size puts "Content-Type: text/html\r\n\r\n" header -cgi_input +cgi_input 1 #cgi_dump puts { @@ -19,43 +19,110 @@ puts { span.pl { padding-left: 2em; } + + +

    Drag the files below into order, enter a name for the resulting file and then click the Join button. } puts "

    " -puts { +puts "

    + +
    Name for joined file: - +
    -
    +
    +Joining:
    + +
    +
    +" +puts { } diff --git a/var/mongoose/cgi-bin/browse/join_backend.jim b/var/mongoose/cgi-bin/browse/join_backend.jim index f026cd0d..a873222b 100755 --- a/var/mongoose/cgi-bin/browse/join_backend.jim +++ b/var/mongoose/cgi-bin/browse/join_backend.jim @@ -6,22 +6,27 @@ require ts.class pretty_size puts "Content-Type: text/html\r\n\r\n" -cgi_input +cgi_input 1 #cgi_dump set joinstart [clock milliseconds] set cmd {/mod/bin/nicesplice} +set dst [file rootname [cgi_get dest "joined"]] foreach file [split [cgi_get files] ","] { + set file [cgi_unquote_input $file] lappend cmd "-in" [file rootname $file] set dir [file dirname $file] } -lappend cmd "-out" "$dir/[cgi_get dest]" +lappend cmd "-out" "$dir/$dst" puts "($cmd)" puts [exec {*}$cmd] +set ts [ts fetch "$dir/$dst.ts"] +$ts settitle $dst + set jointime [expr [expr [clock milliseconds] - $joinstart] / 1000.0] puts "Time taken: $jointime" diff --git a/var/mongoose/cgi-bin/browse/join_progress.jim b/var/mongoose/cgi-bin/browse/join_progress.jim new file mode 100755 index 00000000..53d2284f --- /dev/null +++ b/var/mongoose/cgi-bin/browse/join_progress.jim @@ -0,0 +1,23 @@ +#!/mod/bin/jimsh + +package require cgi +#source /mod/var/mongoose/lib/setup + +puts "Content-Type: text/html\r\n\r\n" + +cgi_input +#cgi_dump + +set expected [cgi_get esize 1] +set file [file normalize [cgi_get file]] + +if {![file exists $file]} { + puts "0" +} else { + set sz [file size $file] + + set perc [expr $sz * 100 / $expected] + if {$perc > 100} { set perc 100 } + puts $perc +} + diff --git a/var/mongoose/lib/system.class b/var/mongoose/lib/system.class index 14492606..d4f39886 100644 --- a/var/mongoose/lib/system.class +++ b/var/mongoose/lib/system.class @@ -37,6 +37,11 @@ proc {system pkgver} {{pkg webif}} { return [lrange [split [exec opkg list-installed $pkg] " "] 2 end] } +proc {system pkginst} {pkg} { + if {[exec opkg list-installed $pkg] ne ""} { + return 1 } else { return 0 } +} + proc {system mediaroot} {} { switch [system model] { HDR { return "/media/My Video" }