diff --git a/webif/html/browse/crop/crop.jim b/webif/html/browse/crop/crop.jim
index 9ab6cc03..232b8cba 100755
--- a/webif/html/browse/crop/crop.jim
+++ b/webif/html/browse/crop/crop.jim
@@ -4,8 +4,8 @@ package require cgi
source /mod/webif/lib/setup
require ts.class pretty_size
-jqplugin progressbar
-jscss crop.js
+jqplugin progressbar iphone-style-checkboxes
+jscss crop.js style.css
header
set rfile [cgi_get file]
@@ -23,13 +23,13 @@ puts "
File: $rfile
Length: [clock format $len -format \"%T\"]
Size: [pretty_size [$ts size]] ([$ts get definition])
-Bookmarks: [$ts get bookmarks] @ "
+ Bookmarks: [$ts get bookmarks] @ "
puts [join [lmap i [$ts bookmarks 1] {
clock format $i -format "%T"
}] ", "]
-puts " File "
+puts " "
puts ""
@@ -48,14 +48,21 @@ append bookmarks [$ts bookmarks]
set keeping 0
set last 0
set start -1
+set newbookmarks "0 "
+set cur 0
foreach b $bookmarks {
if {$start < 0} {
+ # Start of a section to keep
set start $b
continue
}
+ # End of a section to keep
set end $b
- incr keeping $($end - $start)
+ set l $($end - $start)
+ incr keeping $l
+ incr cur $l
+ append newbookmarks "[expr $cur + 3] "
set left $($start * 500 / $len)
set right $($end * 500 / $len)
@@ -69,6 +76,7 @@ foreach b $bookmarks {
}
if {$start > 0} {
+ # Still in a keep section...
incr keeping $($len - $start)
set left $($start * 500 / $len)
div cut $last $($left - 1)
@@ -77,6 +85,10 @@ if {$start > 0} {
div cut $last 500
}
+if {$cur > $keeping - 8 && $keeping - 8 > 0} {
+ set newbookmarks [lreplace $newbookmarks end end $($keeping - 8)]
+}
+
set keepperc $($keeping * 100.0 / $len)
set esttime $(int($keeping * 0.025))
if {[$ts get definition] eq "HD"} { set esttime $($esttime * 4) }
@@ -86,7 +98,23 @@ puts "
Keeping:
[clock format $keeping -format "%T"] ([format "%.2f" $keepperc]%)
-
+"
+
+puts "
+
+
+New Bookmarks:
+
+
+$newbookmarks (
+"
+puts [join [lmap i $newbookmarks {
+ clock format $i -format "%T"
+}] ", "]
+
+puts " ) "
+
+puts "
Time:
Cropping will take around [clock format $esttime -format "%T"]
@@ -98,10 +126,19 @@ puts "
>
-
Invert selection
-
Perform crop operation
+
Back to media list
+Save New Bookmarks
+
Cropping:
@@ -109,6 +146,5 @@ Cropping:
-
"
diff --git a/webif/html/browse/crop/crop.js b/webif/html/browse/crop/crop.js
index 52b6c9c2..a400e0bb 100755
--- a/webif/html/browse/crop/crop.js
+++ b/webif/html/browse/crop/crop.js
@@ -1,18 +1,29 @@
var handle = 0;
+function escapestring(str)
+{
+ str = JSON.stringify(String(str));
+ str = str.substring(1, str.length - 1);
+ return str;
+}
+
function update()
{
- var perc = $('#params').attr('perc');
- var file = $('#params').attr('file');
-
- $.get('progress.jim' + '?perc=' + perc + '&file=' + file,
- function(data) {
+ $.get('progress.jim', {
+ 'perc': $('#params').attr('perc'),
+ 'file': $('#params').attr('file')
+ }, function(data) {
if (handle)
$('#progressbar').reportprogress(data);
});
}
-$(document).ready(function() {
+$(function() {
+
+$('[type="checkbox"]').iphoneStyle({
+ checkedLabel: 'YES',
+ uncheckedLabel: 'NO'
+});
$('#progressbar').reportprogress(0);
@@ -20,24 +31,51 @@ $('#back').button().click(function() {
window.location = '/go/browse?dir=' + $('#params').attr('dir');
});
+$('#save').button({icons: {primary: "ui-icon-disk"}})
+ .on('click', function() {
+ $('#progressdiv,#output,#save').hide('slow');
+ $.post('../bookmarks/save.jim', {
+ 'file': $('#fileparams').attr('file'),
+ 'bookmarks': $('#bookmarks').attr('val')
+ }, function(data) {
+ $('#results').html(data)
+ .slideDown('slow')
+ .delay(6000)
+ .slideUp('slow');
+ $('#originalbookmarks')
+ .html($('#newbookmarks').clone());
+ });
+});
+
$('#cropit').button().click(function() {
$('#cropdiv').hide('slow');
$('#progressdiv').show('slow');
$('#back').hide();
handle = setInterval("update()", 1000);
$('#output').show().text('Please do not interrupt...')
- .load('execute.jim?file=' + $('#params').attr('file') +
- '&invert=' + $('#invert').attr('invert'),
- function() {
+ .load('execute.jim', {
+ 'file': $('#params').attr('file'),
+ 'invert': $('#invert').attr('invert')
+ }, function() {
clearInterval(handle);
handle = 0;
- $('#back').show();
+ $('#back,#save').show();
+ $('#cutplan').html('File cropping complete');
+ $('#originalbookmarks').empty();
$('#progressbar').reportprogress(100);
+ if ($('#saveit').prop('checked'))
+ {
+ $('#save').trigger('click');
+ $('#progressdiv')
+ .delay(3000)
+ .text('Cropping complete.');
+ }
});
});
$('#invert').button().on('click', function() {
- window.location = 'crop.jim?file=' + $('#params').attr('file') +
+ window.location = 'crop.jim?file=' +
+ escapestring($('#params').attr('file')) +
'&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
});
diff --git a/webif/html/browse/crop/execute.jim b/webif/html/browse/crop/execute.jim
index a0382b6c..3fd5d353 100755
--- a/webif/html/browse/crop/execute.jim
+++ b/webif/html/browse/crop/execute.jim
@@ -68,6 +68,7 @@ system endop $token
set newname "$shname-[clock seconds]"
puts "Renaming file group to $newname"
+puts "
"
ts renamegroup "$dir/$shname.ts" $newname
exec /mod/bin/hmt "+setfilename=$newname" "$dir/$newname.hmt"
# New nicesplice shrinks whilst cropping.
diff --git a/webif/html/browse/crop/style.css b/webif/html/browse/crop/style.css
new file mode 100644
index 00000000..f0e45465
--- /dev/null
+++ b/webif/html/browse/crop/style.css
@@ -0,0 +1,13 @@
+
+div.switchlabel
+{
+ height: 27px;
+ line-height: 27px;
+}
+
+div.sliderlabel
+{
+ height: 40px;
+ line-height: 40px;
+}
+