Merge branch 'master' into df-epglostchannel-patch
This commit is contained in:
commit
e201219fde
|
@ -14,6 +14,7 @@ set ts [ts fetch $rfile]
|
|||
set dir [file dirname $rfile]
|
||||
|
||||
set len [$ts duration 1]
|
||||
set planwidth 500
|
||||
|
||||
puts "
|
||||
<fieldset>
|
||||
|
@ -29,12 +30,17 @@ puts [join [lmap i [$ts bookmarks 1] {
|
|||
clock format $i -format "%T"
|
||||
}] ", "]
|
||||
|
||||
puts "</td></tr><tr><th> </th><td id=cutplan>"
|
||||
# set minimum width as positioned contents doesn't resize its cell
|
||||
puts "</td></tr><tr><th> </th><td id=cutplan style=\"min-width: ${planwidth}px\">"
|
||||
|
||||
puts "<div style=\"position: relative; top: -10px\">"
|
||||
|
||||
proc div {type left right} {
|
||||
set width $($right - $left)
|
||||
if {$width < 0} {
|
||||
# negative values are invalid for CSS width
|
||||
set width 0
|
||||
}
|
||||
puts "<div class=$type style=\"left: ${left}px; width: ${width}px\">
|
||||
$type</div>"
|
||||
}
|
||||
|
@ -64,8 +70,8 @@ foreach b $bookmarks {
|
|||
incr cur $l
|
||||
append newbookmarks "[expr $cur + 3] "
|
||||
|
||||
set left $($start * 500 / $len)
|
||||
set right $($end * 500 / $len)
|
||||
set left $($start * $planwidth / $len)
|
||||
set right $($end * $planwidth / $len)
|
||||
|
||||
div cut $last $($left - 1)
|
||||
div keep $left $($right - 1)
|
||||
|
@ -78,11 +84,11 @@ foreach b $bookmarks {
|
|||
if {$start > 0} {
|
||||
# Still in a keep section...
|
||||
incr keeping $($len - $start)
|
||||
set left $($start * 500 / $len)
|
||||
set left $($start * $planwidth / $len)
|
||||
div cut $last $($left - 1)
|
||||
div keep $left 500
|
||||
div keep $left $planwidth
|
||||
} else {
|
||||
div cut $last 500
|
||||
div cut $last $planwidth
|
||||
}
|
||||
|
||||
if {$cur > $keeping - 8 && $keeping - 8 > 0} {
|
||||
|
@ -115,7 +121,7 @@ puts [join [lmap i $newbookmarks {
|
|||
puts " )</td></tr>"
|
||||
|
||||
puts "
|
||||
<tr><th>Time:</th>
|
||||
<tr id=esttime><th>Time:</th>
|
||||
<td>Cropping will take around [clock format $esttime -format "%T"]</td></tr>
|
||||
</table>
|
||||
|
||||
|
@ -130,9 +136,9 @@ puts "
|
|||
<td><button id=invert invert=$invert>Invert selection</button></td>
|
||||
<td><button id=cropit>Perform crop operation</button></td>
|
||||
<td>
|
||||
Save new bookmarks?
|
||||
<label id=saveitlabel for=saveit>Save new bookmarks?</label>
|
||||
<input id=saveit type=checkbox name=saveit checked>
|
||||
<label id=saveitlabel for=saveit> </label>
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
var handle = 0;
|
||||
|
||||
function escapestring(str)
|
||||
{
|
||||
str = JSON.stringify(String(str));
|
||||
str = str.substring(1, str.length - 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
$.get('progress.jim', {
|
||||
|
@ -27,7 +20,8 @@ $('[type="checkbox"]').iphoneStyle({
|
|||
|
||||
$('#progressbar').reportprogress(0);
|
||||
|
||||
$('#back').button().click(function() {
|
||||
$('#back').button({icons: {primary: "ui-icon-arrowreturnthick-1-w"}})
|
||||
.on('click', function() {
|
||||
window.location = '/go/browse?dir=' + $('#params').attr('dir');
|
||||
});
|
||||
|
||||
|
@ -44,10 +38,17 @@ $('#save').button({icons: {primary: "ui-icon-disk"}})
|
|||
.slideUp('slow');
|
||||
$('#originalbookmarks')
|
||||
.html($('#newbookmarks').clone());
|
||||
$('#esttime').hide();
|
||||
if ($('#results').html().indexOf(' successful') < 0) {
|
||||
$('#saveit').hide();
|
||||
$('#saveitlabel').hide();
|
||||
$('#save').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#cropit').button().click(function() {
|
||||
$('#cropit').button({icons: {primary: "ui-icon-scissors"}})
|
||||
.on('click', function() {
|
||||
$('#cropdiv').hide('slow');
|
||||
$('#progressdiv').show('slow');
|
||||
$('#back').hide();
|
||||
|
@ -56,7 +57,7 @@ $('#cropit').button().click(function() {
|
|||
.load('execute.jim', {
|
||||
'file': $('#params').attr('file'),
|
||||
'invert': $('#invert').attr('invert')
|
||||
}, function() {
|
||||
}, function() {
|
||||
clearInterval(handle);
|
||||
handle = 0;
|
||||
$('#back,#save').show();
|
||||
|
@ -73,10 +74,10 @@ $('#cropit').button().click(function() {
|
|||
});
|
||||
});
|
||||
|
||||
$('#invert').button().on('click', function() {
|
||||
window.location = 'crop.jim?file=' +
|
||||
escapestring($('#params').attr('file')) +
|
||||
'&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
|
||||
$('#invert').button({icons: {primary: "ui-icon-shuffle"}})
|
||||
.on('click', function() {
|
||||
window.location = window.location.href.replace(/&invert=[01]/,'') +
|
||||
'&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -11,3 +11,8 @@ div.sliderlabel
|
|||
line-height: 40px;
|
||||
}
|
||||
|
||||
#cutplan {
|
||||
/* ensure cut plan segments are aligned left */
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,10 @@ proc icon {img {hover ""} {extra ""} {class "va"}} {
|
|||
puts ">"
|
||||
}
|
||||
|
||||
proc nbsp {str} {
|
||||
return [string map {" " } $str]
|
||||
}
|
||||
|
||||
proc directory {file bfile tbfile} {
|
||||
puts "<div class=\"va relative\">"
|
||||
set img "/images/711_1_09_Media_Folder.png"
|
||||
|
@ -69,7 +73,7 @@ proc directory {file bfile tbfile} {
|
|||
puts "<a class=dbf
|
||||
href=\"$::env(SCRIPT_NAME)?dir=[cgi_quote_url $file]\"
|
||||
file=\"[cgi_quote_html $file]\">"
|
||||
puts "$bfile</a><span class=filesize id=\"$tbfile\">
|
||||
puts "[nbsp $bfile]</a><span class=filesize id=\"ID$tbfile\">
|
||||
</span>"
|
||||
|
||||
lassign [dir iconset $file] icons attrs
|
||||
|
@ -106,13 +110,12 @@ proc entry {file} {{i 0}} {
|
|||
global dircount filecount dinuse
|
||||
|
||||
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"]} {
|
||||
incr dircount
|
||||
directory $file $bfile $tbfile
|
||||
directory $file $bfile [b64uencode [jsescape $bfile]]
|
||||
return
|
||||
}
|
||||
set ext [string tolower [file extension $file]]
|
||||
|
@ -174,7 +177,7 @@ proc entry {file} {{i 0}} {
|
|||
<input class=\"$fscl\" type=checkbox>
|
||||
<a class=bf title=\"$synopsis\"
|
||||
file=\"[cgi_quote_html $file]\" type=$type href=#>
|
||||
$bfile
|
||||
[nbsp $bfile]
|
||||
</a>
|
||||
"
|
||||
|
||||
|
|
|
@ -111,8 +111,13 @@ function epginfo_callback(data, status, xhr)
|
|||
|
||||
function insert_folder_size(folder, size)
|
||||
{
|
||||
folder = folder.replace(/ /g, '');
|
||||
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
|
||||
// folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
|
||||
// ID of size element is ID + RFC4648 s5 encoding of folder name
|
||||
folder = "ID" +
|
||||
btoa(escape(folder))
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_')
|
||||
.replace(/=/g, '');
|
||||
//console.log("Folder: (%s) = (%s)", folder, size);
|
||||
if (size.search(/\d$/) == -1)
|
||||
size += 'iB';
|
||||
|
|
|
@ -19,7 +19,7 @@ foreach arg $argv {
|
|||
lappend dirs $arg
|
||||
}
|
||||
}
|
||||
if {![llength $dirs]} { lappend dirs [exec pwd] }
|
||||
if {![llength $dirs]} { lappend dirs [pwd] }
|
||||
|
||||
foreach dir $dirs {
|
||||
if {[string index $dir end] eq "/"} {
|
||||
|
|
|
@ -20,3 +20,98 @@ proc midnight {} {{today ""}} {
|
|||
return [clock scan "$today 00:00:00" -format "%Y %m %d %T"]
|
||||
}
|
||||
|
||||
# Base-64 according to RFC 4648
|
||||
# See https://wiki.tcl-lang.org/page/base64
|
||||
|
||||
if {![exists -command binary]} { package require binary }
|
||||
|
||||
# RFC 4648 section 4
|
||||
set ::b64::map {
|
||||
000000 A 000001 B 000010 C 000011 D 000100 E 000101 F
|
||||
000110 G 000111 H 001000 I 001001 J 001010 K 001011 L
|
||||
001100 M 001101 N 001110 O 001111 P 010000 Q 010001 R
|
||||
010010 S 010011 T 010100 U 010101 V 010110 W 010111 X
|
||||
011000 Y 011001 Z 011010 a 011011 b 011100 c 011101 d
|
||||
011110 e 011111 f 100000 g 100001 h 100010 i 100011 j
|
||||
100100 k 100101 l 100110 m 100111 n 101000 o 101001 p
|
||||
101010 q 101011 r 101100 s 101101 t 101110 u 101111 v
|
||||
110000 w 110001 x 110010 y 110011 z 110100 0 110101 1
|
||||
110110 2 110111 3 111000 4 111001 5 111010 6 111011 7
|
||||
111100 8 111101 9 111110 + 111111 /
|
||||
}
|
||||
|
||||
set ::b64::unmap [join [lmap {a b} $::b64::map {list $b $a}]]
|
||||
|
||||
proc ::b64::encode {str} {
|
||||
binary scan $str B* bits
|
||||
switch [expr {[string length $bits]%6}] {
|
||||
0 {set tail {}}
|
||||
2 {append bits 0000; set tail ==}
|
||||
4 {append bits 00; set tail =}
|
||||
}
|
||||
return [string cat [string map $::b64::map $bits] $tail]
|
||||
}
|
||||
|
||||
proc ::b64::decode {str} {
|
||||
set nstr [string trimright $str =]
|
||||
set dstr [string map $::b64::unmap $nstr]
|
||||
switch [expr [string length $str]-[string length $nstr]] {
|
||||
0 {#nothing to do}
|
||||
1 {set dstr [string range $dstr 0 {end-2}]}
|
||||
2 {set dstr [string range $dstr 0 {end-4}]}
|
||||
}
|
||||
return [binary format B* $dstr]
|
||||
}
|
||||
|
||||
# RFC 4648 section 5
|
||||
proc ::b64::url_encode {str} {
|
||||
tailcall string map {+ - / _ = ""} [::b64::encode $str]
|
||||
}
|
||||
|
||||
proc ::b64::url_decode {str} {
|
||||
tailcall ::b64::decode [string map {- + _ /} $str]
|
||||
}
|
||||
|
||||
alias b64encode ::b64::encode
|
||||
alias b64decode ::b64::decode
|
||||
alias b64uencode ::b64::url_encode
|
||||
alias b64udecode ::b64::url_decode
|
||||
|
||||
|
||||
# ECMA-262 Annex B.2.1
|
||||
proc ::js::_escape {str} {
|
||||
return [join [lmap c [split $str ""] {
|
||||
if {1 != [scan $c "%c" cc]} {
|
||||
format "%s" $c
|
||||
} elseif {$cc < 256} {
|
||||
format "%%%02X" $cc
|
||||
} else {
|
||||
format "%%u%04X" $cc
|
||||
}
|
||||
}] ""]
|
||||
}
|
||||
|
||||
proc ::js::_unescape {str} {
|
||||
if {1 == [scan $str "%%%2x" cc] ||
|
||||
1 == [scan $str "%%u%4x" cc]} {
|
||||
return [format "%c" $cc]
|
||||
} else {
|
||||
return $str
|
||||
}
|
||||
}
|
||||
|
||||
proc ::js::escape {str} {
|
||||
return [subst -nobackslashes -novariables \
|
||||
[regsub -all -- {[^A-Za-z0-9@*_+-./]+} $str \
|
||||
{[::js::_escape {&}]}]]
|
||||
}
|
||||
|
||||
proc ::js::unescape {str} {
|
||||
return [subst -nobackslashes -novariables \
|
||||
[regsub -all -- {%(u[[:xdigit:]]{2})?[[:xdigit:]]{2}} $str \
|
||||
{[::js::_unescape {&}]}]]
|
||||
}
|
||||
|
||||
alias jsescape ::js::escape
|
||||
alias jsunescape ::js::unescape
|
||||
|
||||
|
|
Loading…
Reference in New Issue